From ae8b4348b33fc1232121ad29ddee88d43ab98089 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 14 Dec 2025 11:29:54 -0500 Subject: [PATCH 001/176] + xo-object2 --- CMakeLists.txt | 32 +++++++++++++++++ cmake/xo-bootstrap-macros.cmake | 35 ++++++++++++++++++ cmake/xo_object2Config.cmake.in | 7 ++++ include/xo/object2/DFloat.hpp | 14 ++++++++ include/xo/object2/DInteger.hpp | 14 ++++++++ include/xo/object2/IGCObject_DFloat.hpp | 30 ++++++++++++++++ include/xo/object2/IGCObject_DInteger.hpp | 30 ++++++++++++++++ src/object2/CMakeLists.txt | 12 +++++++ src/object2/IGCObject_DFloat.cpp | 44 +++++++++++++++++++++++ src/object2/IGCObject_DInteger.cpp | 44 +++++++++++++++++++++++ 10 files changed, 262 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/xo-bootstrap-macros.cmake create mode 100644 cmake/xo_object2Config.cmake.in create mode 100644 include/xo/object2/DFloat.hpp create mode 100644 include/xo/object2/DInteger.hpp create mode 100644 include/xo/object2/IGCObject_DFloat.hpp create mode 100644 include/xo/object2/IGCObject_DInteger.hpp create mode 100644 src/object2/CMakeLists.txt create mode 100644 src/object2/IGCObject_DFloat.cpp create mode 100644 src/object2/IGCObject_DInteger.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..7d3a714e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,32 @@ +# xo-object2/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(xo_object2 VERSION 0.1) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +set(PROJECT_CXX_FLAGS "") +#set(PROJECT_CXX_FLAGS "-fconcepts-diagnostics-depth=2") # gcc-only! +add_definitions(${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- + +# must complete definition of expression lib before configuring examples +add_subdirectory(src/object2) +#add_subdirectory(utest) +#xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +# ---------------------------------------------------------------- +# docs targets depend on other library/utest/exec targets above, +# --> must come after them. +# +#add_subdirectory(docs) + +# end CMakeLists.txt diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..aba31169 --- /dev/null +++ b/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,35 @@ +# ---------------------------------------------------------------- +# 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) + 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_cxx) + +xo_cxx_bootstrap_message() diff --git a/cmake/xo_object2Config.cmake.in b/cmake/xo_object2Config.cmake.in new file mode 100644 index 00000000..c32a8368 --- /dev/null +++ b/cmake/xo_object2Config.cmake.in @@ -0,0 +1,7 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +#find_dependency(indentlog) +find_dependency(xo_alloc2) +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp new file mode 100644 index 00000000..52a3ba43 --- /dev/null +++ b/include/xo/object2/DFloat.hpp @@ -0,0 +1,14 @@ +/** @file DFloat.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +namespace xo { + namespace scm { + using DFloat = double; + } /*nmaespace obj*/ +} /*namespace xo*/ + +/* end DFloat.hpp */ diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp new file mode 100644 index 00000000..ded9e805 --- /dev/null +++ b/include/xo/object2/DInteger.hpp @@ -0,0 +1,14 @@ +/** @file DInteger.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +namespace xo { + namespace scm { + using DInteger = double; + } /*nmaespace obj*/ +} /*namespace xo*/ + +/* end DInteger.hpp */ diff --git a/include/xo/object2/IGCObject_DFloat.hpp b/include/xo/object2/IGCObject_DFloat.hpp new file mode 100644 index 00000000..59f4c349 --- /dev/null +++ b/include/xo/object2/IGCObject_DFloat.hpp @@ -0,0 +1,30 @@ +/** @file IGCObject_DFloat.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include "xo/alloc2/AAllocator.hpp" +#include "xo/alloc2/AGCObject.hpp" +#include "xo/alloc2/IGCObject_Xfer.hpp" +#include "DFloat.hpp" + +namespace xo { + namespace scm { + /* changes here coordinate with: + * IGCObject_Xfer + */ + struct IGCObject_DFloat { + public: + using AAllocator = xo::mm::AAllocator; + using size_type = std::size_t; + + static size_type shallow_size(const DFloat & d) noexcept; + static DFloat * shallow_copy(const DFloat & d, obj mm) noexcept; + static size_type forward_children(DFloat & d) noexcept; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DFloat.hpp */ diff --git a/include/xo/object2/IGCObject_DInteger.hpp b/include/xo/object2/IGCObject_DInteger.hpp new file mode 100644 index 00000000..0c36062d --- /dev/null +++ b/include/xo/object2/IGCObject_DInteger.hpp @@ -0,0 +1,30 @@ +/** @file IGCObject_DInteger.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include "xo/alloc2/AAllocator.hpp" +#include "xo/alloc2/AGCObject.hpp" +#include "xo/alloc2/IGCObject_Xfer.hpp" +#include "DInteger.hpp" + +namespace xo { + namespace scm { + /* changes here coordinate with: + * IGCObject_Xfer + */ + struct IGCObject_DInteger { + public: + using AAllocator = xo::mm::AAllocator; + using size_type = std::size_t; + + static size_type shallow_size(const DInteger & d) noexcept; + static DInteger * shallow_copy(const DInteger & d, obj mm) noexcept; + static size_type forward_children(DInteger & d) noexcept; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DInteger.hpp */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt new file mode 100644 index 00000000..25b46ba1 --- /dev/null +++ b/src/object2/CMakeLists.txt @@ -0,0 +1,12 @@ +# object2/CMakeLists.txt + +set(SELF_LIB xo_object2) +set(SELF_SRCS + IGCObject_DFloat.cpp + IGCObject_DInteger.cpp + ) + +xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) +# note: deps here must also appear in cmake/xo_alloc2Config.cmake.in +xo_dependency(${SELF_LIB} xo_alloc2) +#xo_dependency(${SELF_LIB} indentlog) diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp new file mode 100644 index 00000000..2c339b09 --- /dev/null +++ b/src/object2/IGCObject_DFloat.cpp @@ -0,0 +1,44 @@ +/** @file IGCObject_DFloat.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "IGCObject_DFloat.hpp" +#include "AAllocator.hpp" +#include "xo/facet/obj.hpp" +#include + +namespace xo { + using xo::mm::AAllocator; + using xo::facet::obj; + using std::size_t; + + namespace scm { + size_t + IGCObject_DFloat::shallow_size(const DFloat &) noexcept + { + return sizeof(DFloat); + } + + DFloat * + IGCObject_DFloat::shallow_copy(const DFloat & src, + obj mm) noexcept + { + DFloat * copy = (DFloat *)mm.alloc(sizeof(DFloat)); + + if (copy) + *copy = src; + + return copy; + } + + size_t + IGCObject_DFloat::forward_children(DFloat &) noexcept + { + return sizeof(DFloat); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DFloat.cpp */ diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp new file mode 100644 index 00000000..0fd2b2e6 --- /dev/null +++ b/src/object2/IGCObject_DInteger.cpp @@ -0,0 +1,44 @@ +/** @file IGCObject_DInteger.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "IGCObject_DInteger.hpp" +#include "AAllocator.hpp" +#include "xo/facet/obj.hpp" +#include + +namespace xo { + using xo::mm::AAllocator; + using xo::facet::obj; + using std::size_t; + + namespace scm { + size_t + IGCObject_DInteger::shallow_size(const DInteger &) noexcept + { + return sizeof(DInteger); + } + + DInteger * + IGCObject_DInteger::shallow_copy(const DInteger & src, + obj mm) noexcept + { + DInteger * copy = (DInteger *)mm.alloc(sizeof(DInteger)); + + if (copy) + *copy = src; + + return copy; + } + + size_t + IGCObject_DInteger::forward_children(DInteger &) noexcept + { + return sizeof(DInteger); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DInteger.cpp */ From 1caa002faa0ce0d8a564ba1eaffd6335f0d1724f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 14 Dec 2025 13:52:29 -0500 Subject: [PATCH 002/176] xo-alloc2 xo-object: bugfix + refactor -> IGCObject_DList builds --- include/xo/object2/DInteger.hpp | 4 ++- include/xo/object2/DList.hpp | 26 +++++++++++++++ include/xo/object2/IGCObject_DList.hpp | 36 +++++++++++++++++++++ src/object2/CMakeLists.txt | 1 + src/object2/IGCObject_DList.cpp | 45 ++++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 include/xo/object2/DList.hpp create mode 100644 include/xo/object2/IGCObject_DList.hpp create mode 100644 src/object2/IGCObject_DList.cpp diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index ded9e805..3457af79 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -5,9 +5,11 @@ #pragma once +#include + namespace xo { namespace scm { - using DInteger = double; + using DInteger = std::int64_t; } /*nmaespace obj*/ } /*namespace xo*/ diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp new file mode 100644 index 00000000..f0be1cf4 --- /dev/null +++ b/include/xo/object2/DList.hpp @@ -0,0 +1,26 @@ +/** @file DList.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "xo/alloc2/RGCObject.hpp" +#include "xo/alloc2/IGCObject_Any.hpp" +#include "xo/facet/obj.hpp" + +namespace xo { + namespace scm { + + struct DList { + using AGCObject = xo::mm::AGCObject; + + DList(xo::obj h, + xo::obj r) : head_{h}, rest_{r} {} + + obj head_; + obj rest_; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DList.hpp */ diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp new file mode 100644 index 00000000..890fdd33 --- /dev/null +++ b/include/xo/object2/IGCObject_DList.hpp @@ -0,0 +1,36 @@ +/** @file IGCObject_DList.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include "DList.hpp" + +namespace xo { + namespace scm { + /* changes here coordinate with: + * IGCObject_XFer + */ + struct IGCObject_DList { + public: + using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; + using size_type = std::size_t; + + static size_type shallow_size(const DList & d) noexcept; + static DList * shallow_copy(const DList & d, obj mm) noexcept; + static size_type forward_children(DList & d, obj gc) noexcept; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DList.hpp */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 25b46ba1..f3c1382a 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -4,6 +4,7 @@ set(SELF_LIB xo_object2) set(SELF_SRCS IGCObject_DFloat.cpp IGCObject_DInteger.cpp + IGCObject_DList.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp new file mode 100644 index 00000000..104358e8 --- /dev/null +++ b/src/object2/IGCObject_DList.cpp @@ -0,0 +1,45 @@ +/** @file IGCObject_DList.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "IGCObject_DList.hpp" + +namespace xo { + using xo::mm::AAllocator; + using xo::facet::obj; + using std::size_t; + + namespace scm { + size_t + IGCObject_DList::shallow_size(const DList &) noexcept + { + return sizeof(DList); + } + + DList * + IGCObject_DList::shallow_copy(const DList & src, + obj mm) noexcept + { + DList * copy = (DList *)mm.alloc(sizeof(DList)); + + if (copy) + *copy = src; + + return copy; + } + + size_t + IGCObject_DList::forward_children(DList & src, + obj gc) noexcept + { + gc.forward_inplace(&src.head_); + gc.forward_inplace(&src.rest_); + + return shallow_size(src); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DList.cpp */ From b38f51c58abafc8657c0764c85bd2a12d5be7182 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 14 Dec 2025 16:58:58 -0500 Subject: [PATCH 003/176] xo-alloc2: header reorg + DX1Collector utest --- include/xo/object2/DList.hpp | 4 ++-- include/xo/object2/IGCObject_DFloat.hpp | 4 ++-- include/xo/object2/IGCObject_DInteger.hpp | 4 ++-- include/xo/object2/IGCObject_DList.hpp | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index f0be1cf4..06efd105 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -3,8 +3,8 @@ * @author Roland Conybeare, Dec 2025 **/ -#include "xo/alloc2/RGCObject.hpp" -#include "xo/alloc2/IGCObject_Any.hpp" +#include "xo/alloc2/gc/RGCObject.hpp" +#include "xo/alloc2/gc/IGCObject_Any.hpp" #include "xo/facet/obj.hpp" namespace xo { diff --git a/include/xo/object2/IGCObject_DFloat.hpp b/include/xo/object2/IGCObject_DFloat.hpp index 59f4c349..df4eed73 100644 --- a/include/xo/object2/IGCObject_DFloat.hpp +++ b/include/xo/object2/IGCObject_DFloat.hpp @@ -6,8 +6,8 @@ #pragma once #include "xo/alloc2/AAllocator.hpp" -#include "xo/alloc2/AGCObject.hpp" -#include "xo/alloc2/IGCObject_Xfer.hpp" +#include +#include #include "DFloat.hpp" namespace xo { diff --git a/include/xo/object2/IGCObject_DInteger.hpp b/include/xo/object2/IGCObject_DInteger.hpp index 0c36062d..20f8976e 100644 --- a/include/xo/object2/IGCObject_DInteger.hpp +++ b/include/xo/object2/IGCObject_DInteger.hpp @@ -6,8 +6,8 @@ #pragma once #include "xo/alloc2/AAllocator.hpp" -#include "xo/alloc2/AGCObject.hpp" -#include "xo/alloc2/IGCObject_Xfer.hpp" +#include +#include #include "DInteger.hpp" namespace xo { diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp index 890fdd33..9f0199d1 100644 --- a/include/xo/object2/IGCObject_DList.hpp +++ b/include/xo/object2/IGCObject_DList.hpp @@ -7,11 +7,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "DList.hpp" namespace xo { From 296c8e852d496e72f18d52808f5b60f6a6f0bc74 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 14 Dec 2025 17:16:05 -0500 Subject: [PATCH 004/176] xo-alloc2: header reorg redux --- include/xo/object2/IGCObject_DFloat.hpp | 2 +- include/xo/object2/IGCObject_DInteger.hpp | 2 +- include/xo/object2/IGCObject_DList.hpp | 11 ++++++----- src/object2/IGCObject_DFloat.cpp | 2 +- src/object2/IGCObject_DInteger.cpp | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/xo/object2/IGCObject_DFloat.hpp b/include/xo/object2/IGCObject_DFloat.hpp index df4eed73..a2da9223 100644 --- a/include/xo/object2/IGCObject_DFloat.hpp +++ b/include/xo/object2/IGCObject_DFloat.hpp @@ -5,7 +5,7 @@ #pragma once -#include "xo/alloc2/AAllocator.hpp" +#include #include #include #include "DFloat.hpp" diff --git a/include/xo/object2/IGCObject_DInteger.hpp b/include/xo/object2/IGCObject_DInteger.hpp index 20f8976e..12fa7457 100644 --- a/include/xo/object2/IGCObject_DInteger.hpp +++ b/include/xo/object2/IGCObject_DInteger.hpp @@ -5,7 +5,7 @@ #pragma once -#include "xo/alloc2/AAllocator.hpp" +#include "xo/alloc2/alloc/AAllocator.hpp" #include #include #include "DInteger.hpp" diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp index 9f0199d1..ef599dcf 100644 --- a/include/xo/object2/IGCObject_DList.hpp +++ b/include/xo/object2/IGCObject_DList.hpp @@ -5,11 +5,12 @@ #pragma once -#include -#include -#include -#include -#include +#include +#include +#include +//#include +//#include +//#include #include #include #include "DList.hpp" diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index 2c339b09..4c67631e 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -4,7 +4,7 @@ **/ #include "IGCObject_DFloat.hpp" -#include "AAllocator.hpp" +#include "xo/alloc2/alloc/AAllocator.hpp" #include "xo/facet/obj.hpp" #include diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 0fd2b2e6..0bd97f12 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -4,7 +4,7 @@ **/ #include "IGCObject_DInteger.hpp" -#include "AAllocator.hpp" +#include "xo/alloc2/alloc/AAllocator.hpp" #include "xo/facet/obj.hpp" #include From 7d2b57971aac02955f88c4f732481d20a993fafb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 14 Dec 2025 17:28:19 -0500 Subject: [PATCH 005/176] xo-alloc2: still more header org-streamlining --- include/xo/object2/DList.hpp | 4 ++-- include/xo/object2/IGCObject_DFloat.hpp | 4 ++-- include/xo/object2/IGCObject_DInteger.hpp | 4 ++-- include/xo/object2/IGCObject_DList.hpp | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 06efd105..a9d02955 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -3,8 +3,8 @@ * @author Roland Conybeare, Dec 2025 **/ -#include "xo/alloc2/gc/RGCObject.hpp" -#include "xo/alloc2/gc/IGCObject_Any.hpp" +#include "xo/alloc2/GCObject.hpp" +//#include "xo/alloc2/gcobject/RGCObject.hpp" #include "xo/facet/obj.hpp" namespace xo { diff --git a/include/xo/object2/IGCObject_DFloat.hpp b/include/xo/object2/IGCObject_DFloat.hpp index a2da9223..6a96dcf5 100644 --- a/include/xo/object2/IGCObject_DFloat.hpp +++ b/include/xo/object2/IGCObject_DFloat.hpp @@ -6,8 +6,8 @@ #pragma once #include -#include -#include +#include +#include #include "DFloat.hpp" namespace xo { diff --git a/include/xo/object2/IGCObject_DInteger.hpp b/include/xo/object2/IGCObject_DInteger.hpp index 12fa7457..765d2d96 100644 --- a/include/xo/object2/IGCObject_DInteger.hpp +++ b/include/xo/object2/IGCObject_DInteger.hpp @@ -6,8 +6,8 @@ #pragma once #include "xo/alloc2/alloc/AAllocator.hpp" -#include -#include +#include +#include #include "DInteger.hpp" namespace xo { diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp index ef599dcf..dc3ffa63 100644 --- a/include/xo/object2/IGCObject_DList.hpp +++ b/include/xo/object2/IGCObject_DList.hpp @@ -7,12 +7,12 @@ #include #include -#include +#include //#include //#include //#include -#include -#include +#include +#include #include "DList.hpp" namespace xo { From 419cb097dd6129b3f10692fddec89124fcafdaeb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 22 Dec 2025 22:24:10 -0500 Subject: [PATCH 006/176] xo-gc: refactor to extract DX1Collector etc from xo-alloc2/ --- include/xo/object2/DList.hpp | 2 +- include/xo/object2/IGCObject_DFloat.hpp | 4 ++-- include/xo/object2/IGCObject_DInteger.hpp | 4 ++-- include/xo/object2/IGCObject_DList.hpp | 9 +++------ src/object2/CMakeLists.txt | 2 +- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index a9d02955..9710defb 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -3,7 +3,7 @@ * @author Roland Conybeare, Dec 2025 **/ -#include "xo/alloc2/GCObject.hpp" +#include "xo/gc/GCObject.hpp" //#include "xo/alloc2/gcobject/RGCObject.hpp" #include "xo/facet/obj.hpp" diff --git a/include/xo/object2/IGCObject_DFloat.hpp b/include/xo/object2/IGCObject_DFloat.hpp index 6a96dcf5..b00873c8 100644 --- a/include/xo/object2/IGCObject_DFloat.hpp +++ b/include/xo/object2/IGCObject_DFloat.hpp @@ -6,8 +6,8 @@ #pragma once #include -#include -#include +#include +#include #include "DFloat.hpp" namespace xo { diff --git a/include/xo/object2/IGCObject_DInteger.hpp b/include/xo/object2/IGCObject_DInteger.hpp index 765d2d96..858856b9 100644 --- a/include/xo/object2/IGCObject_DInteger.hpp +++ b/include/xo/object2/IGCObject_DInteger.hpp @@ -6,8 +6,8 @@ #pragma once #include "xo/alloc2/alloc/AAllocator.hpp" -#include -#include +#include +#include #include "DInteger.hpp" namespace xo { diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp index dc3ffa63..b4f47c8e 100644 --- a/include/xo/object2/IGCObject_DList.hpp +++ b/include/xo/object2/IGCObject_DList.hpp @@ -7,12 +7,9 @@ #include #include -#include -//#include -//#include -//#include -#include -#include +#include +#include +#include #include "DList.hpp" namespace xo { diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index f3c1382a..644216aa 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -9,5 +9,5 @@ set(SELF_SRCS xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) # note: deps here must also appear in cmake/xo_alloc2Config.cmake.in -xo_dependency(${SELF_LIB} xo_alloc2) +xo_dependency(${SELF_LIB} xo_gc) #xo_dependency(${SELF_LIB} indentlog) From d14f7097632f30f526bc3dea1223c3a8c7421aaf Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 22 Dec 2025 23:31:12 -0500 Subject: [PATCH 007/176] xo-gc xo-alloc: refactor for file organization --- include/xo/object2/IGCObject_DFloat.hpp | 4 ++-- include/xo/object2/IGCObject_DInteger.hpp | 4 ++-- include/xo/object2/IGCObject_DList.hpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/xo/object2/IGCObject_DFloat.hpp b/include/xo/object2/IGCObject_DFloat.hpp index b00873c8..1916f7e2 100644 --- a/include/xo/object2/IGCObject_DFloat.hpp +++ b/include/xo/object2/IGCObject_DFloat.hpp @@ -6,8 +6,8 @@ #pragma once #include -#include -#include +#include +#include #include "DFloat.hpp" namespace xo { diff --git a/include/xo/object2/IGCObject_DInteger.hpp b/include/xo/object2/IGCObject_DInteger.hpp index 858856b9..69620b57 100644 --- a/include/xo/object2/IGCObject_DInteger.hpp +++ b/include/xo/object2/IGCObject_DInteger.hpp @@ -6,8 +6,8 @@ #pragma once #include "xo/alloc2/alloc/AAllocator.hpp" -#include -#include +#include +#include #include "DInteger.hpp" namespace xo { diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp index b4f47c8e..927feb74 100644 --- a/include/xo/object2/IGCObject_DList.hpp +++ b/include/xo/object2/IGCObject_DList.hpp @@ -8,8 +8,8 @@ #include #include #include -#include -#include +#include +#include #include "DList.hpp" namespace xo { From 1eea9118902bb18f6521043ae6438650783a0cfc Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 24 Dec 2025 19:39:11 -0500 Subject: [PATCH 008/176] xo-gc xo-object2 xo-alloc2: templates for FOMO [WIP] --- include/xo/object2/IGCObject_DFloat.hpp | 2 +- include/xo/object2/IGCObject_DInteger.hpp | 2 +- include/xo/object2/IGCObject_DList.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/xo/object2/IGCObject_DFloat.hpp b/include/xo/object2/IGCObject_DFloat.hpp index 1916f7e2..a6c5c17e 100644 --- a/include/xo/object2/IGCObject_DFloat.hpp +++ b/include/xo/object2/IGCObject_DFloat.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include "DFloat.hpp" diff --git a/include/xo/object2/IGCObject_DInteger.hpp b/include/xo/object2/IGCObject_DInteger.hpp index 69620b57..1f1f220c 100644 --- a/include/xo/object2/IGCObject_DInteger.hpp +++ b/include/xo/object2/IGCObject_DInteger.hpp @@ -6,7 +6,7 @@ #pragma once #include "xo/alloc2/alloc/AAllocator.hpp" -#include +#include #include #include "DInteger.hpp" diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp index 927feb74..8ba91a61 100644 --- a/include/xo/object2/IGCObject_DList.hpp +++ b/include/xo/object2/IGCObject_DList.hpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include "DList.hpp" From 73c1b54d5036cb87eaf615c78d34a733fe6b047b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 24 Dec 2025 19:40:48 -0500 Subject: [PATCH 009/176] xo-facet: facet template [WIP] --- idl/Sequence.json5 | 47 ++++++++++++++++++++++++++++++++ include/xo/object2/ASequence.hpp | 43 +++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 idl/Sequence.json5 create mode 100644 include/xo/object2/ASequence.hpp diff --git a/idl/Sequence.json5 b/idl/Sequence.json5 new file mode 100644 index 00000000..a0dc0011 --- /dev/null +++ b/idl/Sequence.json5 @@ -0,0 +1,47 @@ +{ + includes: [""], + namespace1: "xo", + namespace2: "scm", + facet: "Sequence", + brief: "an ordered collection of variants", + doc: [ + "Elements appear in some determinstic order.", + "Sequence is GC-aware --> elements must be GC-aware" + ], + methods: [ + // bool is_empty() const noexcept + { + name: "is_empty", + doc: ["true iff sequence is empty"], + return_type: "bool", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + + // bool is_finite() const noexcept + { + name: "is_finite", + doc: ["true iff sequence is finite"], + return_type: "bool", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + + // obj at(size_type index) const; + { + name: "at", + doc: ["return element @p index of this sequence"], + return_type: "obj", + args: [ + {type: "size_type", name: "index"}, + ], + const: true, + noexcept: false, + attributes: [], + }, + ], +} diff --git a/include/xo/object2/ASequence.hpp b/include/xo/object2/ASequence.hpp new file mode 100644 index 00000000..db12e6bd --- /dev/null +++ b/include/xo/object2/ASequence.hpp @@ -0,0 +1,43 @@ +/** @file ASequence.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet.py] + * arguments: + * --input [./idl/Sequence.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [./idl/Sequence.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include + +namespace xo { +namespace scm { + +/** +Elements appear in some determinstic order. +Sequence is GC-aware --> elements must be GC-aware +**/ +class ASequence { +public: + + /** true iff sequence is empty **/ + virtual bool is_empty() const noexcept = 0; + + + /** true iff sequence is finite **/ + virtual bool is_finite() const noexcept = 0; + + + /** return element @p index of this sequence **/ + virtual obj at(size_type index) const = 0; + +}; /*ASequence*/ + +} /*namespace scm*/ +} /*namespace xo*/ \ No newline at end of file From 9a3b3f68e299d9151fde148f3d014c4d492c369d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 24 Dec 2025 23:11:14 -0500 Subject: [PATCH 010/176] xo-facet: expand genfacet.py, generate IFoo_Any.hpp --- idl/Sequence.json5 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/idl/Sequence.json5 b/idl/Sequence.json5 index a0dc0011..7ec535cd 100644 --- a/idl/Sequence.json5 +++ b/idl/Sequence.json5 @@ -8,7 +8,21 @@ "Elements appear in some determinstic order.", "Sequence is GC-aware --> elements must be GC-aware" ], - methods: [ + types: [ + // using size_type = std::size_t + { + name: "size_type", + doc: ["type for length of a sequence"], + definition: "std::size_t", + }, + // using AGCObject = xo::mm::AGCObject + { + name: "AGCObject", + doc: ["facet for types with GC support"], + definition: "xo::mm::AGCObject", + } + ], + const_methods: [ // bool is_empty() const noexcept { name: "is_empty", @@ -44,4 +58,6 @@ attributes: [], }, ], + nonconst_methods: [ + ], } From 1b7859f61c65c1ae50cb4ef537e5075e672ab0b3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 25 Dec 2025 12:33:07 -0500 Subject: [PATCH 011/176] xo-facet: extend facet gen scope to IFoo_{Xfer,Any}, RFoo --- idl/Sequence.json5 | 1 + include/xo/object2/ASequence.hpp | 50 ++++++++++++++++++++++++++------ src/object2/CMakeLists.txt | 1 + 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/idl/Sequence.json5 b/idl/Sequence.json5 index 7ec535cd..433d3ca1 100644 --- a/idl/Sequence.json5 +++ b/idl/Sequence.json5 @@ -4,6 +4,7 @@ namespace2: "scm", facet: "Sequence", brief: "an ordered collection of variants", + using_doxygen: true, doc: [ "Elements appear in some determinstic order.", "Sequence is GC-aware --> elements must be GC-aware" diff --git a/include/xo/object2/ASequence.hpp b/include/xo/object2/ASequence.hpp index db12e6bd..4c4c806c 100644 --- a/include/xo/object2/ASequence.hpp +++ b/include/xo/object2/ASequence.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet.py] + * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet.py] * arguments: * --input [./idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -15,29 +15,61 @@ // includes (via {facet_includes}) #include +#include +#include +#include namespace xo { namespace scm { +using Copaque = const void *; +using Opaque = void *; + /** Elements appear in some determinstic order. Sequence is GC-aware --> elements must be GC-aware **/ class ASequence { public: + /** @defgroup scm-sequence-type-traits **/ + ///@{ + // types + /** type for length of a sequence **/ + using size_type = std::size_t; + /** facet for types with GC support **/ + using AGCObject = xo::mm::AGCObject; + ///@} + /** @defgroup scm-sequence-methods **/ + ///@{ + // const methods + /** RTTI: unique id# for actual runtime data representation **/ + virtual int32_t _typeseq() const noexcept = 0; /** true iff sequence is empty **/ - virtual bool is_empty() const noexcept = 0; - - + virtual bool is_empty(Copaque data) const noexcept = 0; /** true iff sequence is finite **/ - virtual bool is_finite() const noexcept = 0; - - + virtual bool is_finite(Copaque data) const noexcept = 0; /** return element @p index of this sequence **/ - virtual obj at(size_type index) const = 0; + virtual obj at(Copaque data, size_type index) const = 0; + // nonconst methods + ///@} }; /*ASequence*/ +/** Implementation ISequence_DRepr of ASequence for state DRepr + * should provide a specialization: + * + * template <> + * struct xo::facet::FacetImplementation { + * using Impltype = ISequence_DRepr; + * }; + * + * then ISequence_ImplType --> ISequence_DRepr + **/ +template +using ISequence_ImplType = xo::facet::FacetImplType; + } /*namespace scm*/ -} /*namespace xo*/ \ No newline at end of file +} /*namespace xo*/ + +/* */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 644216aa..d7df7235 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -5,6 +5,7 @@ set(SELF_SRCS IGCObject_DFloat.cpp IGCObject_DInteger.cpp IGCObject_DList.cpp + ISequence_Any.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) From 9a68fb6b494f8b2649bacc4bb6f2ef5855ce445f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 25 Dec 2025 13:02:56 -0500 Subject: [PATCH 012/176] xo-facet: support facet files in separate subdir --- include/xo/object2/ASequence.hpp | 75 -------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 include/xo/object2/ASequence.hpp diff --git a/include/xo/object2/ASequence.hpp b/include/xo/object2/ASequence.hpp deleted file mode 100644 index 4c4c806c..00000000 --- a/include/xo/object2/ASequence.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/** @file ASequence.hpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet.py] - * arguments: - * --input [./idl/Sequence.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [abstract_facet.hpp.j2] - * 3. idl for facet methods - * [./idl/Sequence.json5] - **/ - -#pragma once - -// includes (via {facet_includes}) -#include -#include -#include -#include - -namespace xo { -namespace scm { - -using Copaque = const void *; -using Opaque = void *; - -/** -Elements appear in some determinstic order. -Sequence is GC-aware --> elements must be GC-aware -**/ -class ASequence { -public: - /** @defgroup scm-sequence-type-traits **/ - ///@{ - // types - /** type for length of a sequence **/ - using size_type = std::size_t; - /** facet for types with GC support **/ - using AGCObject = xo::mm::AGCObject; - ///@} - - /** @defgroup scm-sequence-methods **/ - ///@{ - // const methods - /** RTTI: unique id# for actual runtime data representation **/ - virtual int32_t _typeseq() const noexcept = 0; - /** true iff sequence is empty **/ - virtual bool is_empty(Copaque data) const noexcept = 0; - /** true iff sequence is finite **/ - virtual bool is_finite(Copaque data) const noexcept = 0; - /** return element @p index of this sequence **/ - virtual obj at(Copaque data, size_type index) const = 0; - - // nonconst methods - ///@} -}; /*ASequence*/ - -/** Implementation ISequence_DRepr of ASequence for state DRepr - * should provide a specialization: - * - * template <> - * struct xo::facet::FacetImplementation { - * using Impltype = ISequence_DRepr; - * }; - * - * then ISequence_ImplType --> ISequence_DRepr - **/ -template -using ISequence_ImplType = xo::facet::FacetImplType; - -} /*namespace scm*/ -} /*namespace xo*/ - -/* */ \ No newline at end of file From 04509c4bd718466254c09ed136dce3fe5c346fc5 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 26 Dec 2025 02:09:25 -0500 Subject: [PATCH 013/176] xo-facet xo-object2 xo-cmake: facet tidy + build integration --- CMakeLists.txt | 11 +++ include/xo/object2/Sequence.hpp | 21 +++++ include/xo/object2/sequence/ASequence.hpp | 75 ++++++++++++++++ include/xo/object2/sequence/ISequence_Any.hpp | 87 +++++++++++++++++++ .../xo/object2/sequence/ISequence_Xfer.hpp | 85 ++++++++++++++++++ include/xo/object2/sequence/RSequence.hpp | 85 ++++++++++++++++++ src/object2/ISequence_Any.cpp | 38 ++++++++ 7 files changed, 402 insertions(+) create mode 100644 include/xo/object2/Sequence.hpp create mode 100644 include/xo/object2/sequence/ASequence.hpp create mode 100644 include/xo/object2/sequence/ISequence_Any.hpp create mode 100644 include/xo/object2/sequence/ISequence_Xfer.hpp create mode 100644 include/xo/object2/sequence/RSequence.hpp create mode 100644 src/object2/ISequence_Any.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d3a714e..7fcc9808 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,17 @@ add_definitions(${PROJECT_CXX_FLAGS}) # ---------------------------------------------------------------- +xo_add_genfacet( + TARGET xo-object2-facet-sequence + FACET Sequence + INPUT idl/Sequence.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR sequence + OUTPUT_CPP_DIR src/object2 +) + +# ---------------------------------------------------------------- + # must complete definition of expression lib before configuring examples add_subdirectory(src/object2) #add_subdirectory(utest) diff --git a/include/xo/object2/Sequence.hpp b/include/xo/object2/Sequence.hpp new file mode 100644 index 00000000..22f67397 --- /dev/null +++ b/include/xo/object2/Sequence.hpp @@ -0,0 +1,21 @@ +/** @file Sequence.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * arguments: + * --input [./idl/Sequence.json5] + * 2. jinja2 template for facet .hpp file: + * [facet.hpp.j2] + * 3. idl for facet methods + * [./idl/Sequence.json5] + **/ + +#pragma once + +#include "sequence/ASequence.hpp" +#include "sequence/ISequence_Any.hpp" +#include "sequence/ISequence_Xfer.hpp" +#include "sequence/RSequence.hpp" + +/* end Sequence.hpp */ \ No newline at end of file diff --git a/include/xo/object2/sequence/ASequence.hpp b/include/xo/object2/sequence/ASequence.hpp new file mode 100644 index 00000000..332e7cff --- /dev/null +++ b/include/xo/object2/sequence/ASequence.hpp @@ -0,0 +1,75 @@ +/** @file ASequence.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * arguments: + * --input [./idl/Sequence.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [./idl/Sequence.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include +#include +#include +#include + +namespace xo { +namespace scm { + +using Copaque = const void *; +using Opaque = void *; + +/** +Elements appear in some determinstic order. +Sequence is GC-aware --> elements must be GC-aware +**/ +class ASequence { +public: + /** @defgroup scm-sequence-type-traits **/ + ///@{ + // types + /** type for length of a sequence **/ + using size_type = std::size_t; + /** facet for types with GC support **/ + using AGCObject = xo::mm::AGCObject; + ///@} + + /** @defgroup scm-sequence-methods **/ + ///@{ + // const methods + /** RTTI: unique id# for actual runtime data representation **/ + virtual int32_t _typeseq() const noexcept = 0; + /** true iff sequence is empty **/ + virtual bool is_empty(Copaque data) const noexcept = 0; + /** true iff sequence is finite **/ + virtual bool is_finite(Copaque data) const noexcept = 0; + /** return element @p index of this sequence **/ + virtual obj at(Copaque data, size_type index) const = 0; + + // nonconst methods + ///@} +}; /*ASequence*/ + +/** Implementation ISequence_DRepr of ASequence for state DRepr + * should provide a specialization: + * + * template <> + * struct xo::facet::FacetImplementation { + * using Impltype = ISequence_DRepr; + * }; + * + * then ISequence_ImplType --> ISequence_DRepr + **/ +template +using ISequence_ImplType = xo::facet::FacetImplType; + +} /*namespace scm*/ +} /*namespace xo*/ + +/* */ \ No newline at end of file diff --git a/include/xo/object2/sequence/ISequence_Any.hpp b/include/xo/object2/sequence/ISequence_Any.hpp new file mode 100644 index 00000000..ebb172d5 --- /dev/null +++ b/include/xo/object2/sequence/ISequence_Any.hpp @@ -0,0 +1,87 @@ +/** @file ISequence_Any.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * arguments: + * --input [./idl/Sequence.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [./idl/Sequence.json5] + **/ + +#pragma once + +#include "ASequence.hpp" +#include + +namespace xo { namespace scm { class ISequence_Any; } } + +namespace xo { +namespace facet { + +template <> +struct FacetImplementation +{ + using ImplType = xo::scm::ISequence_Any; +}; + +} +} + +namespace xo { +namespace scm { + + /** @class ISequence_Any + * @brief ASequence implementation for empty variant instance + **/ + class ISequence_Any : public ASequence { + public: + /** @defgroup scm-sequence-any-type-traits **/ + ///@{ + + using size_type = ASequence::size_type; + using AGCObject = ASequence::AGCObject; + + ///@} + /** @defgroup scm-sequence-any-methods **/ + ///@{ + + const ASequence * iface() const { return std::launder(this); } + + // from ASequence + + // const methods + int32_t _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] bool is_empty(Copaque) const noexcept override { _fatal(); } + [[noreturn]] bool is_finite(Copaque) const noexcept override { _fatal(); } + [[noreturn]] obj at(Copaque, size_type) const override { _fatal(); } + + // nonconst methods + + ///@} + + private: + /** @defgraoup scm-sequence-any-private-methods **/ + ///@{ + + [[noreturn]] static void _fatal(); + + ///@} + + public: + /** @defgraoup scm-sequence-any-member-vars **/ + ///@{ + + static int32_t s_typeseq; + static bool _valid; + + ///@} + }; + +} /*namespace scm */ +} /*namespace xo */ + +/* ISequence_Any.hpp */ \ No newline at end of file diff --git a/include/xo/object2/sequence/ISequence_Xfer.hpp b/include/xo/object2/sequence/ISequence_Xfer.hpp new file mode 100644 index 00000000..18a5a616 --- /dev/null +++ b/include/xo/object2/sequence/ISequence_Xfer.hpp @@ -0,0 +1,85 @@ +/** @file ISequence_Xfer.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * arguments: + * --input [./idl/Sequence.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [./idl/Sequence.json5] + **/ + +#pragma once + +#include "ASequence.hpp" + +namespace xo { +namespace scm { + /** @class ISequence_Xfer + **/ + template + class ISequence_Xfer : public ASequence { + public: + /** @defgroup scm-sequence-xfer-type-traits **/ + ///@{ + using Impl = ISequence_DRepr; + using size_type = ASequence::size_type; + using AGCObject = ASequence::AGCObject; + ///@} + + /** @defgroup scm-sequence-xfer-methods **/ + ///@{ + + static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; } + static DRepr & _dcast(Opaque d) { return *(DRepr *)d; } + + // from ASequence + + // const methods + int32_t _typeseq() const noexcept override { return s_typeseq; } + bool is_empty(Copaque data) const noexcept override { + return I::is_empty(_dcast(data)); + } + bool is_finite(Copaque data) const noexcept override { + return I::is_finite(_dcast(data)); + } + obj at(Copaque data, size_type index) const override { + return I::at(_dcast(data), index); + } + + // non-const methods + + ///@} + + private: + using I = Impl; + + public: + /** @defgraoup scm-sequence-xfer-member-vars **/ + ///@{ + + /** typeseq for template parameter DRepr **/ + static int32_t s_typeseq; + /** true iff satisfies facet implementation **/ + static bool _valid; + + ///@} + }; + + template + int32_t + ISequence_Xfer::s_typeseq + = xo::facet::typeseq::id(); + + template + bool + ISequence_Xfer::_valid + = xo::facet::valid_facet_implementation(); + +} /*namespace scm */ +} /*namespace xo*/ + +/* end ISequence_Xfer.hpp */ \ No newline at end of file diff --git a/include/xo/object2/sequence/RSequence.hpp b/include/xo/object2/sequence/RSequence.hpp new file mode 100644 index 00000000..a63ca8a0 --- /dev/null +++ b/include/xo/object2/sequence/RSequence.hpp @@ -0,0 +1,85 @@ +/** @file RSequence.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * arguments: + * --input [./idl/Sequence.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [./idl/Sequence.json5] + **/ + +#pragma once + +#include "ASequence.hpp" + +namespace xo { +namespace scm { + +/** @class RSequence + **/ +template +class RSequence : public Object { +private: + using O = Object; + +public: + /** @defgroup scm-sequence-router-type-traits **/ + ///@{ + using ObjectType = Object; + using DataPtr = Object::DataPtr; + using size_type = ASequence::size_type; + using AGCObject = ASequence::AGCObject; + ///@} + + /** @defgroup scm-sequence-router-ctors **/ + ///@{ + RSequence() {} + RSequence(Object::DataPtr data) : Object{std::move(data)} {} + + ///@} + /** @defgroup scm-sequence-router-methods **/ + ///@{ + + // const methods + int32_t _typeseq() const noexcept { return O::iface()->_typeseq(); } + bool is_empty() const noexcept override { + return O::iface()->is_empty(O::data()); + } + bool is_finite() const noexcept override { + return O::iface()->is_finite(O::data()); + } + obj at(size_type index) const override { + return O::iface()->at(O::data(), index); + } + + // non-const methods + // << do something for non-const methods >> + // + + ///@} + /** @defgroup scm-sequence-member-vars **/ + ///@{ + + static bool _valid; + + ///@} +}; + +template +bool +RSequence::_valid = xo::facet::valid_object_router(); + +} /*namespace scm*/ +} /*namespace xo*/ + +namespace xo { namespace facet { + template + struct RoutingFor { + using RoutingType = xo::scm::RSequence; + }; +} } + +/* end RSequence.hpp */ \ No newline at end of file diff --git a/src/object2/ISequence_Any.cpp b/src/object2/ISequence_Any.cpp new file mode 100644 index 00000000..9eabc9c4 --- /dev/null +++ b/src/object2/ISequence_Any.cpp @@ -0,0 +1,38 @@ +/** @file ISequence_Any.cpp + * + **/ + +#include "sequence/ISequence_Any.hpp" +#include + +namespace xo { +namespace scm { + +using xo::facet::DVariantPlaceholder; +using xo::facet::typeseq; +using xo::facet::valid_facet_implementation; + +void +ISequence_Any::_fatal() +{ + /* control here on uninitialized IAllocator_Any. + * Initialized instance will have specific implementation type + */ + std::cerr << "fatal" + << ": attempt to call uninitialized" + << " ISequence_Any method" + << std::endl; + std::terminate(); +} + +int32_t +ISequence_Any::s_typeseq = typeseq::id(); + +bool +ISequence_Any::_valid + = valid_facet_implementation(); + +} /*namespace scm*/ +} /*namespace xo*/ + +/* end ISequence_Any.cpp */ From 0d3470c5413a8fd45e796156c5747a65094a7563 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 29 Dec 2025 14:32:52 -0500 Subject: [PATCH 014/176] xo-gc xo-object2 xo-facet: builds w/ ISequence,Dlist --- CMakeLists.txt | 10 ++++ idl/ISequence_DList.json5 | 12 +++++ idl/Sequence.json5 | 2 + include/xo/object2/DList.hpp | 14 +++++- include/xo/object2/IGCObject_DFloat.hpp | 1 + include/xo/object2/IGCObject_DInteger.hpp | 1 + include/xo/object2/IGCObject_DList.hpp | 13 +++++ include/xo/object2/ISequence_DList.hpp | 61 +++++++++++++++++++++++ src/object2/CMakeLists.txt | 3 ++ src/object2/DList.cpp | 54 ++++++++++++++++++++ src/object2/IGCObject_DList.cpp | 9 +++- src/object2/ISequence_DList.cpp | 40 +++++++++++++++ 12 files changed, 216 insertions(+), 4 deletions(-) create mode 100644 idl/ISequence_DList.json5 create mode 100644 include/xo/object2/ISequence_DList.hpp create mode 100644 src/object2/DList.cpp create mode 100644 src/object2/ISequence_DList.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fcc9808..4dabb209 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,16 @@ xo_add_genfacet( OUTPUT_CPP_DIR src/object2 ) +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-sequence-list + FACET Sequence + REPR List + INPUT idl/ISequence_DList.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR sequence + OUTPUT_CPP_DIR src/object2 +) + # ---------------------------------------------------------------- # must complete definition of expression lib before configuring examples diff --git a/idl/ISequence_DList.json5 b/idl/ISequence_DList.json5 new file mode 100644 index 00000000..30c0b262 --- /dev/null +++ b/idl/ISequence_DList.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Sequence.json5", + brief: "provide ASequence interface for DList state", + using_doxygen: true, + repr: "DList", + doc: [ "doc for something or other" + ], +} \ No newline at end of file diff --git a/idl/Sequence.json5 b/idl/Sequence.json5 index 433d3ca1..2ee1a204 100644 --- a/idl/Sequence.json5 +++ b/idl/Sequence.json5 @@ -1,8 +1,10 @@ { + mode: "facet", includes: [""], namespace1: "xo", namespace2: "scm", facet: "Sequence", + detail_subdir: "sequence", brief: "an ordered collection of variants", using_doxygen: true, doc: [ diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 9710defb..79cc84f7 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -11,13 +11,23 @@ namespace xo { namespace scm { struct DList { + using size_type = std::size_t; using AGCObject = xo::mm::AGCObject; DList(xo::obj h, - xo::obj r) : head_{h}, rest_{r} {} + DList * r) : head_{h}, rest_{r} {} + + /** DList length is at least 1 **/ + bool is_empty() const noexcept { return false; }; + /** DList models a finite sequence **/ + bool is_finite() const noexcept { return true; }; + /** return number of elements in this DList **/ + size_type size() const noexcept; + /** return element at 0-based index @p ix **/ + obj at(size_type ix) const; obj head_; - obj rest_; + DList * rest_ = nullptr; }; } /*namespace scm*/ diff --git a/include/xo/object2/IGCObject_DFloat.hpp b/include/xo/object2/IGCObject_DFloat.hpp index a6c5c17e..3ccf40d8 100644 --- a/include/xo/object2/IGCObject_DFloat.hpp +++ b/include/xo/object2/IGCObject_DFloat.hpp @@ -5,6 +5,7 @@ #pragma once +#include #include #include #include diff --git a/include/xo/object2/IGCObject_DInteger.hpp b/include/xo/object2/IGCObject_DInteger.hpp index 1f1f220c..c53a79f5 100644 --- a/include/xo/object2/IGCObject_DInteger.hpp +++ b/include/xo/object2/IGCObject_DInteger.hpp @@ -5,6 +5,7 @@ #pragma once +#include #include "xo/alloc2/alloc/AAllocator.hpp" #include #include diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp index 8ba91a61..c469d17b 100644 --- a/include/xo/object2/IGCObject_DList.hpp +++ b/include/xo/object2/IGCObject_DList.hpp @@ -13,6 +13,19 @@ #include "DList.hpp" namespace xo { + namespace scm { struct IGCObject_DList; } + + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } + namespace scm { /* changes here coordinate with: * IGCObject_XFer diff --git a/include/xo/object2/ISequence_DList.hpp b/include/xo/object2/ISequence_DList.hpp new file mode 100644 index 00000000..5f67a3ff --- /dev/null +++ b/include/xo/object2/ISequence_DList.hpp @@ -0,0 +1,61 @@ +/** @file ISequence_DList.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/ISequence_DList.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/ISequence_DList.json5] + **/ + +#pragma once + +#include "Sequence.hpp" +#include "sequence/ISequence_Xfer.hpp" +#include "DList.hpp" + +namespace xo { namespace scm { class ISequence_DList; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::ISequence_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class ISequence_DList + **/ + class ISequence_DList { + public: + /** @defgroup scm-sequence-dlist-type-traits **/ + ///@{ + using size_type = ASequence::size_type; + using AGCObject = ASequence::AGCObject; + ///@} + /** @defgroup scm-sequence-dlist-methods **/ + ///@{ + /** true iff sequence is empty **/ + static bool is_empty(const DList & self) noexcept; + /** true iff sequence is finite **/ + static bool is_finite(const DList & self) noexcept; + /** return element @p index of this sequence **/ + static obj at(const DList & self, size_type index); + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index d7df7235..dd76874e 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -6,9 +6,12 @@ set(SELF_SRCS IGCObject_DInteger.cpp IGCObject_DList.cpp ISequence_Any.cpp + ISequence_DList.cpp + DList.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) # note: deps here must also appear in cmake/xo_alloc2Config.cmake.in xo_dependency(${SELF_LIB} xo_gc) #xo_dependency(${SELF_LIB} indentlog) +#add_dependencies(${SELF_LIB} xo-object2-facetimpl-sequence-list) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp new file mode 100644 index 00000000..2377d182 --- /dev/null +++ b/src/object2/DList.cpp @@ -0,0 +1,54 @@ +/** @file DList.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "DList.hpp" +#include + +namespace xo { + namespace scm { + auto + DList::size() const noexcept -> size_type + { + const DList * l = this; + + size_type z = 0; + + while (l) { + ++z; + l = l->rest_; + } + + return z; + } + + auto + DList::at(size_type index) const -> obj + { + size_type ix = index; + const DList * l = this; + + while (l->rest_ && (ix > 0)) { + --ix; + l = l->rest_; + } + + if (ix > 0) { + assert(l == nullptr); + + throw std::runtime_error + (tostr("DList::at: out-of-range index where [0..z) expected", + xtag("index", index), + xtag("z", this->size()))); + } + + assert(l); + + return l->head_; + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DList.cpp */ diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 104358e8..d4355a29 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -6,7 +6,9 @@ #include "IGCObject_DList.hpp" namespace xo { + using xo::mm::AGCObject; using xo::mm::AAllocator; + using xo::facet::with_facet; using xo::facet::obj; using std::size_t; @@ -33,8 +35,11 @@ namespace xo { IGCObject_DList::forward_children(DList & src, obj gc) noexcept { - gc.forward_inplace(&src.head_); - gc.forward_inplace(&src.rest_); + gc.forward_inplace(src.head_.iface(), (void **)&(src.head_.data_)); + + //auto rest = with_facet::mkobj(src.rest_); + xo::facet::FacetImplementation::ImplType iface; + gc.forward_inplace(&iface, (void **)(&src.rest_)); return shallow_size(src); } diff --git a/src/object2/ISequence_DList.cpp b/src/object2/ISequence_DList.cpp new file mode 100644 index 00000000..22d5bde5 --- /dev/null +++ b/src/object2/ISequence_DList.cpp @@ -0,0 +1,40 @@ +/** @file ISequence_DList.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/ISequence_DList.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/ISequence_DList.json5] +**/ + +#include "ISequence_DList.hpp" + +namespace xo { + namespace scm { + auto + ISequence_DList::is_empty(const DList & self) noexcept -> bool + { + return self.is_empty(); + } + + auto + ISequence_DList::is_finite(const DList & self) noexcept -> bool + { + return self.is_finite(); + } + + auto + ISequence_DList::at(const DList & self, size_type index) -> obj + { + return self.at(index); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end ISequence_DList.cpp */ \ No newline at end of file From 4af2cd04015a3668a7df072438a0993c7ad4c0e9 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 2 Jan 2026 09:52:16 -0500 Subject: [PATCH 015/176] xo-facet: typeseq strongly typed --- include/xo/object2/sequence/ASequence.hpp | 6 ++++-- include/xo/object2/sequence/ISequence_Xfer.hpp | 8 ++++---- src/object2/ISequence_Any.cpp | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/xo/object2/sequence/ASequence.hpp b/include/xo/object2/sequence/ASequence.hpp index 332e7cff..301d5be8 100644 --- a/include/xo/object2/sequence/ASequence.hpp +++ b/include/xo/object2/sequence/ASequence.hpp @@ -34,6 +34,8 @@ public: /** @defgroup scm-sequence-type-traits **/ ///@{ // types + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; /** type for length of a sequence **/ using size_type = std::size_t; /** facet for types with GC support **/ @@ -44,7 +46,7 @@ public: ///@{ // const methods /** RTTI: unique id# for actual runtime data representation **/ - virtual int32_t _typeseq() const noexcept = 0; + virtual typeseq _typeseq() const noexcept = 0; /** true iff sequence is empty **/ virtual bool is_empty(Copaque data) const noexcept = 0; /** true iff sequence is finite **/ @@ -72,4 +74,4 @@ using ISequence_ImplType = xo::facet::FacetImplType; } /*namespace scm*/ } /*namespace xo*/ -/* */ \ No newline at end of file +/* */ diff --git a/include/xo/object2/sequence/ISequence_Xfer.hpp b/include/xo/object2/sequence/ISequence_Xfer.hpp index 18a5a616..4a679b6c 100644 --- a/include/xo/object2/sequence/ISequence_Xfer.hpp +++ b/include/xo/object2/sequence/ISequence_Xfer.hpp @@ -38,7 +38,7 @@ namespace scm { // from ASequence // const methods - int32_t _typeseq() const noexcept override { return s_typeseq; } + typeseq _typeseq() const noexcept override { return s_typeseq; } bool is_empty(Copaque data) const noexcept override { return I::is_empty(_dcast(data)); } @@ -61,7 +61,7 @@ namespace scm { ///@{ /** typeseq for template parameter DRepr **/ - static int32_t s_typeseq; + static typeseq s_typeseq; /** true iff satisfies facet implementation **/ static bool _valid; @@ -69,7 +69,7 @@ namespace scm { }; template - int32_t + xo::facet::typeseq ISequence_Xfer::s_typeseq = xo::facet::typeseq::id(); @@ -82,4 +82,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo*/ -/* end ISequence_Xfer.hpp */ \ No newline at end of file +/* end ISequence_Xfer.hpp */ diff --git a/src/object2/ISequence_Any.cpp b/src/object2/ISequence_Any.cpp index 9eabc9c4..a7781e97 100644 --- a/src/object2/ISequence_Any.cpp +++ b/src/object2/ISequence_Any.cpp @@ -25,7 +25,7 @@ ISequence_Any::_fatal() std::terminate(); } -int32_t +typeseq ISequence_Any::s_typeseq = typeseq::id(); bool From 99108b8dbb7eb06b32050a8fdf2761487b6a7c34 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 2 Jan 2026 09:53:23 -0500 Subject: [PATCH 016/176] xo-object2: type registration + gc fixes --- CMakeLists.txt | 2 +- include/xo/object2/DList.hpp | 16 ++- include/xo/object2/IGCObject_DFloat.hpp | 18 ++- include/xo/object2/IGCObject_DInteger.hpp | 16 ++- include/xo/object2/IGCObject_DList.hpp | 3 +- include/xo/object2/object2_register_types.hpp | 19 +++ include/xo/object2/sequence/ISequence_Any.hpp | 8 +- src/object2/CMakeLists.txt | 1 + src/object2/DList.cpp | 37 +++++- src/object2/IGCObject_DFloat.cpp | 5 +- src/object2/IGCObject_DInteger.cpp | 5 +- src/object2/IGCObject_DList.cpp | 3 +- src/object2/object2_register_types.cpp | 34 +++++ utest/CMakeLists.txt | 12 ++ utest/X1Collector.test.cpp | 117 ++++++++++++++++++ utest/object2_utest_main.cpp | 6 + 16 files changed, 285 insertions(+), 17 deletions(-) create mode 100644 include/xo/object2/object2_register_types.hpp create mode 100644 src/object2/object2_register_types.cpp create mode 100644 utest/CMakeLists.txt create mode 100644 utest/X1Collector.test.cpp create mode 100644 utest/object2_utest_main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dabb209..bb540b37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ xo_add_genfacetimpl( # must complete definition of expression lib before configuring examples add_subdirectory(src/object2) -#add_subdirectory(utest) +add_subdirectory(utest) #xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) # ---------------------------------------------------------------- diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 79cc84f7..3f6a5639 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -13,12 +13,24 @@ namespace xo { struct DList { using size_type = std::size_t; using AGCObject = xo::mm::AGCObject; + using AAllocator = xo::mm::AAllocator; DList(xo::obj h, DList * r) : head_{h}, rest_{r} {} + /** sentinel for null list **/ + static DList * null(); + + /** list with one element @p h1, allocated from @p mm **/ + static DList * list(obj mm, + obj h1); + /** list with two elements @p h1, @p h2, allocated from @p mm **/ + static DList * list(obj mm, + obj h1, + obj h2); + /** DList length is at least 1 **/ - bool is_empty() const noexcept { return false; }; + bool is_empty() const noexcept; /** DList models a finite sequence **/ bool is_finite() const noexcept { return true; }; /** return number of elements in this DList **/ @@ -26,7 +38,9 @@ namespace xo { /** return element at 0-based index @p ix **/ obj at(size_type ix) const; + /** first member of list **/ obj head_; + /** remainder of list **/ DList * rest_ = nullptr; }; diff --git a/include/xo/object2/IGCObject_DFloat.hpp b/include/xo/object2/IGCObject_DFloat.hpp index 3ccf40d8..58b931bc 100644 --- a/include/xo/object2/IGCObject_DFloat.hpp +++ b/include/xo/object2/IGCObject_DFloat.hpp @@ -5,13 +5,26 @@ #pragma once +#include #include -#include #include #include #include "DFloat.hpp" namespace xo { + namespace scm { struct IGCObject_DFloat; } + + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } + namespace scm { /* changes here coordinate with: * IGCObject_Xfer @@ -19,11 +32,12 @@ namespace xo { struct IGCObject_DFloat { public: using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; using size_type = std::size_t; static size_type shallow_size(const DFloat & d) noexcept; static DFloat * shallow_copy(const DFloat & d, obj mm) noexcept; - static size_type forward_children(DFloat & d) noexcept; + static size_type forward_children(DFloat & d, obj gc) noexcept; }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/object2/IGCObject_DInteger.hpp b/include/xo/object2/IGCObject_DInteger.hpp index c53a79f5..b3061980 100644 --- a/include/xo/object2/IGCObject_DInteger.hpp +++ b/include/xo/object2/IGCObject_DInteger.hpp @@ -12,6 +12,19 @@ #include "DInteger.hpp" namespace xo { + namespace scm { struct IGCObject_DInteger; } + + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } + namespace scm { /* changes here coordinate with: * IGCObject_Xfer @@ -19,11 +32,12 @@ namespace xo { struct IGCObject_DInteger { public: using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; using size_type = std::size_t; static size_type shallow_size(const DInteger & d) noexcept; static DInteger * shallow_copy(const DInteger & d, obj mm) noexcept; - static size_type forward_children(DInteger & d) noexcept; + static size_type forward_children(DInteger & d, obj gc) noexcept; }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp index c469d17b..3d61a71d 100644 --- a/include/xo/object2/IGCObject_DList.hpp +++ b/include/xo/object2/IGCObject_DList.hpp @@ -5,8 +5,7 @@ #pragma once -#include -#include +#include #include #include #include diff --git a/include/xo/object2/object2_register_types.hpp b/include/xo/object2/object2_register_types.hpp new file mode 100644 index 00000000..9b2656a1 --- /dev/null +++ b/include/xo/object2/object2_register_types.hpp @@ -0,0 +1,19 @@ +/** @file object2_register_types.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + /** Register all object2/ gc-aware types with @p gc. + * Return true iff all types register successfully. + **/ + bool object2_register_types(obj gc); + } +} + +/* end object2_register_types.hpp */ diff --git a/include/xo/object2/sequence/ISequence_Any.hpp b/include/xo/object2/sequence/ISequence_Any.hpp index ebb172d5..06838b36 100644 --- a/include/xo/object2/sequence/ISequence_Any.hpp +++ b/include/xo/object2/sequence/ISequence_Any.hpp @@ -14,6 +14,7 @@ #pragma once #include "ASequence.hpp" +#include #include namespace xo { namespace scm { class ISequence_Any; } } @@ -42,6 +43,7 @@ namespace scm { /** @defgroup scm-sequence-any-type-traits **/ ///@{ + using typeseq = xo::facet::typeseq; using size_type = ASequence::size_type; using AGCObject = ASequence::AGCObject; @@ -54,7 +56,7 @@ namespace scm { // from ASequence // const methods - int32_t _typeseq() const noexcept override { return s_typeseq; } + typeseq _typeseq() const noexcept override { return s_typeseq; } [[noreturn]] bool is_empty(Copaque) const noexcept override { _fatal(); } [[noreturn]] bool is_finite(Copaque) const noexcept override { _fatal(); } [[noreturn]] obj at(Copaque, size_type) const override { _fatal(); } @@ -75,7 +77,7 @@ namespace scm { /** @defgraoup scm-sequence-any-member-vars **/ ///@{ - static int32_t s_typeseq; + static typeseq s_typeseq; static bool _valid; ///@} @@ -84,4 +86,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo */ -/* ISequence_Any.hpp */ \ No newline at end of file +/* ISequence_Any.hpp */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index dd76874e..e2ffee22 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -8,6 +8,7 @@ set(SELF_SRCS ISequence_Any.cpp ISequence_DList.cpp DList.cpp + object2_register_types.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 2377d182..99469d1a 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -7,7 +7,42 @@ #include namespace xo { + using xo::mm::AGCObject; + namespace scm { + static DList s_null(obj(), nullptr); + + DList * + DList::null() + { + return &s_null; + } + + DList * + DList::list(obj mm, + obj h1) + { + void * mem = mm.alloc(sizeof(DList)); + + return new (mem) DList(h1, DList::null()); + } + + DList * + DList::list(obj mm, + obj h1, + obj h2) + { + void * mem = mm.alloc(sizeof(DList)); + + return new (mem) DList(h1, DList::list(mm, h2)); + } + + bool + DList::is_empty() const noexcept + { + return this != &s_null; + } + auto DList::size() const noexcept -> size_type { @@ -15,7 +50,7 @@ namespace xo { size_type z = 0; - while (l) { + while (l && l != &s_null) { ++z; l = l->rest_; } diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index 4c67631e..a56175f1 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -33,9 +33,10 @@ namespace xo { } size_t - IGCObject_DFloat::forward_children(DFloat &) noexcept + IGCObject_DFloat::forward_children(DFloat & src, + obj) noexcept { - return sizeof(DFloat); + return shallow_size(src); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 0bd97f12..706ab093 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -33,9 +33,10 @@ namespace xo { } size_t - IGCObject_DInteger::forward_children(DInteger &) noexcept + IGCObject_DInteger::forward_children(DInteger & src, + obj) noexcept { - return sizeof(DInteger); + return shallow_size(src); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index d4355a29..19188dfd 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -37,8 +37,7 @@ namespace xo { { gc.forward_inplace(src.head_.iface(), (void **)&(src.head_.data_)); - //auto rest = with_facet::mkobj(src.rest_); - xo::facet::FacetImplementation::ImplType iface; + auto iface = xo::facet::impl_for(); gc.forward_inplace(&iface, (void **)(&src.rest_)); return shallow_size(src); diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp new file mode 100644 index 00000000..e472401a --- /dev/null +++ b/src/object2/object2_register_types.cpp @@ -0,0 +1,34 @@ +/** @file object2_register_types.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "object2_register_types.hpp" +#include "IGCObject_DList.hpp" +#include "IGCObject_DFloat.hpp" +#include "IGCObject_DInteger.hpp" + +namespace xo { + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::IGCObject_Any; + using xo::facet::impl_for; + using xo::facet::typeseq; + + namespace scm { + + bool + object2_register_types(obj gc) + { + bool ok = true; + + ok &= gc.install_type(impl_for()); + + ok &= gc.install_type(impl_for()); + + return ok; + } + } +} /*namespace xo*/ + +/* end object2_register_types.cpp */ diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt new file mode 100644 index 00000000..258f56a1 --- /dev/null +++ b/utest/CMakeLists.txt @@ -0,0 +1,12 @@ +# built unittest xo-object2/utest + +set(UTEST_EXE utest.object2) +set(UTEST_SRCS + object2_utest_main.cpp + X1Collector.test.cpp +) + +xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) +xo_self_dependency(${UTEST_EXE} xo_object2) +#xo_dependency(${UTEST_EXE} randomgen) +xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp new file mode 100644 index 00000000..3857f0bf --- /dev/null +++ b/utest/X1Collector.test.cpp @@ -0,0 +1,117 @@ +/** @file X1Collector.test.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include +#include +#include + +namespace ut { + using xo::mm::DX1Collector; + using xo::mm::DArena; + using xo::mm::CollectorConfig; + using xo::mm::ArenaConfig; + using xo::mm::generation; + using xo::mm::role; + + namespace { + struct testcase_x1 { + testcase_x1(std::size_t nz, + std::size_t tz, + std::size_t n_gct, + std::size_t t_gct) + : nursery_z_{nz}, + tenured_z_{tz}, + incr_gc_threshold_{n_gct}, + full_gc_threshold_{t_gct} {} + + std::size_t nursery_z_; + std::size_t tenured_z_; + std::size_t incr_gc_threshold_; + std::size_t full_gc_threshold_; + }; + + std::vector + s_testcase_v = { + // n_gct: nursery gc threshold + // t_gct: tenured gc threshold + // + // nz tz n_gct t_gct + testcase_x1(4096, 8192, 1024, 1024) + }; + } + + TEST_CASE("x1", "[gc][x1]") + { + for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) { + try { + const testcase_x1 & tc = s_testcase_v[i_tc]; + + CollectorConfig cfg{ + .name_ = "x1_test", + .arena_config_ = ArenaConfig{ + .size_ = tc.tenured_z_, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{ + tc.incr_gc_threshold_, + tc.full_gc_threshold_}}, + }; + + DX1Collector gc(cfg); + + { + REQUIRE(gc.name() == "x1_test"); + + const DArena * otypes = gc.get_object_types(); + + REQUIRE(otypes != nullptr); + REQUIRE(otypes->reserved() >= cfg.object_types_z_); + REQUIRE(otypes->reserved() < cfg.object_types_z_ + otypes->page_z_); + + DArena * from_0 = gc.get_space(role::from_space(), generation{0}); + + REQUIRE(from_0 != nullptr); + REQUIRE(from_0->reserved() >= tc.tenured_z_); + REQUIRE(from_0->reserved() < tc.tenured_z_ + from_0->page_z_); + REQUIRE(from_0->reserved() % from_0->page_z_ == 0); + + DArena * from_1 = gc.get_space(role::from_space(), generation{1}); + + REQUIRE(from_1 != nullptr); + REQUIRE(from_1->reserved() == from_0->reserved()); + + DArena * to_0 = gc.get_space(role::to_space(), generation{0}); + + REQUIRE(to_0 != nullptr); + REQUIRE(to_0->reserved() == from_0->reserved()); + + DArena * to_1 = gc.get_space(role::to_space(), generation{1}); + + REQUIRE(to_1 != nullptr); + REQUIRE(to_1->reserved() == to_0->reserved()); + + DArena * from_2 = gc.get_space(role::from_space(), generation{2}); + + REQUIRE(from_2 == nullptr); + + DArena * to_2 = gc.get_space(role::to_space(), generation{2}); + + REQUIRE(to_2 == nullptr); + + REQUIRE(gc.reserved_total() + == otypes->reserved() + 4 * from_0->reserved()); + } + + /* attempt allocation */ + + } catch (std::exception & ex) { + std::cerr << "caught exception: " << ex.what() << std::endl; + REQUIRE(false); + } + } + } +} + +/* end X1Collector.test.cpp */ diff --git a/utest/object2_utest_main.cpp b/utest/object2_utest_main.cpp new file mode 100644 index 00000000..a3dcb813 --- /dev/null +++ b/utest/object2_utest_main.cpp @@ -0,0 +1,6 @@ +/* file object2_utest_main.cpp */ + +#define CATCH_CONFIG_MAIN +#include "catch2/catch.hpp" + +/* end object2_utest_main.cpp */ From c1b0504fc144a005d82eafc2c6ef0ed122c296e7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 2 Jan 2026 10:20:19 -0500 Subject: [PATCH 017/176] xo-alloc: explicit typeseq arg to alloc --- src/object2/DList.cpp | 5 +++-- src/object2/IGCObject_DFloat.cpp | 4 +++- src/object2/IGCObject_DInteger.cpp | 4 +++- src/object2/IGCObject_DList.cpp | 6 ++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 99469d1a..d95f0bd0 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -8,6 +8,7 @@ namespace xo { using xo::mm::AGCObject; + using xo::facet::typeseq; namespace scm { static DList s_null(obj(), nullptr); @@ -22,7 +23,7 @@ namespace xo { DList::list(obj mm, obj h1) { - void * mem = mm.alloc(sizeof(DList)); + void * mem = mm.alloc(typeseq::id(), sizeof(DList)); return new (mem) DList(h1, DList::null()); } @@ -32,7 +33,7 @@ namespace xo { obj h1, obj h2) { - void * mem = mm.alloc(sizeof(DList)); + void * mem = mm.alloc(typeseq::id(), sizeof(DList)); return new (mem) DList(h1, DList::list(mm, h2)); } diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index a56175f1..9d9a65de 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -11,6 +11,7 @@ namespace xo { using xo::mm::AAllocator; using xo::facet::obj; + using xo::facet::typeseq; using std::size_t; namespace scm { @@ -24,7 +25,8 @@ namespace xo { IGCObject_DFloat::shallow_copy(const DFloat & src, obj mm) noexcept { - DFloat * copy = (DFloat *)mm.alloc(sizeof(DFloat)); + DFloat * copy = (DFloat *)mm.alloc(typeseq::id(), + sizeof(DFloat)); if (copy) *copy = src; diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 706ab093..d6c80bb6 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -11,6 +11,7 @@ namespace xo { using xo::mm::AAllocator; using xo::facet::obj; + using xo::facet::typeseq; using std::size_t; namespace scm { @@ -24,7 +25,8 @@ namespace xo { IGCObject_DInteger::shallow_copy(const DInteger & src, obj mm) noexcept { - DInteger * copy = (DInteger *)mm.alloc(sizeof(DInteger)); + DInteger * copy = (DInteger *)mm.alloc(typeseq::id(), + sizeof(DInteger)); if (copy) *copy = src; diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 19188dfd..a30f2c6a 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -8,8 +8,9 @@ namespace xo { using xo::mm::AGCObject; using xo::mm::AAllocator; - using xo::facet::with_facet; + //using xo::facet::with_facet; using xo::facet::obj; + using xo::facet::typeseq; using std::size_t; namespace scm { @@ -23,7 +24,8 @@ namespace xo { IGCObject_DList::shallow_copy(const DList & src, obj mm) noexcept { - DList * copy = (DList *)mm.alloc(sizeof(DList)); + /* FIXME: need to supply object age here */ + DList * copy = (DList *)mm.alloc(typeseq::id(), sizeof(DList)); if (copy) *copy = src; From 39a16a3f15fd870dc151d0a323cb0907c901365a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 2 Jan 2026 18:55:53 -0500 Subject: [PATCH 018/176] xo-object2: utest: ++ allocation in collector utest --- include/xo/object2/DFloat.hpp | 23 ++++++++++++-- include/xo/object2/DList.hpp | 6 ++-- src/object2/CMakeLists.txt | 1 + src/object2/DFloat.cpp | 24 +++++++++++++++ utest/X1Collector.test.cpp | 56 +++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 src/object2/DFloat.cpp diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index 52a3ba43..821e31d0 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -5,10 +5,29 @@ #pragma once +#include + namespace xo { namespace scm { - using DFloat = double; - } /*nmaespace obj*/ + struct DFloat { + using AAllocator = xo::mm::AAllocator; + + explicit DFloat(double x) : value_{x} {} + + /** allocate boxed value @p x using memory from @p mm **/ + static DFloat * make(obj mm, + double x); + + double value() const noexcept { return value_; } + + operator double() const noexcept { return value_; } + + private: + + /** boxed floating-oint value **/ + double value_; + }; + } /*nmaespace scm*/ } /*namespace xo*/ /* end DFloat.hpp */ diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 3f6a5639..65ed0ad4 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -3,9 +3,11 @@ * @author Roland Conybeare, Dec 2025 **/ -#include "xo/gc/GCObject.hpp" +#pragma once + +#include //#include "xo/alloc2/gcobject/RGCObject.hpp" -#include "xo/facet/obj.hpp" +#include namespace xo { namespace scm { diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index e2ffee22..fc66c970 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -8,6 +8,7 @@ set(SELF_SRCS ISequence_Any.cpp ISequence_DList.cpp DList.cpp + DFloat.cpp object2_register_types.cpp ) diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp new file mode 100644 index 00000000..1ef8fa52 --- /dev/null +++ b/src/object2/DFloat.cpp @@ -0,0 +1,24 @@ +/** @file DFloat.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "DFloat.hpp" + +namespace xo { + using xo::facet::typeseq; + + namespace scm { + DFloat * + DFloat::make(obj mm, + double x) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DFloat)); + + return new (mem) DFloat(x); + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DFloat.cpp */ diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 3857f0bf..742e460c 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -3,17 +3,35 @@ * @author Roland Conybeare, Dec 2025 **/ +#include "DFloat.hpp" +#include "DList.hpp" + +#include "IGCObject_DFloat.hpp" +#include "IGCObject_DList.hpp" + #include #include +#include +#include +#include + #include namespace ut { + using xo::scm::DList; + using xo::scm::DFloat; + using xo::mm::AAllocator; + using xo::mm::AllocInfo; + using xo::mm::AGCObject; using xo::mm::DX1Collector; using xo::mm::DArena; using xo::mm::CollectorConfig; using xo::mm::ArenaConfig; using xo::mm::generation; using xo::mm::role; + using xo::mm::padding; + using xo::facet::with_facet; + using xo::facet::typeseq; namespace { struct testcase_x1 { @@ -61,6 +79,7 @@ namespace ut { DX1Collector gc(cfg); + /* verify initial collector state */ { REQUIRE(gc.name() == "x1_test"); @@ -105,6 +124,43 @@ namespace ut { } /* attempt allocation */ + auto gc_o = with_facet::mkobj(&gc); + + DFloat * x0 = DFloat::make(gc_o, 3.1415927); + auto x0_o = with_facet::mkobj(x0); + + DList * l0 = DList::list(gc_o, x0_o); + auto l0_o = with_facet::mkobj(l0); + + { + { + REQUIRE(x0_o.iface() != nullptr); + REQUIRE(x0_o.data() != nullptr); + REQUIRE(gc.contains(role::to_space(), x0_o.data())); + + /* check alloc info for newly-allocated object */ + AllocInfo info = gc.alloc_info((std::byte *)x0_o.data()); + + REQUIRE(info.age() == 0); + REQUIRE(info.tseq() == typeseq::id().seqno()); + REQUIRE(info.size() >= sizeof(DFloat)); + REQUIRE(info.size() < sizeof(DFloat) + padding::c_alloc_alignment); + } + + { + REQUIRE(l0_o.iface() != nullptr); + REQUIRE(l0_o.data() != nullptr); + REQUIRE(gc.contains(role::to_space(), l0_o.data())); + + AllocInfo info = gc.alloc_info((std::byte *)l0_o.data()); + + REQUIRE(info.age() == 0); + REQUIRE(info.tseq() == typeseq::id().seqno()); + REQUIRE(info.size() >= sizeof(DList)); + REQUIRE(info.size() < sizeof(DList) + padding::c_alloc_alignment); + + } + } } catch (std::exception & ex) { std::cerr << "caught exception: " << ex.what() << std::endl; From c35e7921c1a79ccf5c106207fc7d7009da570b5e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 2 Jan 2026 22:33:54 -0500 Subject: [PATCH 019/176] xo-gc: + Collector.is_type_installed() --- utest/X1Collector.test.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 742e460c..2afe158d 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -5,22 +5,29 @@ #include "DFloat.hpp" #include "DList.hpp" +#include "object2_register_types.hpp" #include "IGCObject_DFloat.hpp" #include "IGCObject_DList.hpp" #include #include + #include +#include + #include #include #include namespace ut { + using xo::scm::object2_register_types; using xo::scm::DList; using xo::scm::DFloat; using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AllocHeader; using xo::mm::AllocInfo; using xo::mm::AGCObject; using xo::mm::DX1Collector; @@ -79,6 +86,8 @@ namespace ut { DX1Collector gc(cfg); + DArena * to_0 = nullptr; + /* verify initial collector state */ { REQUIRE(gc.name() == "x1_test"); @@ -95,21 +104,25 @@ namespace ut { REQUIRE(from_0->reserved() >= tc.tenured_z_); REQUIRE(from_0->reserved() < tc.tenured_z_ + from_0->page_z_); REQUIRE(from_0->reserved() % from_0->page_z_ == 0); + REQUIRE(from_0->allocated() == 0); DArena * from_1 = gc.get_space(role::from_space(), generation{1}); REQUIRE(from_1 != nullptr); REQUIRE(from_1->reserved() == from_0->reserved()); + REQUIRE(from_1->allocated() == 0); - DArena * to_0 = gc.get_space(role::to_space(), generation{0}); + to_0 = gc.get_space(role::to_space(), generation{0}); REQUIRE(to_0 != nullptr); REQUIRE(to_0->reserved() == from_0->reserved()); + REQUIRE(to_0->allocated() == 0); DArena * to_1 = gc.get_space(role::to_space(), generation{1}); REQUIRE(to_1 != nullptr); REQUIRE(to_1->reserved() == to_0->reserved()); + REQUIRE(to_1->allocated() == 0); DArena * from_2 = gc.get_space(role::from_space(), generation{2}); @@ -125,13 +138,30 @@ namespace ut { /* attempt allocation */ auto gc_o = with_facet::mkobj(&gc); + auto c_o = with_facet::mkobj(&gc); + + /* register object types */ + bool ok = object2_register_types(c_o); + + REQUIRE(ok); + + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); DFloat * x0 = DFloat::make(gc_o, 3.1415927); auto x0_o = with_facet::mkobj(x0); + REQUIRE(to_0->allocated() == sizeof(AllocHeader) + sizeof(DFloat)); + DList * l0 = DList::list(gc_o, x0_o); auto l0_o = with_facet::mkobj(l0); + REQUIRE(to_0->allocated() == (sizeof(AllocHeader) + sizeof(DFloat) + + sizeof(AllocHeader) + sizeof(DList))); + { { REQUIRE(x0_o.iface() != nullptr); @@ -152,6 +182,7 @@ namespace ut { REQUIRE(l0_o.data() != nullptr); REQUIRE(gc.contains(role::to_space(), l0_o.data())); + /* check alloc info for newly-allocated object */ AllocInfo info = gc.alloc_info((std::byte *)l0_o.data()); REQUIRE(info.age() == 0); @@ -162,6 +193,7 @@ namespace ut { } } + /* no GC roots, so GC is trivial */ } catch (std::exception & ex) { std::cerr << "caught exception: " << ex.what() << std::endl; REQUIRE(false); From dd3185fb1a66f40aaa4ef43400cd704cd98e0d49 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 3 Jan 2026 00:19:26 -0500 Subject: [PATCH 020/176] xo-gc: + execute_gc() scaffold --- utest/X1Collector.test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 2afe158d..720711a9 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -194,6 +194,7 @@ namespace ut { } /* no GC roots, so GC is trivial */ + c_o.request_gc(generation{1}); } catch (std::exception & ex) { std::cerr << "caught exception: " << ex.what() << std::endl; REQUIRE(false); From b14d43a633a7a5be2267d25c40970cefb13ade5e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 3 Jan 2026 13:53:21 -0500 Subject: [PATCH 021/176] xo-gc: + arena for object roots --- utest/X1Collector.test.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 720711a9..bc579e93 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -98,7 +98,13 @@ namespace ut { REQUIRE(otypes->reserved() >= cfg.object_types_z_); REQUIRE(otypes->reserved() < cfg.object_types_z_ + otypes->page_z_); - DArena * from_0 = gc.get_space(role::from_space(), generation{0}); + const DArena * roots = gc.get_roots(); + + REQUIRE(roots != nullptr); + REQUIRE(roots->reserved() >= cfg.object_roots_z_); + REQUIRE(roots->reserved() < cfg.object_roots_z_ + roots->page_z_); + + const DArena * from_0 = gc.get_space(role::from_space(), generation{0}); REQUIRE(from_0 != nullptr); REQUIRE(from_0->reserved() >= tc.tenured_z_); @@ -106,7 +112,7 @@ namespace ut { REQUIRE(from_0->reserved() % from_0->page_z_ == 0); REQUIRE(from_0->allocated() == 0); - DArena * from_1 = gc.get_space(role::from_space(), generation{1}); + const DArena * from_1 = gc.get_space(role::from_space(), generation{1}); REQUIRE(from_1 != nullptr); REQUIRE(from_1->reserved() == from_0->reserved()); @@ -118,22 +124,22 @@ namespace ut { REQUIRE(to_0->reserved() == from_0->reserved()); REQUIRE(to_0->allocated() == 0); - DArena * to_1 = gc.get_space(role::to_space(), generation{1}); + const DArena * to_1 = gc.get_space(role::to_space(), generation{1}); REQUIRE(to_1 != nullptr); REQUIRE(to_1->reserved() == to_0->reserved()); REQUIRE(to_1->allocated() == 0); - DArena * from_2 = gc.get_space(role::from_space(), generation{2}); + const DArena * from_2 = gc.get_space(role::from_space(), generation{2}); REQUIRE(from_2 == nullptr); - DArena * to_2 = gc.get_space(role::to_space(), generation{2}); + const DArena * to_2 = gc.get_space(role::to_space(), generation{2}); REQUIRE(to_2 == nullptr); REQUIRE(gc.reserved_total() - == otypes->reserved() + 4 * from_0->reserved()); + == otypes->reserved() + roots->reserved() + 4 * from_0->reserved()); } /* attempt allocation */ @@ -147,18 +153,17 @@ namespace ut { ok = c_o.is_type_installed(typeseq::id()); REQUIRE(ok); - ok = c_o.is_type_installed(typeseq::id()); REQUIRE(ok); DFloat * x0 = DFloat::make(gc_o, 3.1415927); auto x0_o = with_facet::mkobj(x0); - + c_o.add_gc_root(&x0_o); REQUIRE(to_0->allocated() == sizeof(AllocHeader) + sizeof(DFloat)); DList * l0 = DList::list(gc_o, x0_o); auto l0_o = with_facet::mkobj(l0); - + c_o.add_gc_root(&l0_o); REQUIRE(to_0->allocated() == (sizeof(AllocHeader) + sizeof(DFloat) + sizeof(AllocHeader) + sizeof(DList))); @@ -195,6 +200,8 @@ namespace ut { /* no GC roots, so GC is trivial */ c_o.request_gc(generation{1}); + + } catch (std::exception & ex) { std::cerr << "caught exception: " << ex.what() << std::endl; REQUIRE(false); From 65ee116ff871e3fa48ab3ecb19940c19bb514e16 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 4 Jan 2026 00:34:19 -0500 Subject: [PATCH 022/176] xo-gc: copy/move step for collection phase --- src/object2/IGCObject_DFloat.cpp | 3 +-- src/object2/IGCObject_DInteger.cpp | 5 ++--- src/object2/IGCObject_DList.cpp | 3 +-- utest/X1Collector.test.cpp | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index 9d9a65de..be4849ac 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -25,8 +25,7 @@ namespace xo { IGCObject_DFloat::shallow_copy(const DFloat & src, obj mm) noexcept { - DFloat * copy = (DFloat *)mm.alloc(typeseq::id(), - sizeof(DFloat)); + DFloat * copy = (DFloat *)mm.alloc_copy((std::byte *)&src); if (copy) *copy = src; diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index d6c80bb6..cbc27f63 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -23,10 +23,9 @@ namespace xo { DInteger * IGCObject_DInteger::shallow_copy(const DInteger & src, - obj mm) noexcept + obj mm) noexcept { - DInteger * copy = (DInteger *)mm.alloc(typeseq::id(), - sizeof(DInteger)); + DInteger * copy = (DInteger *)mm.alloc_copy((std::byte *)&src); if (copy) *copy = src; diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index a30f2c6a..2139d682 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -24,8 +24,7 @@ namespace xo { IGCObject_DList::shallow_copy(const DList & src, obj mm) noexcept { - /* FIXME: need to supply object age here */ - DList * copy = (DList *)mm.alloc(typeseq::id(), sizeof(DList)); + DList * copy = (DList *)mm.alloc_copy((std::byte *)&src); if (copy) *copy = src; diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index bc579e93..b15a0c56 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -194,14 +194,14 @@ namespace ut { REQUIRE(info.tseq() == typeseq::id().seqno()); REQUIRE(info.size() >= sizeof(DList)); REQUIRE(info.size() < sizeof(DList) + padding::c_alloc_alignment); - } } + + /* no GC roots, so GC is trivial */ c_o.request_gc(generation{1}); - } catch (std::exception & ex) { std::cerr << "caught exception: " << ex.what() << std::endl; REQUIRE(false); From 103ffb8a179bf69f10ab0548569b49463f6b61e6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 4 Jan 2026 15:33:08 -0500 Subject: [PATCH 023/176] xo-gc xo-object2: gc bugfixes and logging [WORKING] --- src/object2/DList.cpp | 2 +- src/object2/IGCObject_DList.cpp | 3 +++ utest/X1Collector.test.cpp | 26 ++++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index d95f0bd0..a30aef82 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -41,7 +41,7 @@ namespace xo { bool DList::is_empty() const noexcept { - return this != &s_null; + return this == &s_null; } auto diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 2139d682..af7353f3 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -4,6 +4,7 @@ **/ #include "IGCObject_DList.hpp" +#include namespace xo { using xo::mm::AGCObject; @@ -36,6 +37,8 @@ namespace xo { IGCObject_DList::forward_children(DList & src, obj gc) noexcept { + scope log(XO_DEBUG(true)); + gc.forward_inplace(src.head_.iface(), (void **)&(src.head_.data_)); auto iface = xo::facet::impl_for(); diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index b15a0c56..1174635c 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -19,6 +19,9 @@ #include #include +#include +#include + #include namespace ut { @@ -39,6 +42,8 @@ namespace ut { using xo::mm::padding; using xo::facet::with_facet; using xo::facet::typeseq; + using xo::scope; + using xo::xtag; namespace { struct testcase_x1 { @@ -69,6 +74,9 @@ namespace ut { TEST_CASE("x1", "[gc][x1]") { + constexpr bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag)); + for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) { try { const testcase_x1 & tc = s_testcase_v[i_tc]; @@ -82,6 +90,7 @@ namespace ut { .gc_trigger_v_{{ tc.incr_gc_threshold_, tc.full_gc_threshold_}}, + .debug_flag_ = c_debug_flag, }; DX1Collector gc(cfg); @@ -140,6 +149,8 @@ namespace ut { REQUIRE(gc.reserved_total() == otypes->reserved() + roots->reserved() + 4 * from_0->reserved()); + + log && log(xtag("from_0", from_0->lo_), xtag("to_0", to_0->lo_)); } /* attempt allocation */ @@ -197,11 +208,22 @@ namespace ut { } } - - /* no GC roots, so GC is trivial */ c_o.request_gc(generation{1}); + log && log(xtag("l0_o.data()", l0_o.data())); + log && log(xtag("l0_o.data()->head_.data()", l0_o.data()->head_.data())); + log && log(xtag("x0_o.data()", x0_o.data())); + + REQUIRE(!gc.contains(role::from_space(), x0_o.data())); + REQUIRE(gc.contains(role::to_space(), x0_o.data())); + REQUIRE(x0_o.data()->value() == 3.1415927); + REQUIRE(!gc.contains(role::from_space(), l0_o.data())); + REQUIRE(gc.contains(role::to_space(), l0_o.data())); + REQUIRE(l0_o.data()->is_empty() == false); + + REQUIRE((void*)l0_o.data()->head_.data() == (void*)x0_o.data()); + } catch (std::exception & ex) { std::cerr << "caught exception: " << ex.what() << std::endl; REQUIRE(false); From a2e75071cc8b5cf5ed1c2ba5f8e0af0a32c35cb8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 4 Jan 2026 23:03:18 -0500 Subject: [PATCH 024/176] + xo-printable2 + build fixes for cmake config --- CMakeLists.txt | 16 +++++++++++++++- idl/IPrintable_DFloat.json5 | 11 +++++++++++ include/xo/object2/sequence/ISequence_Any.hpp | 4 ++-- include/xo/object2/sequence/ISequence_Xfer.hpp | 2 +- src/object2/CMakeLists.txt | 1 - 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 idl/IPrintable_DFloat.json5 diff --git a/CMakeLists.txt b/CMakeLists.txt index bb540b37..fc15ebf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,12 +37,26 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +get_target_property(xo_printable2_src_dir xo-printable2 xo_srcdir) +message(STATUS "xo_printable2_src_dir=${xo_printable_src_dir}") + +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-float + FACET Printable + REPR Float + INPUT idl/IPrintable_DFloat.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR . + OUTPUT_CPP_DIR src/object2 +) + # ---------------------------------------------------------------- # must complete definition of expression lib before configuring examples add_subdirectory(src/object2) add_subdirectory(utest) -#xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) # ---------------------------------------------------------------- # docs targets depend on other library/utest/exec targets above, diff --git a/idl/IPrintable_DFloat.json5 b/idl/IPrintable_DFloat.json5 new file mode 100644 index 00000000..31d10dd5 --- /dev/null +++ b/idl/IPrintable_DFloat.json5 @@ -0,0 +1,11 @@ +{ + mode: "implementation", + includes: [], + namespace1: "xo", + namespace2: "print", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DFloat", + using_doxygen: true, + repr: "DFloat", + doc: [ "doc for something or other" ], +} diff --git a/include/xo/object2/sequence/ISequence_Any.hpp b/include/xo/object2/sequence/ISequence_Any.hpp index 06838b36..dc9d73fc 100644 --- a/include/xo/object2/sequence/ISequence_Any.hpp +++ b/include/xo/object2/sequence/ISequence_Any.hpp @@ -66,7 +66,7 @@ namespace scm { ///@} private: - /** @defgraoup scm-sequence-any-private-methods **/ + /** @defgroup scm-sequence-any-private-methods **/ ///@{ [[noreturn]] static void _fatal(); @@ -74,7 +74,7 @@ namespace scm { ///@} public: - /** @defgraoup scm-sequence-any-member-vars **/ + /** @defgroup scm-sequence-any-member-vars **/ ///@{ static typeseq s_typeseq; diff --git a/include/xo/object2/sequence/ISequence_Xfer.hpp b/include/xo/object2/sequence/ISequence_Xfer.hpp index 4a679b6c..3bcad3d8 100644 --- a/include/xo/object2/sequence/ISequence_Xfer.hpp +++ b/include/xo/object2/sequence/ISequence_Xfer.hpp @@ -57,7 +57,7 @@ namespace scm { using I = Impl; public: - /** @defgraoup scm-sequence-xfer-member-vars **/ + /** @defgroup scm-sequence-xfer-member-vars **/ ///@{ /** typeseq for template parameter DRepr **/ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index fc66c970..f1359f3b 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -16,4 +16,3 @@ xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 $ # note: deps here must also appear in cmake/xo_alloc2Config.cmake.in xo_dependency(${SELF_LIB} xo_gc) #xo_dependency(${SELF_LIB} indentlog) -#add_dependencies(${SELF_LIB} xo-object2-facetimpl-sequence-list) From a903a058f1c101cc91eeb8d8ba161b7eeec036b6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 5 Jan 2026 11:53:44 -0500 Subject: [PATCH 025/176] xo-object2: APrintable+DFloat --- CMakeLists.txt | 5 +- cmake/xo_object2Config.cmake.in | 5 +- idl/IPrintable_DFloat.json5 | 5 +- idl/ISequence_DList.json5 | 2 +- include/xo/object2/DFloat.hpp | 4 ++ include/xo/object2/IPrintable_DFloat.hpp | 58 ++++++++++++++++++++++++ src/object2/CMakeLists.txt | 6 ++- src/object2/DFloat.cpp | 8 ++++ src/object2/IPrintable_DFloat.cpp | 28 ++++++++++++ 9 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 include/xo/object2/IPrintable_DFloat.hpp create mode 100644 src/object2/IPrintable_DFloat.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fc15ebf9..629d5491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,11 +37,12 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) -get_target_property(xo_printable2_src_dir xo-printable2 xo_srcdir) -message(STATUS "xo_printable2_src_dir=${xo_printable_src_dir}") +get_target_property(xo_printable2_dir share_xo_printable2 path) +message(STATUS "xo_printable2_dir=${xo_printable2_dir}") xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-float + FACET_DIR ${xo_printable2_dir} FACET Printable REPR Float INPUT idl/IPrintable_DFloat.json5 diff --git a/cmake/xo_object2Config.cmake.in b/cmake/xo_object2Config.cmake.in index c32a8368..45104c22 100644 --- a/cmake/xo_object2Config.cmake.in +++ b/cmake/xo_object2Config.cmake.in @@ -1,7 +1,8 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) -#find_dependency(indentlog) -find_dependency(xo_alloc2) +find_dependency(xo_gc) +find_dependency(xo_printable2) +find_dependency(indentlog) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") check_required_components("@PROJECT_NAME@") diff --git a/idl/IPrintable_DFloat.json5 b/idl/IPrintable_DFloat.json5 index 31d10dd5..ef51cf70 100644 --- a/idl/IPrintable_DFloat.json5 +++ b/idl/IPrintable_DFloat.json5 @@ -1,8 +1,9 @@ { mode: "implementation", - includes: [], + includes: [ "", + "" ], namespace1: "xo", - namespace2: "print", + namespace2: "scm", facet_idl: "idl/Printable.json5", brief: "provide APrintable interface for DFloat", using_doxygen: true, diff --git a/idl/ISequence_DList.json5 b/idl/ISequence_DList.json5 index 30c0b262..999fb482 100644 --- a/idl/ISequence_DList.json5 +++ b/idl/ISequence_DList.json5 @@ -1,6 +1,6 @@ { mode: "implementation", - includes: [], + includes: [ "" ], namespace1: "xo", namespace2: "scm", facet_idl: "idl/Sequence.json5", diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index 821e31d0..3df8f741 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -6,11 +6,13 @@ #pragma once #include +#include namespace xo { namespace scm { struct DFloat { using AAllocator = xo::mm::AAllocator; + using ppindentinfo = xo::print::ppindentinfo; explicit DFloat(double x) : value_{x} {} @@ -20,6 +22,8 @@ namespace xo { double value() const noexcept { return value_; } + bool pretty(const ppindentinfo & ppii) const; + operator double() const noexcept { return value_; } private: diff --git a/include/xo/object2/IPrintable_DFloat.hpp b/include/xo/object2/IPrintable_DFloat.hpp new file mode 100644 index 00000000..a7140cda --- /dev/null +++ b/include/xo/object2/IPrintable_DFloat.hpp @@ -0,0 +1,58 @@ +/** @file IPrintable_DFloat.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DFloat.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DFloat.json5] + **/ + +#pragma once + +#include +#include +#include "DFloat.hpp" + +namespace xo { namespace scm { class IPrintable_DFloat; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DFloat + **/ + class IPrintable_DFloat { + public: + /** @defgroup scm-printable-dfloat-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + ///@} + /** @defgroup scm-printable-dfloat-methods **/ + ///@{ + /** Pretty-printing support for this object. + See [xo-indentlog/xo/indentlog/pretty.hpp] + **/ + static bool pretty(const DFloat & self, const ppindentinfo & ppii); + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index f1359f3b..9ef4c63c 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -7,12 +7,14 @@ set(SELF_SRCS IGCObject_DList.cpp ISequence_Any.cpp ISequence_DList.cpp + IPrintable_DFloat.cpp DList.cpp DFloat.cpp object2_register_types.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) -# note: deps here must also appear in cmake/xo_alloc2Config.cmake.in +# note: deps here must also appear in cmake/xo_object2Config.cmake.in xo_dependency(${SELF_LIB} xo_gc) -#xo_dependency(${SELF_LIB} indentlog) +xo_dependency(${SELF_LIB} xo_printable2) +xo_dependency(${SELF_LIB} indentlog) diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index 1ef8fa52..a9f7150c 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -4,9 +4,11 @@ **/ #include "DFloat.hpp" +#include namespace xo { using xo::facet::typeseq; + using xo::print::ppdetail_atomic; namespace scm { DFloat * @@ -18,6 +20,12 @@ namespace xo { return new (mem) DFloat(x); } + + bool + DFloat::pretty(const ppindentinfo & ppii) const + { + return ppdetail_atomic::print_pretty(ppii, value_); + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/IPrintable_DFloat.cpp b/src/object2/IPrintable_DFloat.cpp new file mode 100644 index 00000000..98866266 --- /dev/null +++ b/src/object2/IPrintable_DFloat.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DFloat.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DFloat.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DFloat.json5] +**/ + +#include "IPrintable_DFloat.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DFloat::pretty(const DFloat & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DFloat.cpp */ \ No newline at end of file From ca27454ce87b17932f0e37f67b635a7597ce953d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 5 Jan 2026 12:09:42 -0500 Subject: [PATCH 026/176] xo-cmake: streamline facet gen --- CMakeLists.txt | 8 +++++--- include/xo/object2/IPrintable_DFloat.hpp | 7 +++---- src/object2/IPrintable_DFloat.cpp | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 629d5491..70df940d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ xo_add_genfacet( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-list + FACET_PKG xo_object2 FACET Sequence REPR List INPUT idl/ISequence_DList.json5 @@ -37,12 +38,13 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) -get_target_property(xo_printable2_dir share_xo_printable2 path) -message(STATUS "xo_printable2_dir=${xo_printable2_dir}") +#get_target_property(xo_printable2_dir share_xo_printable2 path) +#message(STATUS "xo_printable2_dir=${xo_printable2_dir}") xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-float - FACET_DIR ${xo_printable2_dir} + FACET_PKG xo_printable2 +# FACET_DIR ${xo_printable2_dir} FACET Printable REPR Float INPUT idl/IPrintable_DFloat.json5 diff --git a/include/xo/object2/IPrintable_DFloat.hpp b/include/xo/object2/IPrintable_DFloat.hpp index a7140cda..0ac94b9f 100644 --- a/include/xo/object2/IPrintable_DFloat.hpp +++ b/include/xo/object2/IPrintable_DFloat.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -45,8 +45,7 @@ namespace xo { /** @defgroup scm-printable-dfloat-methods **/ ///@{ /** Pretty-printing support for this object. - See [xo-indentlog/xo/indentlog/pretty.hpp] - **/ +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ static bool pretty(const DFloat & self, const ppindentinfo & ppii); ///@} @@ -55,4 +54,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/src/object2/IPrintable_DFloat.cpp b/src/object2/IPrintable_DFloat.cpp index 98866266..b459e384 100644 --- a/src/object2/IPrintable_DFloat.cpp +++ b/src/object2/IPrintable_DFloat.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: From 3b2a384ab6f4c3214cf2fc86f3ddca23359260a6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 5 Jan 2026 17:10:22 -0500 Subject: [PATCH 027/176] xo-object2: Printable+DList [WIP] --- CMakeLists.txt | 18 ++++++-- idl/IPrintable_DFloat.json5 | 2 +- idl/IPrintable_DList.json5 | 12 ++++++ include/xo/object2/DList.hpp | 3 ++ include/xo/object2/IPrintable_DList.hpp | 57 +++++++++++++++++++++++++ src/object2/CMakeLists.txt | 1 + src/object2/DList.cpp | 25 +++++++++++ src/object2/IPrintable_DList.cpp | 28 ++++++++++++ 8 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 idl/IPrintable_DList.json5 create mode 100644 include/xo/object2/IPrintable_DList.hpp create mode 100644 src/object2/IPrintable_DList.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 70df940d..2df2cb2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ xo_add_genfacet( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-list FACET_PKG xo_object2 @@ -38,13 +39,10 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) -#get_target_property(xo_printable2_dir share_xo_printable2 path) -#message(STATUS "xo_printable2_dir=${xo_printable2_dir}") - +# note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-float FACET_PKG xo_printable2 -# FACET_DIR ${xo_printable2_dir} FACET Printable REPR Float INPUT idl/IPrintable_DFloat.json5 @@ -53,6 +51,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-list + FACET_PKG xo_printable2 + FACET Printable + REPR List + INPUT idl/IPrintable_DList.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR . + OUTPUT_CPP_DIR src/object2 +) + # ---------------------------------------------------------------- # must complete definition of expression lib before configuring examples diff --git a/idl/IPrintable_DFloat.json5 b/idl/IPrintable_DFloat.json5 index ef51cf70..10673d3f 100644 --- a/idl/IPrintable_DFloat.json5 +++ b/idl/IPrintable_DFloat.json5 @@ -8,5 +8,5 @@ brief: "provide APrintable interface for DFloat", using_doxygen: true, repr: "DFloat", - doc: [ "doc for something or other" ], + doc: [ "implement APrintable for DFloat" ], } diff --git a/idl/IPrintable_DList.json5 b/idl/IPrintable_DList.json5 new file mode 100644 index 00000000..478ce7c2 --- /dev/null +++ b/idl/IPrintable_DList.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DList", + using_doxygen: true, + repr: "DList", + doc: [ "implement APrintable for DList" ], +} diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 65ed0ad4..f6296933 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -40,6 +40,9 @@ namespace xo { /** return element at 0-based index @p ix **/ obj at(size_type ix) const; + /** pretty-printing driver; combine layout+printing **/ + bool pretty(const ppindentinfo & ppii) const; + /** first member of list **/ obj head_; /** remainder of list **/ diff --git a/include/xo/object2/IPrintable_DList.hpp b/include/xo/object2/IPrintable_DList.hpp new file mode 100644 index 00000000..6a38f020 --- /dev/null +++ b/include/xo/object2/IPrintable_DList.hpp @@ -0,0 +1,57 @@ +/** @file IPrintable_DList.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DList.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DList.json5] + **/ + +#pragma once + +#include +#include +#include "DList.hpp" + +namespace xo { namespace scm { class IPrintable_DList; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DList + **/ + class IPrintable_DList { + public: + /** @defgroup scm-printable-dlist-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + ///@} + /** @defgroup scm-printable-dlist-methods **/ + ///@{ + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DList & self, const ppindentinfo & ppii); + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 9ef4c63c..62754f96 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -8,6 +8,7 @@ set(SELF_SRCS ISequence_Any.cpp ISequence_DList.cpp IPrintable_DFloat.cpp + IPrintable_DList.cpp DList.cpp DFloat.cpp object2_register_types.cpp diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index a30aef82..ea725773 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -84,6 +84,31 @@ namespace xo { return l->head_; } +#ifdef NOT_YET + bool + DList::pretty(const ppindentinfo & ppii) const + { + /* adapted from ppstate.pretty_struct(), see also */ + + using xo::print::ppstate; + + ppstate * pps = ppii.pps(); + + if (ppii.upto()) { +/* perhaps print on one line */ + if (!pps->print_upto("(") + return false; + + /* TODO: probably use iterators here, when available */ + const DList * l = this; + while (!l->is_empty()) { + obj(l->head_.data()); + + } + } + } +#endif + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/IPrintable_DList.cpp b/src/object2/IPrintable_DList.cpp new file mode 100644 index 00000000..880af691 --- /dev/null +++ b/src/object2/IPrintable_DList.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DList.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DList.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DList.json5] +**/ + +#include "IPrintable_DList.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DList::pretty(const DList & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DList.cpp */ \ No newline at end of file From 8d500231f2a9ffa1437eb22233ad1a4a2cf4e458 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 6 Jan 2026 00:01:38 -0500 Subject: [PATCH 028/176] xo-arena xo-facet xo-alloc2: build restored --- include/xo/object2/DList.hpp | 4 ++++ src/object2/IPrintable_DList.cpp | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index f6296933..6f803a82 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -8,6 +8,7 @@ #include //#include "xo/alloc2/gcobject/RGCObject.hpp" #include +#include namespace xo { namespace scm { @@ -16,6 +17,7 @@ namespace xo { using size_type = std::size_t; using AGCObject = xo::mm::AGCObject; using AAllocator = xo::mm::AAllocator; + using ppindentinfo = xo::print::ppindentinfo; DList(xo::obj h, DList * r) : head_{h}, rest_{r} {} @@ -40,8 +42,10 @@ namespace xo { /** return element at 0-based index @p ix **/ obj at(size_type ix) const; +#ifdef NOT_YET /** pretty-printing driver; combine layout+printing **/ bool pretty(const ppindentinfo & ppii) const; +#endif /** first member of list **/ obj head_; diff --git a/src/object2/IPrintable_DList.cpp b/src/object2/IPrintable_DList.cpp index 880af691..b705ad59 100644 --- a/src/object2/IPrintable_DList.cpp +++ b/src/object2/IPrintable_DList.cpp @@ -18,11 +18,17 @@ namespace xo { auto IPrintable_DList::pretty(const DList & self, const ppindentinfo & ppii) -> bool { + (void)self; + (void)ppii; + + return false; +#ifdef NOT_YET return self.pretty(ppii); +#endif } } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DList.cpp */ \ No newline at end of file +/* end IPrintable_DList.cpp */ From fff821ec8f8188ea8d8333ee2463ceaf23679963 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 6 Jan 2026 00:08:50 -0500 Subject: [PATCH 029/176] xo-arena: annex padding from xo-alloc2 --- utest/X1Collector.test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 1174635c..adfc9771 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -17,7 +17,8 @@ #include #include -#include + +#include #include #include From 80537c3d68cd2d7db7ab6d82d9c175fdd0fd9364 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 6 Jan 2026 00:14:13 -0500 Subject: [PATCH 030/176] xo-arena: annex AllocInfo.*pp from xo-alloc2 --- utest/X1Collector.test.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index adfc9771..8b37c8ab 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -16,8 +16,7 @@ #include #include -#include - +#include #include #include From d5e1e6290bff7c11e50d8a4b40989f8b64ff6d62 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 9 Jan 2026 10:07:20 -0500 Subject: [PATCH 031/176] xo-facet: runtime facet lookup [PROTO] --- src/object2/DList.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 65b18a69..8d851e78 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -4,11 +4,15 @@ **/ #include "DList.hpp" +#include +#include #include #include namespace xo { + using xo::print::APrintable; using xo::mm::AGCObject; + using xo::facet::FacetRegistry; using xo::facet::typeseq; namespace scm { @@ -96,17 +100,28 @@ namespace xo { if (ppii.upto()) { /* perhaps print on one line */ - if (!pps->print_upto("(...)")) - return false; + pps->write("("); -#ifdef NOT_YET /* TODO: probably use iterators here, when available */ const DList * l = this; - while (!l->is_empty()) { - obj(l->head_.data()); + size_t i = 0; + while (!l->is_empty()) { + if (i > 0) + pps->write(" "); + + obj elt + = FacetRegistry::instance().variant(l->head_); + // what if no converter registered ? + + if (!pps->print_upto(elt)) + return false; + + l = l->rest_; + ++i; } -#endif + + pps->write(")"); return true; } else { pps->write("(...)"); From 148d5e9ca0aafb1639098f6686ae1b0e25de9f8d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 9 Jan 2026 17:48:54 -0500 Subject: [PATCH 032/176] xo-objectd2 xo-printable xo-facet: pp working for List(Integer) Also streamline facet switching --- include/xo/object2/DInteger.hpp | 23 ++- include/xo/object2/DList.hpp | 38 ++++- include/xo/object2/IPrintable_DInteger.hpp | 57 +++++++ include/xo/object2/IPrintable_DList.hpp | 2 +- include/xo/object2/object2_register_types.hpp | 3 + src/object2/CMakeLists.txt | 4 +- src/object2/DInteger.cpp | 32 ++++ src/object2/DList.cpp | 17 ++- src/object2/IPrintable_DInteger.cpp | 28 ++++ src/object2/object2_register_types.cpp | 39 +++++ utest/CMakeLists.txt | 1 + utest/Printable.test.cpp | 141 ++++++++++++++++++ utest/X1Collector.test.cpp | 2 +- 13 files changed, 379 insertions(+), 8 deletions(-) create mode 100644 include/xo/object2/IPrintable_DInteger.hpp create mode 100644 src/object2/DInteger.cpp create mode 100644 src/object2/IPrintable_DInteger.cpp create mode 100644 utest/Printable.test.cpp diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index 3457af79..25921474 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -5,11 +5,32 @@ #pragma once +#include +#include #include namespace xo { namespace scm { - using DInteger = std::int64_t; + struct DInteger { + using AAllocator = xo::mm::AAllocator; + using ppindentinfo = xo::print::ppindentinfo; + + explicit DInteger(long x) : value_{x} {} + + /** allocate boxed value @p x using memory from @p mm **/ + static DInteger * make(obj mm, + long x); + + double value() const noexcept { return value_; } + + bool pretty(const ppindentinfo & ppii) const; + + operator long() const noexcept { return value_; } + + private: + /** boxed integer value **/ + long value_; + }; } /*nmaespace obj*/ } /*namespace xo*/ diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index dc0729bf..1e863a60 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -13,6 +13,7 @@ namespace xo { namespace scm { + // TODO: consider renaming to DCons struct DList { using size_type = std::size_t; using AGCObject = xo::mm::AGCObject; @@ -22,8 +23,27 @@ namespace xo { DList(xo::obj h, DList * r) : head_{h}, rest_{r} {} + template + static obj nil(); + + /** shortcut for + * cons(mm, cdr, cdr.data()) + **/ + template + static obj cons(obj mm, + obj car, + obj cdr); + /** sentinel for null list **/ - static DList * null(); + static DList * _nil(); + + /** list with first element @p car, + * followed by contents of list @p cdr. + * Shares structure with @p cdr + **/ + static DList * _cons(obj mm, + obj car, + DList * cdr); /** list with one element @p h1, allocated from @p mm **/ static DList * list(obj mm, @@ -51,6 +71,22 @@ namespace xo { DList * rest_ = nullptr; }; + template + obj + DList::nil() + { + return obj(DList::_nil()); + } + + template + obj + DList::cons(obj mm, + obj car, + obj cdr) + { + return obj(DList::_cons(mm, car, cdr.data())); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/object2/IPrintable_DInteger.hpp b/include/xo/object2/IPrintable_DInteger.hpp new file mode 100644 index 00000000..d18b25ab --- /dev/null +++ b/include/xo/object2/IPrintable_DInteger.hpp @@ -0,0 +1,57 @@ +/** @file IPrintable_DInteger.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DInteger.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DInteger.json5] + **/ + +#pragma once + +#include +#include +#include "DInteger.hpp" + +namespace xo { namespace scm { class IPrintable_DInteger; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DInteger + **/ + class IPrintable_DInteger { + public: + /** @defgroup scm-printable-dinteger-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + ///@} + /** @defgroup scm-printable-dinteger-methods **/ + ///@{ + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DInteger & self, const ppindentinfo & ppii); + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ diff --git a/include/xo/object2/IPrintable_DList.hpp b/include/xo/object2/IPrintable_DList.hpp index 6a38f020..ac4c5315 100644 --- a/include/xo/object2/IPrintable_DList.hpp +++ b/include/xo/object2/IPrintable_DList.hpp @@ -54,4 +54,4 @@ See [xo-indentlog/xo/indentlog/pretty.hpp] **/ } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/object2_register_types.hpp b/include/xo/object2/object2_register_types.hpp index 9b2656a1..110779cb 100644 --- a/include/xo/object2/object2_register_types.hpp +++ b/include/xo/object2/object2_register_types.hpp @@ -13,6 +13,9 @@ namespace xo { * Return true iff all types register successfully. **/ bool object2_register_types(obj gc); + + /** Register object2 (facet,impl) combinations with FacetRegistry **/ + bool object2_register_facets(); } } diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 62754f96..d784e881 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -7,10 +7,12 @@ set(SELF_SRCS IGCObject_DList.cpp ISequence_Any.cpp ISequence_DList.cpp - IPrintable_DFloat.cpp IPrintable_DList.cpp + IPrintable_DFloat.cpp + IPrintable_DInteger.cpp DList.cpp DFloat.cpp + DInteger.cpp object2_register_types.cpp ) diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp new file mode 100644 index 00000000..1aa3efb1 --- /dev/null +++ b/src/object2/DInteger.cpp @@ -0,0 +1,32 @@ +/** @file DInteger.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DInteger.hpp" +#include + +namespace xo { + using xo::facet::typeseq; + using xo::print::ppdetail_atomic; + + namespace scm { + DInteger * + DInteger::make(obj mm, + long x) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DInteger)); + + return new (mem) DInteger(x); + } + + bool + DInteger::pretty(const ppindentinfo & ppii) const + { + return ppdetail_atomic::print_pretty(ppii, value_); + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DInteger.cpp */ diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 8d851e78..777d5033 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -19,18 +19,28 @@ namespace xo { static DList s_null(obj(), nullptr); DList * - DList::null() + DList::_nil() { return &s_null; } + DList * + DList::_cons(obj mm, + obj car, + DList * cdr) + { + void * mem = mm.alloc(typeseq::id(), sizeof(DList)); + + return new (mem) DList(car, cdr); + } + DList * DList::list(obj mm, obj h1) { void * mem = mm.alloc(typeseq::id(), sizeof(DList)); - return new (mem) DList(h1, DList::null()); + return new (mem) DList(h1, DList::_nil()); } DList * @@ -112,7 +122,8 @@ namespace xo { obj elt = FacetRegistry::instance().variant(l->head_); - // what if no converter registered ? + + assert(elt); if (!pps->print_upto(elt)) return false; diff --git a/src/object2/IPrintable_DInteger.cpp b/src/object2/IPrintable_DInteger.cpp new file mode 100644 index 00000000..8e9bc774 --- /dev/null +++ b/src/object2/IPrintable_DInteger.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DInteger.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DInteger.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DInteger.json5] +**/ + +#include "IPrintable_DInteger.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DInteger::pretty(const DInteger & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DInteger.cpp */ diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index e472401a..131b8cfc 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -4,22 +4,36 @@ **/ #include "object2_register_types.hpp" + #include "IGCObject_DList.hpp" #include "IGCObject_DFloat.hpp" #include "IGCObject_DInteger.hpp" +#include "IPrintable_DList.hpp" +//#include "IPrintable_DFloat.hpp" +#include "IPrintable_DInteger.hpp" + +#include +#include + namespace xo { + using xo::print::APrintable; + using xo::mm::AAllocator; using xo::mm::ACollector; using xo::mm::AGCObject; using xo::mm::IGCObject_Any; + using xo::facet::FacetRegistry; using xo::facet::impl_for; using xo::facet::typeseq; + using xo::scope; namespace scm { bool object2_register_types(obj gc) { + scope log(XO_DEBUG(true)); + bool ok = true; ok &= gc.install_type(impl_for()); @@ -28,6 +42,31 @@ namespace xo { return ok; } + + bool + object2_register_facets() + { + scope log(XO_DEBUG(true)); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); +// FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + log && log(xtag("DList.tseq", typeseq::id())); + log && log(xtag("DFloat.tseq", typeseq::id())); + log && log(xtag("DInteger.tseq", typeseq::id())); + + log && log(xtag("AAllocator.tseq", typeseq::id())); + log && log(xtag("APrintable.tseq", typeseq::id())); + log && log(xtag("AGCObject.tseq", typeseq::id())); + + return true; + } } } /*namespace xo*/ diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 258f56a1..70544571 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -4,6 +4,7 @@ set(UTEST_EXE utest.object2) set(UTEST_SRCS object2_utest_main.cpp X1Collector.test.cpp + Printable.test.cpp ) xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp new file mode 100644 index 00000000..d385a8e9 --- /dev/null +++ b/utest/Printable.test.cpp @@ -0,0 +1,141 @@ +/** @file Printable.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DList.hpp" +#include "object2_register_types.hpp" + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include +#include + +#include + +namespace ut { + using xo::scm::object2_register_types; + using xo::scm::object2_register_facets; + using xo::scm::DList; + using xo::scm::DInteger; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + using xo::facet::typeseq; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + using xo::scope; + using xo::xtag; + using std::string; + + namespace { + struct testcase_pp { + explicit testcase_pp(size_t gc_z, size_t gc_threshold, int z, const std::string & expected) + : gc_gen_size_{gc_z}, gc_trigger_threshold_{gc_threshold}, expected_{expected} { + for (int i = 0; i < z; ++i) { + list_.push_back(1000 + 197 * i); + } + } + + size_t gc_gen_size_ = 0; + size_t gc_trigger_threshold_ = 0; + std::vector list_; + std::string expected_; + }; + + std::vector + s_testcase_v = { + testcase_pp(16384, 8192, 0, "()"), + testcase_pp(16384, 8192, 1, "(1000)"), + testcase_pp(16384, 8192, 2, "(1000 1197)"), + testcase_pp(16384, 8192, 5, "(1000 1197 1394 1591 1788)"), + testcase_pp(16384, 8192, 10, "(1000 1197 1394 1591 1788 1985 2182 2379 2576 2773)"), + testcase_pp(16384, 8192, 20, "(...)"), + }; + } + + TEST_CASE("printable1", "[pp][x1][list]") + { + constexpr bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag)); + + bool ok = object2_register_facets(); + REQUIRE(ok); + + FacetRegistry::instance().dump(&std::cerr); + + for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) { + try { + const testcase_pp & tc = s_testcase_v[i_tc]; + + CollectorConfig cfg{ + .name_ = "pp_test", + .arena_config_ = ArenaConfig{ + .size_ = tc.gc_gen_size_, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{tc.gc_trigger_threshold_, + tc.gc_trigger_threshold_}}, + .debug_flag_ = c_debug_flag + }; + + DX1Collector gc(cfg); + auto gc_o = with_facet::mkobj(&gc); + auto c_o = with_facet::mkobj(&gc); + + bool ok = object2_register_types(c_o); + REQUIRE(ok); + + auto l0_o = DList::nil(); + + c_o.add_gc_root(&l0_o); + + for(int ip1 = tc.list_.size(); ip1 > 0; --ip1) { + // auto xi_o = Integer::make(g_o, ...); + DInteger * xi = DInteger::make(gc_o, tc.list_[ip1 - 1]); + auto xi_o = with_facet::mkobj(xi); + + l0_o = DList::cons(gc_o, xi_o, l0_o); + } + + // TODO: log_streambuf using DArena + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj l0_po(static_cast(l0_o.data())); + REQUIRE(l0_po._typeseq() == typeseq::id()); + + pps.pretty(l0_po); + + REQUIRE(ss.str() == string(tc.expected_)); + } catch (std::exception & ex) { + std::cerr << "caught exception: " << ex.what() << std::endl; + REQUIRE(false); + } + } + } /* TEST_CASE(printable1) */ +} + +/* end Printable.test.cpp */ diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 8b37c8ab..9d4256a1 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -74,7 +74,7 @@ namespace ut { TEST_CASE("x1", "[gc][x1]") { - constexpr bool c_debug_flag = true; + constexpr bool c_debug_flag = false; scope log(XO_DEBUG(c_debug_flag)); for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) { From 59ce547db30d84bc409a466bf20a75aedfd47a6d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 9 Jan 2026 17:54:42 -0500 Subject: [PATCH 033/176] xo-object2: streamline DInteger alloc. make() -> box() --- include/xo/object2/DInteger.hpp | 15 +++++++++++++-- src/object2/DInteger.cpp | 3 +-- utest/Printable.test.cpp | 4 +--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index 25921474..d125fc4d 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -7,6 +7,7 @@ #include #include +#include #include namespace xo { @@ -17,9 +18,12 @@ namespace xo { explicit DInteger(long x) : value_{x} {} + /** will likely want this to default to ANumeric, once we have it **/ + template + static obj box(obj mm, long x); + /** allocate boxed value @p x using memory from @p mm **/ - static DInteger * make(obj mm, - long x); + static DInteger * _box(obj mm, long x); double value() const noexcept { return value_; } @@ -31,6 +35,13 @@ namespace xo { /** boxed integer value **/ long value_; }; + + template + obj + DInteger::box(obj mm, long x) { + return obj(_box(mm, x)); + } + } /*nmaespace obj*/ } /*namespace xo*/ diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 1aa3efb1..8e1b9594 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -12,8 +12,7 @@ namespace xo { namespace scm { DInteger * - DInteger::make(obj mm, - long x) + DInteger::_box(obj mm, long x) { void * mem = mm.alloc(typeseq::id(), sizeof(DInteger)); diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index d385a8e9..e84d52a6 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -112,9 +112,7 @@ namespace ut { c_o.add_gc_root(&l0_o); for(int ip1 = tc.list_.size(); ip1 > 0; --ip1) { - // auto xi_o = Integer::make(g_o, ...); - DInteger * xi = DInteger::make(gc_o, tc.list_[ip1 - 1]); - auto xi_o = with_facet::mkobj(xi); + auto xi_o = DInteger::box(gc_o, tc.list_[ip1 - 1]); l0_o = DList::cons(gc_o, xi_o, l0_o); } From ce32d59bc353ffcbce055d73d5d4f41b054a42ef Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 9 Jan 2026 18:09:50 -0500 Subject: [PATCH 034/176] xo-object: streamline DFloat construction, like w/ DList/DInteger --- include/xo/object2/DFloat.hpp | 14 ++++++++++++-- src/object2/DFloat.cpp | 3 +-- utest/X1Collector.test.cpp | 3 +-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index 3df8f741..0812a59c 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -6,6 +6,7 @@ #pragma once #include +#include #include namespace xo { @@ -16,9 +17,12 @@ namespace xo { explicit DFloat(double x) : value_{x} {} + /** probably want default = ANumeric, once we introduce it **/ + template + static obj box(obj mm, double x); + /** allocate boxed value @p x using memory from @p mm **/ - static DFloat * make(obj mm, - double x); + static DFloat * _box(obj mm, double x); double value() const noexcept { return value_; } @@ -31,6 +35,12 @@ namespace xo { /** boxed floating-oint value **/ double value_; }; + + template + obj + DFloat::box(obj mm, double x) { + return obj(DFloat::_box(mm, x)); + } } /*nmaespace scm*/ } /*namespace xo*/ diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index a9f7150c..52940efe 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -12,8 +12,7 @@ namespace xo { namespace scm { DFloat * - DFloat::make(obj mm, - double x) + DFloat::_box(obj mm, double x) { void * mem = mm.alloc(typeseq::id(), sizeof(DFloat)); diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 9d4256a1..cec744e9 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -167,8 +167,7 @@ namespace ut { ok = c_o.is_type_installed(typeseq::id()); REQUIRE(ok); - DFloat * x0 = DFloat::make(gc_o, 3.1415927); - auto x0_o = with_facet::mkobj(x0); + auto x0_o = DFloat::box(gc_o, 3.1415927); c_o.add_gc_root(&x0_o); REQUIRE(to_0->allocated() == sizeof(AllocHeader) + sizeof(DFloat)); From 8f1361763e50b8e1cf0e6096c3d60c0e97b5cb68 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 11 Jan 2026 12:32:02 -0500 Subject: [PATCH 035/176] xo-object2: streamline DList::list use --- include/xo/object2/DList.hpp | 30 ++++++++++++++++++++++++++++++ src/object2/DList.cpp | 2 ++ utest/X1Collector.test.cpp | 5 +++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 1e863a60..b023f0d3 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -34,6 +34,17 @@ namespace xo { obj car, obj cdr); + /** list with one element @p e1, allocated from @p mm **/ + template + static obj list(obj mm, + obj e1); + + /** list with two element @p e1, @p e2, allocated from @p mm **/ + template + static obj list(obj mm, + obj e1, + obj e2); + /** sentinel for null list **/ static DList * _nil(); @@ -45,6 +56,7 @@ namespace xo { obj car, DList * cdr); +#ifdef OBSOLETE /** list with one element @p h1, allocated from @p mm **/ static DList * list(obj mm, obj h1); @@ -52,6 +64,7 @@ namespace xo { static DList * list(obj mm, obj h1, obj h2); +#endif /** DList length is at least 1 **/ bool is_empty() const noexcept; @@ -87,6 +100,23 @@ namespace xo { return obj(DList::_cons(mm, car, cdr.data())); } + template + obj + DList::list(obj mm, + obj e1) + { + return cons(mm, e1, nil()); + } + + template + obj + DList::list(obj mm, + obj e1, + obj e2) + { + return cons(mm, e1, list(mm, e2)); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 777d5033..934fa503 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -34,6 +34,7 @@ namespace xo { return new (mem) DList(car, cdr); } +#ifdef OBSOLETE DList * DList::list(obj mm, obj h1) @@ -52,6 +53,7 @@ namespace xo { return new (mem) DList(h1, DList::list(mm, h2)); } +#endif bool DList::is_empty() const noexcept diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index cec744e9..1536ebfd 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -171,8 +171,9 @@ namespace ut { c_o.add_gc_root(&x0_o); REQUIRE(to_0->allocated() == sizeof(AllocHeader) + sizeof(DFloat)); - DList * l0 = DList::list(gc_o, x0_o); - auto l0_o = with_facet::mkobj(l0); + //DList * l0 = DList::list(gc_o, x0_o); + //auto l0_o = with_facet::mkobj(l0); + auto l0_o = DList::list(gc_o, x0_o); c_o.add_gc_root(&l0_o); REQUIRE(to_0->allocated() == (sizeof(AllocHeader) + sizeof(DFloat) + sizeof(AllocHeader) + sizeof(DList))); From 46de06354859356327d5e5a05e516e73db9b1d76 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 11 Jan 2026 12:32:41 -0500 Subject: [PATCH 036/176] cosmetic --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2df2cb2c..4dfdf4d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ add_definitions(${PROJECT_CXX_FLAGS}) # ---------------------------------------------------------------- +# note: manual target; generated code committed to git xo_add_genfacet( TARGET xo-object2-facet-sequence FACET Sequence From 3d8cff548376220cfbbeb6911cf03661b9eba8ac Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 12 Jan 2026 01:03:49 -0500 Subject: [PATCH 037/176] xo-alloc2 xo-object2 : refactor to build on osx --- include/xo/object2/DList.hpp | 58 +------------ include/xo/object2/IGCObject_DList.hpp | 3 +- include/xo/object2/ListOps.hpp | 84 +++++++++++++++++++ .../xo/object2/object2_register_facets.hpp | 17 ++++ include/xo/object2/object2_register_types.hpp | 7 +- src/object2/CMakeLists.txt | 1 + src/object2/DList.cpp | 1 - src/object2/IGCObject_DList.cpp | 2 +- src/object2/IPrintable_DList.cpp | 2 +- src/object2/ISequence_DList.cpp | 3 +- src/object2/object2_register_facets.cpp | 57 +++++++++++++ src/object2/object2_register_types.cpp | 34 +------- utest/Printable.test.cpp | 7 +- utest/X1Collector.test.cpp | 4 +- 14 files changed, 180 insertions(+), 100 deletions(-) create mode 100644 include/xo/object2/ListOps.hpp create mode 100644 include/xo/object2/object2_register_facets.hpp create mode 100644 src/object2/object2_register_facets.cpp diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index b023f0d3..d20fadca 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -6,7 +6,6 @@ #pragma once #include -//#include "xo/alloc2/gcobject/RGCObject.hpp" #include #include @@ -14,6 +13,8 @@ namespace xo { namespace scm { // TODO: consider renaming to DCons + // See also ListOps in ListOps.hpp + // struct DList { using size_type = std::size_t; using AGCObject = xo::mm::AGCObject; @@ -23,28 +24,6 @@ namespace xo { DList(xo::obj h, DList * r) : head_{h}, rest_{r} {} - template - static obj nil(); - - /** shortcut for - * cons(mm, cdr, cdr.data()) - **/ - template - static obj cons(obj mm, - obj car, - obj cdr); - - /** list with one element @p e1, allocated from @p mm **/ - template - static obj list(obj mm, - obj e1); - - /** list with two element @p e1, @p e2, allocated from @p mm **/ - template - static obj list(obj mm, - obj e1, - obj e2); - /** sentinel for null list **/ static DList * _nil(); @@ -84,39 +63,6 @@ namespace xo { DList * rest_ = nullptr; }; - template - obj - DList::nil() - { - return obj(DList::_nil()); - } - - template - obj - DList::cons(obj mm, - obj car, - obj cdr) - { - return obj(DList::_cons(mm, car, cdr.data())); - } - - template - obj - DList::list(obj mm, - obj e1) - { - return cons(mm, e1, nil()); - } - - template - obj - DList::list(obj mm, - obj e1, - obj e2) - { - return cons(mm, e1, list(mm, e2)); - } - } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp index 3d61a71d..eba4a7d1 100644 --- a/include/xo/object2/IGCObject_DList.hpp +++ b/include/xo/object2/IGCObject_DList.hpp @@ -9,10 +9,11 @@ #include #include #include -#include "DList.hpp" +//#include "DList.hpp" // circular namespace xo { namespace scm { struct IGCObject_DList; } + namespace scm { struct DList; } namespace facet { template <> diff --git a/include/xo/object2/ListOps.hpp b/include/xo/object2/ListOps.hpp new file mode 100644 index 00000000..90041cac --- /dev/null +++ b/include/xo/object2/ListOps.hpp @@ -0,0 +1,84 @@ +/** @file ListOps.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "IGCObject_DList.hpp" +#include "DList.hpp" + +namespace xo { + namespace scm { + /** @brief list functions + * + * note: separate from DList, to avoid problems with deps needed + * to compile functions that return obj + **/ + struct ListOps { + using AGCObject = xo::mm::AGCObject; + using AAllocator = xo::mm::AAllocator; + + template + static obj nil(); + + /** shortcut for + * cons(mm, cdr, cdr.data()) + **/ + template + static obj cons(obj mm, + obj car, + obj cdr); + + /** list with one element @p e1, allocated from @p mm **/ + template + static obj list(obj mm, + obj e1); + + /** list with two element @p e1, @p e2, allocated from @p mm **/ + template + static obj list(obj mm, + obj e1, + obj e2); + + }; + + template + obj + ListOps::nil() + { + return obj(DList::_nil()); + } + + template + obj + ListOps::cons(obj mm, + obj car, + obj cdr) + { + return obj(DList::_cons(mm, car, cdr.data())); + } + + template + obj + ListOps::list(obj mm, + obj e1) + { + // clang 15 doesn't like nil() here. + + return cons(mm, e1, nil()); + } + + template + obj + ListOps::list(obj mm, + obj e1, + obj e2) + { + return cons(mm, e1, list(mm, e2)); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end ListOps.hpp */ diff --git a/include/xo/object2/object2_register_facets.hpp b/include/xo/object2/object2_register_facets.hpp new file mode 100644 index 00000000..e419b794 --- /dev/null +++ b/include/xo/object2/object2_register_facets.hpp @@ -0,0 +1,17 @@ +/** @file object2_register_facets.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + /** Register object2 (facet,impl) combinations with FacetRegistry **/ + bool object2_register_facets(); + } +} + +/* end object2_register_facets.hpp */ diff --git a/include/xo/object2/object2_register_types.hpp b/include/xo/object2/object2_register_types.hpp index 110779cb..5c61692d 100644 --- a/include/xo/object2/object2_register_types.hpp +++ b/include/xo/object2/object2_register_types.hpp @@ -9,13 +9,8 @@ namespace xo { namespace scm { - /** Register all object2/ gc-aware types with @p gc. - * Return true iff all types register successfully. - **/ - bool object2_register_types(obj gc); - /** Register object2 (facet,impl) combinations with FacetRegistry **/ - bool object2_register_facets(); + bool object2_register_types(obj gc); } } diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index d784e881..fc4c2d8e 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -14,6 +14,7 @@ set(SELF_SRCS DFloat.cpp DInteger.cpp object2_register_types.cpp + object2_register_facets.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 934fa503..b43d1a9f 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -141,7 +141,6 @@ namespace xo { return false; } } - } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index af7353f3..4266075d 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -4,6 +4,7 @@ **/ #include "IGCObject_DList.hpp" +#include "DList.hpp" #include namespace xo { @@ -46,7 +47,6 @@ namespace xo { return shallow_size(src); } - } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/IPrintable_DList.cpp b/src/object2/IPrintable_DList.cpp index 880af691..19e5a875 100644 --- a/src/object2/IPrintable_DList.cpp +++ b/src/object2/IPrintable_DList.cpp @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DList.cpp */ \ No newline at end of file +/* end IPrintable_DList.cpp */ diff --git a/src/object2/ISequence_DList.cpp b/src/object2/ISequence_DList.cpp index 22d5bde5..71dcf744 100644 --- a/src/object2/ISequence_DList.cpp +++ b/src/object2/ISequence_DList.cpp @@ -11,6 +11,7 @@ * [idl/ISequence_DList.json5] **/ +#include "IGCObject_DList.hpp" // apparently need this with clang 15 #include "ISequence_DList.hpp" namespace xo { @@ -37,4 +38,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end ISequence_DList.cpp */ \ No newline at end of file +/* end ISequence_DList.cpp */ diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp new file mode 100644 index 00000000..210fb7c0 --- /dev/null +++ b/src/object2/object2_register_facets.cpp @@ -0,0 +1,57 @@ +/** @file object2_register_facets.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "object2_register_facets.hpp" +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +namespace xo { + using xo::print::APrintable; + using xo::mm::AAllocator; + using xo::mm::AGCObject; + using xo::scm::DList; + using xo::scm::DFloat; + using xo::facet::FacetRegistry; + using xo::facet::typeseq; + + namespace scm { + bool + object2_register_facets() + { + scope log(XO_DEBUG(true)); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + log && log(xtag("DList.tseq", typeseq::id())); + log && log(xtag("DFloat.tseq", typeseq::id())); + log && log(xtag("DInteger.tseq", typeseq::id())); + + log && log(xtag("AAllocator.tseq", typeseq::id())); + log && log(xtag("APrintable.tseq", typeseq::id())); + log && log(xtag("AGCObject.tseq", typeseq::id())); + + return true; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end object2_register_facets.cpp */ diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index 131b8cfc..909d28ab 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -17,18 +17,17 @@ #include namespace xo { - using xo::print::APrintable; - using xo::mm::AAllocator; +// using xo::print::APrintable; +// using xo::mm::AAllocator; using xo::mm::ACollector; using xo::mm::AGCObject; - using xo::mm::IGCObject_Any; - using xo::facet::FacetRegistry; +// using xo::mm::IGCObject_Any; +// using xo::facet::FacetRegistry; using xo::facet::impl_for; using xo::facet::typeseq; using xo::scope; namespace scm { - bool object2_register_types(obj gc) { @@ -42,31 +41,6 @@ namespace xo { return ok; } - - bool - object2_register_facets() - { - scope log(XO_DEBUG(true)); - - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); - - FacetRegistry::register_impl(); -// FacetRegistry::register_impl(); - - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); - - log && log(xtag("DList.tseq", typeseq::id())); - log && log(xtag("DFloat.tseq", typeseq::id())); - log && log(xtag("DInteger.tseq", typeseq::id())); - - log && log(xtag("AAllocator.tseq", typeseq::id())); - log && log(xtag("APrintable.tseq", typeseq::id())); - log && log(xtag("AGCObject.tseq", typeseq::id())); - - return true; - } } } /*namespace xo*/ diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index e84d52a6..47bfcf1b 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -3,8 +3,10 @@ * @author Roland Conybeare, Jan 2026 **/ +#include "ListOps.hpp" #include "DList.hpp" #include "object2_register_types.hpp" +#include "object2_register_facets.hpp" #include #include @@ -30,6 +32,7 @@ namespace ut { using xo::scm::object2_register_types; using xo::scm::object2_register_facets; + using xo::scm::ListOps; using xo::scm::DList; using xo::scm::DInteger; using xo::mm::AAllocator; @@ -107,14 +110,14 @@ namespace ut { bool ok = object2_register_types(c_o); REQUIRE(ok); - auto l0_o = DList::nil(); + auto l0_o = ListOps::nil(); c_o.add_gc_root(&l0_o); for(int ip1 = tc.list_.size(); ip1 > 0; --ip1) { auto xi_o = DInteger::box(gc_o, tc.list_[ip1 - 1]); - l0_o = DList::cons(gc_o, xi_o, l0_o); + l0_o = ListOps::cons(gc_o, xi_o, l0_o); } // TODO: log_streambuf using DArena diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 1536ebfd..2ad93810 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -3,6 +3,7 @@ * @author Roland Conybeare, Dec 2025 **/ +#include "ListOps.hpp" #include "DFloat.hpp" #include "DList.hpp" #include "object2_register_types.hpp" @@ -26,6 +27,7 @@ namespace ut { using xo::scm::object2_register_types; + using xo::scm::ListOps; using xo::scm::DList; using xo::scm::DFloat; using xo::mm::AAllocator; @@ -173,7 +175,7 @@ namespace ut { //DList * l0 = DList::list(gc_o, x0_o); //auto l0_o = with_facet::mkobj(l0); - auto l0_o = DList::list(gc_o, x0_o); + auto l0_o = ListOps::list(gc_o, x0_o); c_o.add_gc_root(&l0_o); REQUIRE(to_0->allocated() == (sizeof(AllocHeader) + sizeof(DFloat) + sizeof(AllocHeader) + sizeof(DList))); From 0c9f9d2f0d242b4e40f68df2e05a6f5b17cbfec3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 12 Jan 2026 21:50:17 -0500 Subject: [PATCH 038/176] xo-expression2: + Expression facet --- include/xo/object2/DList.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index d20fadca..58de0750 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -21,6 +21,7 @@ namespace xo { using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; + public: DList(xo::obj h, DList * r) : head_{h}, rest_{r} {} From b710505709266feeeffc4c572f35071c76fab5a9 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 13 Jan 2026 01:40:48 -0500 Subject: [PATCH 039/176] + xo-interpreter2 scaffold for constant expression [WIP] --- include/xo/object2/DFloat.hpp | 1 + include/xo/object2/DInteger.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index 0812a59c..ab38d078 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -14,6 +14,7 @@ namespace xo { struct DFloat { using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; + using value_type = double; explicit DFloat(double x) : value_{x} {} diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index d125fc4d..8cb109f4 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -15,6 +15,7 @@ namespace xo { struct DInteger { using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; + using value_type = long; explicit DInteger(long x) : value_{x} {} From 8d577129ee20d893166eb56725daf117a894152d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 13 Jan 2026 16:43:58 -0500 Subject: [PATCH 040/176] xo-object2: beginning of DString + utest --- include/xo/object2/DList.hpp | 15 ++---- include/xo/object2/DString.hpp | 58 ++++++++++++++++++++++ include/xo/object2/IPrintable_DInteger.hpp | 1 - src/object2/CMakeLists.txt | 1 + src/object2/DString.cpp | 37 ++++++++++++++ utest/CMakeLists.txt | 1 + utest/DString.test.cpp | 36 ++++++++++++++ 7 files changed, 137 insertions(+), 12 deletions(-) create mode 100644 include/xo/object2/DString.hpp create mode 100644 src/object2/DString.cpp create mode 100644 utest/DString.test.cpp diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 58de0750..eecb4310 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -25,27 +25,20 @@ namespace xo { DList(xo::obj h, DList * r) : head_{h}, rest_{r} {} - /** sentinel for null list **/ + /** sentinel for null list. + * Application code may prefer ListOps::nil() + **/ static DList * _nil(); /** list with first element @p car, * followed by contents of list @p cdr. * Shares structure with @p cdr + * Application code may prefer ListOps::cons() **/ static DList * _cons(obj mm, obj car, DList * cdr); -#ifdef OBSOLETE - /** list with one element @p h1, allocated from @p mm **/ - static DList * list(obj mm, - obj h1); - /** list with two elements @p h1, @p h2, allocated from @p mm **/ - static DList * list(obj mm, - obj h1, - obj h2); -#endif - /** DList length is at least 1 **/ bool is_empty() const noexcept; /** DList models a finite sequence **/ diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp new file mode 100644 index 00000000..6333f7a4 --- /dev/null +++ b/include/xo/object2/DString.hpp @@ -0,0 +1,58 @@ +/** @file DString.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include +#include +#include + +namespace xo { + namespace scm { + /** @class DString + * @brief String implementation with gc hooks + * + * String implementation for Schematika. + * Size-prefixed and null-terminated. + * Note however that string length != size for utf-8. + * + * Uses flexible array for chars, + * with string contents in memory immediately + * following the DString itself + **/ + struct DString { + public: + using size_type = std::uint32_t; + using AAllocator = xo::mm::AAllocator; + + /** create empty string with space for @cap chars + * (including null terminator). + * Use memory from allocator @p mm + **/ + static DString * empty(obj mm, + size_type cap); + + /** create string containing a copy of null-terminated @p cstr. + * Use memory from allocator @p mm + **/ + static DString * from_cstr(obj mm, + const char * cstr); + + size_type capacity() const noexcept { return capacity_; } + size_type size() const noexcept { return size_; } + const char * chars() const noexcept { return chars_; } + + private: + /** extent of @ref chars_ array **/ + size_type capacity_ = 0; + /** null terminator at @c chars_[size_] **/ + size_type size_ = 0; + /** string contents **/ + char chars_[]; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DString.hpp */ diff --git a/include/xo/object2/IPrintable_DInteger.hpp b/include/xo/object2/IPrintable_DInteger.hpp index d18b25ab..60c9821c 100644 --- a/include/xo/object2/IPrintable_DInteger.hpp +++ b/include/xo/object2/IPrintable_DInteger.hpp @@ -14,7 +14,6 @@ #pragma once #include -#include #include "DInteger.hpp" namespace xo { namespace scm { class IPrintable_DInteger; } } diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index fc4c2d8e..a3658925 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -13,6 +13,7 @@ set(SELF_SRCS DList.cpp DFloat.cpp DInteger.cpp + DString.cpp object2_register_types.cpp object2_register_facets.cpp ) diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp new file mode 100644 index 00000000..0fad514e --- /dev/null +++ b/src/object2/DString.cpp @@ -0,0 +1,37 @@ +/** @file DString.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DString.hpp" + +namespace xo { + using xo::facet::typeseq; + + namespace scm { + DString * + DString::empty(obj mm, + size_type cap) + { + assert(cap > 0); + + DString * result = nullptr; + + if (cap > 0) { + void * mem = mm.alloc(typeseq::id(), + sizeof(DString) + cap); + + result = new (mem) DString(); + result->capacity_ = cap; + result->size_ = 0; + if (cap > 0) { + result->chars_[0] = '\0'; + } + } + + return result; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DString.cpp */ diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 70544571..a681e52c 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -3,6 +3,7 @@ set(UTEST_EXE utest.object2) set(UTEST_SRCS object2_utest_main.cpp + DString.test.cpp X1Collector.test.cpp Printable.test.cpp ) diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp new file mode 100644 index 00000000..da4d8ca4 --- /dev/null +++ b/utest/DString.test.cpp @@ -0,0 +1,36 @@ +/** @file DString.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include +#include +#include + +namespace xo { + using xo::scm::DString; + using xo::mm::AAllocator; + using xo::mm::DArena; + using xo::mm::ArenaConfig; + using xo::facet::with_facet; + using xo::facet::obj; + + namespace ut { + TEST_CASE("DString-empty", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::empty(alloc, 16); + + REQUIRE(s != nullptr); + REQUIRE(s->capacity() == 16); + REQUIRE(s->size() == 0); + REQUIRE(s->chars()[0] == '\0'); + } + } /*namespace ut*/ +} /*namespace xo*/ + +/* end DString.test.cpp */ From 6b216a7e846f769458ea7f5fcd33b659b479fc98 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 13 Jan 2026 16:47:44 -0500 Subject: [PATCH 041/176] xo-object2: add DString::from_cstr + utest --- src/object2/DString.cpp | 19 +++++++++++++++++++ utest/DString.test.cpp | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index 0fad514e..7f5aee15 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -4,6 +4,7 @@ **/ #include "DString.hpp" +#include namespace xo { using xo::facet::typeseq; @@ -31,6 +32,24 @@ namespace xo { return result; } + + DString * + DString::from_cstr(obj mm, + const char * cstr) + { + size_type len = std::strlen(cstr); + size_type cap = len + 1; + + void * mem = mm.alloc(typeseq::id(), + sizeof(DString) + cap); + + DString * result = new (mem) DString(); + result->capacity_ = cap; + result->size_ = len; + std::memcpy(result->chars_, cstr, cap); + + return result; + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index da4d8ca4..c3437b6b 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace xo { using xo::scm::DString; @@ -30,6 +31,22 @@ namespace xo { REQUIRE(s->size() == 0); REQUIRE(s->chars()[0] == '\0'); } + + TEST_CASE("DString-from_cstr", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + const char * cstr = "hello world"; + DString * s = DString::from_cstr(alloc, cstr); + + REQUIRE(s != nullptr); + REQUIRE(s->capacity() == 12); + REQUIRE(s->size() == 11); + REQUIRE(std::strcmp(s->chars(), cstr) == 0); + } } /*namespace ut*/ } /*namespace xo*/ From d3ba2900d68cb278301c9610ead4ebd0d9ae6fa8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 13 Jan 2026 17:07:03 -0500 Subject: [PATCH 042/176] xo-object2: + DString::assign --- include/xo/object2/DString.hpp | 63 ++++++++++++++++++++++++++++++++++ src/object2/DString.cpp | 13 +++++++ utest/DString.test.cpp | 32 +++++++++++++++++ 3 files changed, 108 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index 6333f7a4..dbd72ddf 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -7,6 +7,7 @@ #include #include +#include #include namespace xo { @@ -27,6 +28,9 @@ namespace xo { using size_type = std::uint32_t; using AAllocator = xo::mm::AAllocator; + /** @defgroup dstring-ctors constructors **/ + ///@{ + /** create empty string with space for @cap chars * (including null terminator). * Use memory from allocator @p mm @@ -40,10 +44,69 @@ namespace xo { static DString * from_cstr(obj mm, const char * cstr); + ///@} + /** @defgroup dstring-access access methods **/ + ///@{ + size_type capacity() const noexcept { return capacity_; } size_type size() const noexcept { return size_; } const char * chars() const noexcept { return chars_; } + ///@} + /** @defgroup dstring-iterators iterators **/ + ///@{ + + ///@} + /** @defgroup dstring-assign assignment **/ + ///@{ + + /** put string into empty state **/ + void clear() noexcept { size_ = 0; chars_[0] = '\0'; } + + /** replace contents with @p other, or prefix of up to @p capacity - 1 chars **/ + DString & assign(const DString & other); + + // TODO - behave like std::string, to the extent feasible + // insert + // insert_range + // erase + // push_back + // append + // append_range + // operator+= + // replace + // replace_with_range + // copy + // find + // rfind + // find_first_of + // find_first_not_of + // find_last_of + // find_last_not_of + // compare + // starts_with + // end_with + // contains + // substr + + ///@} + /** @defgroup dstring-conversion-operators conversion operators **/ + ///@{ + + operator std::string_view() const noexcept { return std::string_view(chars_); } + + /** @brief conversion oeprator to C-style string. + * + * Example + * @code + * DString s = ...; + * ::strcmp(s, "obey..."); + * @endcode + **/ + operator const char * () const noexcept { return &(chars_[0]); } + + ///@} + private: /** extent of @ref chars_ array **/ size_type capacity_ = 0; diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index 7f5aee15..53feef8c 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -4,6 +4,7 @@ **/ #include "DString.hpp" +#include #include namespace xo { @@ -50,6 +51,18 @@ namespace xo { return result; } + + DString & + DString::assign(const DString & other) + { + size_type n = std::min(other.size_, capacity_ - 1); + std::memcpy(chars_, other.chars_, n); + chars_[n] = '\0'; + size_ = n; + + return *this; + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index c3437b6b..0bc3e596 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -47,6 +47,38 @@ namespace xo { REQUIRE(s->size() == 11); REQUIRE(std::strcmp(s->chars(), cstr) == 0); } + + TEST_CASE("DString-assign", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * src = DString::from_cstr(alloc, "hello"); + DString * dst = DString::empty(alloc, 16); + + dst->assign(*src); + + REQUIRE(dst->size() == 5); + REQUIRE(std::strcmp(dst->chars(), "hello") == 0); + } + + TEST_CASE("DString-assign-truncate", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * src = DString::from_cstr(alloc, "hello world"); + DString * dst = DString::empty(alloc, 6); + + dst->assign(*src); + + REQUIRE(dst->size() == 5); + REQUIRE(std::strcmp(dst->chars(), "hello") == 0); + } } /*namespace ut*/ } /*namespace xo*/ From ed2c5841d43eacf6c77b81d602d784a5888ee9fa Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 13 Jan 2026 17:40:06 -0500 Subject: [PATCH 043/176] xo-object2: + DString methods --- include/xo/object2/DString.hpp | 21 +++++++++++++++++++++ src/object2/DString.cpp | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index dbd72ddf..0292c818 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -48,6 +48,17 @@ namespace xo { /** @defgroup dstring-access access methods **/ ///@{ + /** get writeable access to string representation. + * Caller responsible for calling fixup() if string length modified + **/ + char * data() noexcept { return chars_; } + + /** return char at position @p pos in this string, counting from zero. + * Does not check bounds. Undefined behavior if @p pos = @ref capacity_ + **/ + char & operator[](size_type pos) noexcept { return chars_[pos]; } + const char & operator[](size_type pos) const noexcept { return chars_[pos]; } + size_type capacity() const noexcept { return capacity_; } size_type size() const noexcept { return size_; } const char * chars() const noexcept { return chars_; } @@ -89,6 +100,11 @@ namespace xo { // contains // substr + /** recalculate string size if string contents modified without + * through side effects + **/ + size_type fixup_size() noexcept; + ///@} /** @defgroup dstring-conversion-operators conversion operators **/ ///@{ @@ -108,12 +124,17 @@ namespace xo { ///@} private: + /** @defgroup dstring-instance-variables instance variables **/ + ///@{ + /** extent of @ref chars_ array **/ size_type capacity_ = 0; /** null terminator at @c chars_[size_] **/ size_type size_ = 0; /** string contents **/ char chars_[]; + + ///@} }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index 53feef8c..c173d106 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -63,6 +63,14 @@ namespace xo { return *this; } + auto + DString::fixup_size() noexcept -> size_type + { + this->chars_[capacity_ - 1] = '\0'; + this->size_ = ::strlen(chars_); + return this->size_; + } + } /*namespace scm*/ } /*namespace xo*/ From f620fc39656f09ed0288be024626f21ae7c2aac3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 13 Jan 2026 17:42:50 -0500 Subject: [PATCH 044/176] xo-object2: + DString utests --- utest/DString.test.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index 0bc3e596..b757c1b6 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -79,6 +79,104 @@ namespace xo { REQUIRE(dst->size() == 5); REQUIRE(std::strcmp(dst->chars(), "hello") == 0); } + + TEST_CASE("DString-data", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::empty(alloc, 16); + char * p = s->data(); + std::strcpy(p, "test"); + s->fixup_size(); + + REQUIRE(s->size() == 4); + REQUIRE(std::strcmp(s->chars(), "test") == 0); + } + + TEST_CASE("DString-operator-bracket", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::from_cstr(alloc, "hello"); + + REQUIRE((*s)[0] == 'h'); + REQUIRE((*s)[4] == 'o'); + + (*s)[0] = 'H'; + REQUIRE(std::strcmp(s->chars(), "Hello") == 0); + } + + TEST_CASE("DString-clear", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::from_cstr(alloc, "hello"); + REQUIRE(s->size() == 5); + + s->clear(); + + REQUIRE(s->size() == 0); + REQUIRE(s->chars()[0] == '\0'); + REQUIRE(s->capacity() == 6); + } + + TEST_CASE("DString-fixup_size", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::empty(alloc, 16); + char * p = s->data(); + p[0] = 'a'; + p[1] = 'b'; + p[2] = 'c'; + p[3] = '\0'; + + REQUIRE(s->size() == 0); + + auto new_size = s->fixup_size(); + + REQUIRE(new_size == 3); + REQUIRE(s->size() == 3); + } + + TEST_CASE("DString-string_view", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::from_cstr(alloc, "hello"); + std::string_view sv = *s; + + REQUIRE(sv == "hello"); + REQUIRE(sv.size() == 5); + } + + TEST_CASE("DString-cstr-conversion", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::from_cstr(alloc, "hello"); + const char * cstr = *s; + + REQUIRE(std::strcmp(cstr, "hello") == 0); + } } /*namespace ut*/ } /*namespace xo*/ From 629db9b93a6fedb900b6f7ffc8e4bcc261f9033c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 13 Jan 2026 17:52:27 -0500 Subject: [PATCH 045/176] xo-object2: + DString iterator methods --- include/xo/object2/DString.hpp | 19 ++++++++++ utest/DString.test.cpp | 66 ++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index 0292c818..7f8e1eeb 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -25,9 +25,21 @@ namespace xo { **/ struct DString { public: + /** @defgroup dstring-types type traits **/ + ///@{ + /** character traits for this DString **/ + using traits_type = std::char_traits; + /** type of each character in this DString **/ + using value_type = char; using size_type = std::uint32_t; + /** representation for a read/write iterator **/ + using iterator = char *; + /** representation for a readonly iterator **/ + using const_iterator = const char *; + /** xo allocator **/ using AAllocator = xo::mm::AAllocator; + ///@} /** @defgroup dstring-ctors constructors **/ ///@{ @@ -66,6 +78,13 @@ namespace xo { ///@} /** @defgroup dstring-iterators iterators **/ ///@{ + iterator begin() noexcept { return &chars_[0]; } + iterator end() noexcept { return &chars_[size_]; } + + const_iterator cbegin() const noexcept { return &chars_[0]; } + const_iterator cend() const noexcept { return &chars_[size_]; } + const_iterator begin() const noexcept { return cbegin(); } + const_iterator end() const noexcept { return cend(); } ///@} /** @defgroup dstring-assign assignment **/ diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index b757c1b6..c6d217f1 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -6,7 +6,9 @@ #include #include #include +#include #include +#include namespace xo { using xo::scm::DString; @@ -177,6 +179,70 @@ namespace xo { REQUIRE(std::strcmp(cstr, "hello") == 0); } + + TEST_CASE("DString-begin-end", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::from_cstr(alloc, "hello"); + + REQUIRE(s->begin() == s->chars()); + REQUIRE(s->end() == s->chars() + 5); + REQUIRE(s->end() - s->begin() == 5); + + *s->begin() = 'H'; + REQUIRE(std::strcmp(s->chars(), "Hello") == 0); + } + + TEST_CASE("DString-cbegin-cend", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::from_cstr(alloc, "hello"); + + REQUIRE(s->cbegin() == s->chars()); + REQUIRE(s->cend() == s->chars() + 5); + REQUIRE(s->cend() - s->cbegin() == 5); + } + + TEST_CASE("DString-range-for", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::from_cstr(alloc, "hello"); + + std::string result; + for (char c : *s) { + result += c; + } + + REQUIRE(result == "hello"); + } + + TEST_CASE("DString-iterator-modify", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::from_cstr(alloc, "hello"); + + for (auto it = s->begin(); it != s->end(); ++it) { + *it = std::toupper(*it); + } + + REQUIRE(std::strcmp(s->chars(), "HELLO") == 0); + } } /*namespace ut*/ } /*namespace xo*/ From 78e7548e530bd803335ddce20913438590067b00 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 14 Jan 2026 14:37:44 -0500 Subject: [PATCH 046/176] xo-object2 xo-gc xo-facet: codegen updates + IGCObject_DString --- CMakeLists.txt | 12 +++++ idl/IGCObject_DString.json5 | 14 +++++ include/xo/object2/DString.hpp | 44 +++++++++++++++- include/xo/object2/IGCObject_DString.hpp | 66 ++++++++++++++++++++++++ src/object2/CMakeLists.txt | 1 + src/object2/DString.cpp | 42 +++++++++++++++ src/object2/IGCObject_DString.cpp | 39 ++++++++++++++ src/object2/object2_register_facets.cpp | 6 +++ utest/DString.test.cpp | 17 ++++++ 9 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 idl/IGCObject_DString.json5 create mode 100644 include/xo/object2/IGCObject_DString.hpp create mode 100644 src/object2/IGCObject_DString.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dfdf4d8..556e6d66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-gcobject-string + FACET_PKG xo_gc + FACET GCObject + REPR String + INPUT idl/IGCObject_DString.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR string + OUTPUT_CPP_DIR src/object2 +) + # ---------------------------------------------------------------- # must complete definition of expression lib before configuring examples diff --git a/idl/IGCObject_DString.json5 b/idl/IGCObject_DString.json5 new file mode 100644 index 00000000..b8fcfba5 --- /dev/null +++ b/idl/IGCObject_DString.json5 @@ -0,0 +1,14 @@ +{ + mode: "implementation", + includes: [ "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DString", + using_doxygen: true, + repr: "DString", + doc: [ "implement AGCObject for DString" ], +} diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index 7f8e1eeb..accdd96d 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -6,7 +6,9 @@ #pragma once #include +#include #include +#include #include #include @@ -38,11 +40,22 @@ namespace xo { using const_iterator = const char *; /** xo allocator **/ using AAllocator = xo::mm::AAllocator; - + /** garbage collector **/ + using ACollector = xo::mm::ACollector; + /** ppindentinfo for APrintable **/ + using ppindentinfo = xo::print::ppindentinfo; ///@} /** @defgroup dstring-ctors constructors **/ ///@{ + /** default ctor **/ + DString() = default; + + /** not simply copyable, because of flexible array. + * Need allocator + **/ + DString(const DString &) = delete; + /** create empty string with space for @cap chars * (including null terminator). * Use memory from allocator @p mm @@ -56,6 +69,17 @@ namespace xo { static DString * from_cstr(obj mm, const char * cstr); + /** clone existing string **/ + static DString * clone(obj mm, + const DString * src); + +#ifdef NOT_YET + /** **/ + static DString * concat(obj mm, + DString * s1, + DString * s2); +#endif + ///@} /** @defgroup dstring-access access methods **/ ///@{ @@ -141,6 +165,24 @@ namespace xo { operator const char * () const noexcept { return &(chars_[0]); } ///@} + /** @defgroup dstring-printable-methods printable facet methods **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + /** @defgroup dstring-gcobject-methods gcobject facet methods **/ + ///@{ + + size_type shallow_size() const noexcept; + + /** clone string, using memory from allocator @p mm **/ + DString * shallow_copy(obj mm) const noexcept; + + /** fixup child pointers (trivial for DString, no children) **/ + size_type forward_children(obj gc) noexcept; + + ///@} private: /** @defgroup dstring-instance-variables instance variables **/ diff --git a/include/xo/object2/IGCObject_DString.hpp b/include/xo/object2/IGCObject_DString.hpp new file mode 100644 index 00000000..ad12cb80 --- /dev/null +++ b/include/xo/object2/IGCObject_DString.hpp @@ -0,0 +1,66 @@ +/** @file IGCObject_DString.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DString.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DString.json5] + **/ + +#pragma once + +#include +#include +#include "DString.hpp" + +namespace xo { namespace scm { class IGCObject_DString; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DString + **/ + class IGCObject_DString { + public: + /** @defgroup scm-gcobject-dstring-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dstring-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DString & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DString & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DString & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index a3658925..4c74529f 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -5,6 +5,7 @@ set(SELF_SRCS IGCObject_DFloat.cpp IGCObject_DInteger.cpp IGCObject_DList.cpp + IGCObject_DString.cpp ISequence_Any.cpp ISequence_DList.cpp IPrintable_DList.cpp diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index c173d106..3278d258 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -52,6 +52,22 @@ namespace xo { return result; } + DString * + DString::clone(obj mm, const DString * src) + { + size_type cap = src->capacity_; + + void * mem = mm.alloc(typeseq::id(), + sizeof(DString) + cap); + + DString * result = new (mem) DString(); + result->capacity_ = cap; + result->size_ = src->size_; + std::memcpy(result->chars_, src->chars_, cap); + + return result; + } + DString & DString::assign(const DString & other) { @@ -71,6 +87,32 @@ namespace xo { return this->size_; } + auto + DString::shallow_size() const noexcept -> size_type + { + return sizeof(DString) + capacity_; + } + + DString * + DString::shallow_copy(obj mm) const noexcept + { + DString * copy = (DString *)mm.alloc_copy((std::byte *)this); + + if (copy) { + copy->capacity_ = capacity_; + copy->size_ = size_; + ::memcpy(copy->chars_, chars_, capacity_); + } + + return copy; + } + + auto + DString::forward_children(obj) noexcept -> size_type + { + return shallow_size(); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/IGCObject_DString.cpp b/src/object2/IGCObject_DString.cpp new file mode 100644 index 00000000..72a81244 --- /dev/null +++ b/src/object2/IGCObject_DString.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DString.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DString.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DString.json5] +**/ + +#include "IGCObject_DString.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DString::shallow_size(const DString & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DString::shallow_copy(const DString & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DString::forward_children(DString & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DString.cpp */ \ No newline at end of file diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 210fb7c0..c33b0637 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -4,9 +4,11 @@ **/ #include "object2_register_facets.hpp" + #include #include #include +#include #include #include @@ -23,6 +25,7 @@ namespace xo { using xo::mm::AGCObject; using xo::scm::DList; using xo::scm::DFloat; + using xo::scm::DString; using xo::facet::FacetRegistry; using xo::facet::typeseq; @@ -41,9 +44,12 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DList.tseq", typeseq::id())); log && log(xtag("DFloat.tseq", typeseq::id())); log && log(xtag("DInteger.tseq", typeseq::id())); + log && log(xtag("DString.tseq", typeseq::id())); log && log(xtag("AAllocator.tseq", typeseq::id())); log && log(xtag("APrintable.tseq", typeseq::id())); diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index c6d217f1..b5f70f17 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -243,6 +243,23 @@ namespace xo { REQUIRE(std::strcmp(s->chars(), "HELLO") == 0); } + + TEST_CASE("DString-clone", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * src = DString::from_cstr(alloc, "hello world"); + DString * copy = DString::clone(alloc, src); + + REQUIRE(copy != nullptr); + REQUIRE(copy != src); + REQUIRE(copy->size() == src->size()); + REQUIRE(copy->capacity() == src->capacity()); + REQUIRE(std::strcmp(copy->chars(), src->chars()) == 0); + } } /*namespace ut*/ } /*namespace xo*/ From 989a42cc8c9579bcbbc37197adc5349080f17a9f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 14 Jan 2026 15:27:32 -0500 Subject: [PATCH 047/176] xo-object2 gardening for IGCObject_DString --- CMakeLists.txt | 4 ++-- idl/IGCObject_DString.json5 | 3 ++- include/xo/object2/{ => string}/IGCObject_DString.hpp | 0 src/object2/IGCObject_DString.cpp | 4 ++-- src/object2/object2_register_facets.cpp | 2 +- src/object2/object2_register_types.cpp | 9 +++++---- 6 files changed, 12 insertions(+), 10 deletions(-) rename include/xo/object2/{ => string}/IGCObject_DString.hpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 556e6d66..31b408a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,8 +71,8 @@ xo_add_genfacetimpl( FACET GCObject REPR String INPUT idl/IGCObject_DString.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR string + OUTPUT_HPP_DIR include/xo/object2/string + OUTPUT_IMPL_SUBDIR . OUTPUT_CPP_DIR src/object2 ) diff --git a/idl/IGCObject_DString.json5 b/idl/IGCObject_DString.json5 index b8fcfba5..8d0e14e0 100644 --- a/idl/IGCObject_DString.json5 +++ b/idl/IGCObject_DString.json5 @@ -1,6 +1,7 @@ { mode: "implementation", - includes: [ "", + includes: [ + "", "" ], local_types: [ ], diff --git a/include/xo/object2/IGCObject_DString.hpp b/include/xo/object2/string/IGCObject_DString.hpp similarity index 100% rename from include/xo/object2/IGCObject_DString.hpp rename to include/xo/object2/string/IGCObject_DString.hpp diff --git a/src/object2/IGCObject_DString.cpp b/src/object2/IGCObject_DString.cpp index 72a81244..d411686a 100644 --- a/src/object2/IGCObject_DString.cpp +++ b/src/object2/IGCObject_DString.cpp @@ -11,7 +11,7 @@ * [idl/IGCObject_DString.json5] **/ -#include "IGCObject_DString.hpp" +#include "string/IGCObject_DString.hpp" namespace xo { namespace scm { @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DString.cpp */ \ No newline at end of file +/* end IGCObject_DString.cpp */ diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index c33b0637..8b9e8106 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index 909d28ab..b8b68756 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -8,6 +8,7 @@ #include "IGCObject_DList.hpp" #include "IGCObject_DFloat.hpp" #include "IGCObject_DInteger.hpp" +#include "string/IGCObject_DString.hpp" #include "IPrintable_DList.hpp" //#include "IPrintable_DFloat.hpp" @@ -17,12 +18,8 @@ #include namespace xo { -// using xo::print::APrintable; -// using xo::mm::AAllocator; using xo::mm::ACollector; using xo::mm::AGCObject; -// using xo::mm::IGCObject_Any; -// using xo::facet::FacetRegistry; using xo::facet::impl_for; using xo::facet::typeseq; using xo::scope; @@ -39,6 +36,10 @@ namespace xo { ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + + ok &= gc.install_type(impl_for()); + return ok; } } From 8a5cd339e8b9bc64b1fc9e4351a6078ac3ee82c7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 14 Jan 2026 16:32:58 -0500 Subject: [PATCH 048/176] xo-facet xo-object2: facet fixes + IPrintable_DString --- CMakeLists.txt | 12 ++++ idl/IPrintable_DString.json5 | 13 ++++ .../xo/object2/string/IPrintable_DString.hpp | 61 +++++++++++++++++++ src/object2/CMakeLists.txt | 1 + src/object2/DInteger.cpp | 1 + src/object2/DList.cpp | 6 +- src/object2/DString.cpp | 8 +++ src/object2/IPrintable_DList.cpp | 1 + src/object2/IPrintable_DString.cpp | 28 +++++++++ src/object2/object2_register_facets.cpp | 2 + utest/Printable.test.cpp | 4 +- 11 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 idl/IPrintable_DString.json5 create mode 100644 include/xo/object2/string/IPrintable_DString.hpp create mode 100644 src/object2/IPrintable_DString.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 31b408a1..19a59363 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-string + FACET_PKG xo_printable2 + FACET Printable + REPR String + INPUT idl/IPrintable_DString.json5 + OUTPUT_HPP_DIR include/xo/object2/string + OUTPUT_IMPL_SUBDIR . + OUTPUT_CPP_DIR src/object2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-string diff --git a/idl/IPrintable_DString.json5 b/idl/IPrintable_DString.json5 new file mode 100644 index 00000000..f032ca46 --- /dev/null +++ b/idl/IPrintable_DString.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DString", + using_doxygen: true, + repr: "DString", + doc: [ "implement APrintable for DString" ], +} diff --git a/include/xo/object2/string/IPrintable_DString.hpp b/include/xo/object2/string/IPrintable_DString.hpp new file mode 100644 index 00000000..d1d3f22a --- /dev/null +++ b/include/xo/object2/string/IPrintable_DString.hpp @@ -0,0 +1,61 @@ +/** @file IPrintable_DString.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DString.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DString.json5] + **/ + +#pragma once + +#include +#include +#include "DString.hpp" + +namespace xo { namespace scm { class IPrintable_DString; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DString + **/ + class IPrintable_DString { + public: + /** @defgroup scm-printable-dstring-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dstring-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DString & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 4c74529f..5764d98b 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -11,6 +11,7 @@ set(SELF_SRCS IPrintable_DList.cpp IPrintable_DFloat.cpp IPrintable_DInteger.cpp + IPrintable_DString.cpp DList.cpp DFloat.cpp DInteger.cpp diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 8e1b9594..6c670ccd 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -5,6 +5,7 @@ #include "DInteger.hpp" #include +#include namespace xo { using xo::facet::typeseq; diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index b43d1a9f..19e09e11 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -4,6 +4,8 @@ **/ #include "DList.hpp" +#include "IPrintable_DList.hpp" +#include #include #include #include @@ -125,7 +127,9 @@ namespace xo { obj elt = FacetRegistry::instance().variant(l->head_); - assert(elt); + + + assert(elt.data()); if (!pps->print_upto(elt)) return false; diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index 3278d258..517f3f97 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -4,11 +4,13 @@ **/ #include "DString.hpp" +#include #include #include namespace xo { using xo::facet::typeseq; + using xo::print::ppdetail_atomic; namespace scm { DString * @@ -113,6 +115,12 @@ namespace xo { return shallow_size(); } + bool + DString::pretty(const ppindentinfo & ppii) const + { + return ppdetail_atomic::print_pretty(ppii, &(chars_[0])); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/IPrintable_DList.cpp b/src/object2/IPrintable_DList.cpp index 19e5a875..bdcf6694 100644 --- a/src/object2/IPrintable_DList.cpp +++ b/src/object2/IPrintable_DList.cpp @@ -12,6 +12,7 @@ **/ #include "IPrintable_DList.hpp" +#include namespace xo { namespace scm { diff --git a/src/object2/IPrintable_DString.cpp b/src/object2/IPrintable_DString.cpp new file mode 100644 index 00000000..f47aa3fa --- /dev/null +++ b/src/object2/IPrintable_DString.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DString.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DString.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DString.json5] +**/ + +#include "string/IPrintable_DString.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DString::pretty(const DString & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DString.cpp */ diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 8b9e8106..9cf67988 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); log && log(xtag("DList.tseq", typeseq::id())); log && log(xtag("DFloat.tseq", typeseq::id())); diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index 47bfcf1b..c1b63dc4 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -89,6 +89,8 @@ namespace ut { FacetRegistry::instance().dump(&std::cerr); for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) { + log && log("printable1 test:", xtag("i_tc", i_tc)); + try { const testcase_pp & tc = s_testcase_v[i_tc]; @@ -130,7 +132,7 @@ namespace ut { pps.pretty(l0_po); - REQUIRE(ss.str() == string(tc.expected_)); + CHECK(ss.str() == string(tc.expected_)); } catch (std::exception & ex) { std::cerr << "caught exception: " << ex.what() << std::endl; REQUIRE(false); From 7e0b182da3b5c190850c269d3b66f8521995b891 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 14 Jan 2026 16:42:11 -0500 Subject: [PATCH 049/176] xo-object2: + DString.sprintf --- include/xo/object2/DString.hpp | 20 ++++++++++++++++++++ utest/DString.test.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index accdd96d..b7be7086 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace xo { namespace scm { @@ -119,6 +120,25 @@ namespace xo { /** replace contents with @p other, or prefix of up to @p capacity - 1 chars **/ DString & assign(const DString & other); + ///@} + /** @defgroup dstring-general general methods **/ + ///@{ + + /** format string into this DString using printf-style formatting. + * Truncates if result exceeds capacity. + * @return number of characters written (excluding null terminator) + **/ + template + size_type sprintf(const char * fmt, Args&&... args) { + int n = std::snprintf(chars_, capacity_, fmt, std::forward(args)...); + if (n < 0) { + size_ = 0; + chars_[0] = '\0'; + } else { + size_ = (n < static_cast(capacity_)) ? n : capacity_ - 1; + } + return size_; + } // TODO - behave like std::string, to the extent feasible // insert diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index b5f70f17..213f5023 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -260,6 +260,38 @@ namespace xo { REQUIRE(copy->capacity() == src->capacity()); REQUIRE(std::strcmp(copy->chars(), src->chars()) == 0); } + + TEST_CASE("DString-sprintf", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::empty(alloc, 32); + + auto n = s->sprintf("hello %s %d", "world", 42); + + REQUIRE(n == 14); + REQUIRE(s->size() == 14); + REQUIRE(std::strcmp(s->chars(), "hello world 42") == 0); + } + + TEST_CASE("DString-sprintf-truncate", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s = DString::empty(alloc, 8); + + auto n = s->sprintf("hello world"); + + REQUIRE(n == 7); + REQUIRE(s->size() == 7); + REQUIRE(std::strcmp(s->chars(), "hello w") == 0); + } } /*namespace ut*/ } /*namespace xo*/ From e81c7fba77b8a82dc832852482e40771fd5a2c27 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 14 Jan 2026 16:49:01 -0500 Subject: [PATCH 050/176] xo-object2: + DString::snprintf --- include/xo/object2/DString.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index b7be7086..bf8f04f4 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -81,6 +81,24 @@ namespace xo { DString * s2); #endif + /** create string using printf-style formatting. + * Use memory from allocator @p mm with capacity @p cap. + * Truncates if result exceeds capacity. + * @return pointer to newly created DString + **/ + template + static DString * snprintf(obj mm, + size_type cap, + const char * fmt, + Args&&... args) + { + DString * result = DString::empty(mm, cap); + if (result) { + result->sprintf(fmt, std::forward(args)...); + } + return result; + } + ///@} /** @defgroup dstring-access access methods **/ ///@{ From bdef33083224f5f1fd7a52d63617a3a6891ab71b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 14 Jan 2026 17:08:17 -0500 Subject: [PATCH 051/176] xo-object2: expand Printable.test.cpp to exercise DString --- include/xo/object2/DString.hpp | 15 ++++++++++----- utest/Printable.test.cpp | 25 +++++++++++++++++++------ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index bf8f04f4..a029da3f 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -87,10 +87,10 @@ namespace xo { * @return pointer to newly created DString **/ template - static DString * snprintf(obj mm, - size_type cap, - const char * fmt, - Args&&... args) + static DString * printf(obj mm, + size_type cap, + const char * fmt, + Args&&... args) { DString * result = DString::empty(mm, cap); if (result) { @@ -148,7 +148,12 @@ namespace xo { **/ template size_type sprintf(const char * fmt, Args&&... args) { - int n = std::snprintf(chars_, capacity_, fmt, std::forward(args)...); + int n; + if constexpr (sizeof...(Args) == 0) { + n = std::snprintf(chars_, capacity_, "%s", fmt); + } else { + n = std::snprintf(chars_, capacity_, fmt, std::forward(args)...); + } if (n < 0) { size_ = 0; chars_[0] = '\0'; diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index c1b63dc4..f61e06aa 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -12,6 +12,10 @@ #include #include +#include +#include +#include + #include #include @@ -35,6 +39,7 @@ namespace ut { using xo::scm::ListOps; using xo::scm::DList; using xo::scm::DInteger; + using xo::scm::DString; using xo::mm::AAllocator; using xo::mm::ACollector; using xo::mm::AGCObject; @@ -70,10 +75,10 @@ namespace ut { std::vector s_testcase_v = { testcase_pp(16384, 8192, 0, "()"), - testcase_pp(16384, 8192, 1, "(1000)"), - testcase_pp(16384, 8192, 2, "(1000 1197)"), - testcase_pp(16384, 8192, 5, "(1000 1197 1394 1591 1788)"), - testcase_pp(16384, 8192, 10, "(1000 1197 1394 1591 1788 1985 2182 2379 2576 2773)"), + testcase_pp(16384, 8192, 1, "(01000)"), + testcase_pp(16384, 8192, 2, "(01000 1197)"), + testcase_pp(16384, 8192, 5, "(01000 1197 01394 1591 01788)"), + testcase_pp(16384, 8192, 10, "(01000 1197 01394 1591 01788 1985 02182 2379 02576 2773)"), testcase_pp(16384, 8192, 20, "(...)"), }; } @@ -117,9 +122,17 @@ namespace ut { c_o.add_gc_root(&l0_o); for(int ip1 = tc.list_.size(); ip1 > 0; --ip1) { - auto xi_o = DInteger::box(gc_o, tc.list_[ip1 - 1]); + obj elt; - l0_o = ListOps::cons(gc_o, xi_o, l0_o); + //elt = DInteger::box(gc_o, tc.list_[ip1 - 1]); + + if (ip1 % 2 == 0) { + elt = DInteger::box(gc_o, tc.list_[ip1 - 1]); + } else { + elt = obj(DString::printf(gc_o, 80, "%05d", tc.list_[ip1 - 1])); + } + + l0_o = ListOps::cons(gc_o, elt, l0_o); } // TODO: log_streambuf using DArena From 0a8f2c1cd9b55c0c1b3bdaf9f763009a997d3543 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 00:05:48 -0500 Subject: [PATCH 052/176] xo-facet xo-object2 : tidy: ISequence_DList -> list/ subdir --- CMakeLists.txt | 2 +- idl/ISequence_DList.json5 | 1 + idl/Sequence.json5 | 4 ++++ include/xo/object2/Sequence.hpp | 7 +++--- .../xo/object2/{ => list}/ISequence_DList.hpp | 12 ++++++---- include/xo/object2/sequence/ASequence.hpp | 18 +++++++++------ include/xo/object2/sequence/ISequence_Any.hpp | 18 +++++++-------- .../xo/object2/sequence/ISequence_Xfer.hpp | 19 +++++++++------- include/xo/object2/sequence/RSequence.hpp | 22 ++++++++++--------- src/object2/ISequence_Any.cpp | 5 ++++- src/object2/ISequence_DList.cpp | 5 ++--- 11 files changed, 67 insertions(+), 46 deletions(-) rename include/xo/object2/{ => list}/ISequence_DList.hpp (80%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19a59363..b0141c62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ xo_add_genfacetimpl( REPR List INPUT idl/ISequence_DList.json5 OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR sequence + OUTPUT_IMPL_SUBDIR list OUTPUT_CPP_DIR src/object2 ) diff --git a/idl/ISequence_DList.json5 b/idl/ISequence_DList.json5 index 999fb482..8edbd16a 100644 --- a/idl/ISequence_DList.json5 +++ b/idl/ISequence_DList.json5 @@ -1,6 +1,7 @@ { mode: "implementation", includes: [ "" ], + local_types: [ ], namespace1: "xo", namespace2: "scm", facet_idl: "idl/Sequence.json5", diff --git a/idl/Sequence.json5 b/idl/Sequence.json5 index 2ee1a204..9ceda9ea 100644 --- a/idl/Sequence.json5 +++ b/idl/Sequence.json5 @@ -1,8 +1,12 @@ { mode: "facet", includes: [""], + // extra includes in Sequence.hpp, if any + user_hpp_includes: [], namespace1: "xo", namespace2: "scm", + // text after includes, before ASequence + pretext: [ "// {pretext} here" ], facet: "Sequence", detail_subdir: "sequence", brief: "an ordered collection of variants", diff --git a/include/xo/object2/Sequence.hpp b/include/xo/object2/Sequence.hpp index 22f67397..fc934084 100644 --- a/include/xo/object2/Sequence.hpp +++ b/include/xo/object2/Sequence.hpp @@ -2,13 +2,13 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: - * --input [./idl/Sequence.json5] + * --input [idl/Sequence.json5] * 2. jinja2 template for facet .hpp file: * [facet.hpp.j2] * 3. idl for facet methods - * [./idl/Sequence.json5] + * [idl/Sequence.json5] **/ #pragma once @@ -18,4 +18,5 @@ #include "sequence/ISequence_Xfer.hpp" #include "sequence/RSequence.hpp" + /* end Sequence.hpp */ \ No newline at end of file diff --git a/include/xo/object2/ISequence_DList.hpp b/include/xo/object2/list/ISequence_DList.hpp similarity index 80% rename from include/xo/object2/ISequence_DList.hpp rename to include/xo/object2/list/ISequence_DList.hpp index 5f67a3ff..81289db9 100644 --- a/include/xo/object2/ISequence_DList.hpp +++ b/include/xo/object2/list/ISequence_DList.hpp @@ -6,7 +6,7 @@ * arguments: * --input [idl/ISequence_DList.json5] * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] + * [iface_facet_repr.hpp.j2] * 3. idl for facet methods * [idl/ISequence_DList.json5] **/ @@ -14,7 +14,7 @@ #pragma once #include "Sequence.hpp" -#include "sequence/ISequence_Xfer.hpp" +#include #include "DList.hpp" namespace xo { namespace scm { class ISequence_DList; } } @@ -40,11 +40,14 @@ namespace xo { public: /** @defgroup scm-sequence-dlist-type-traits **/ ///@{ - using size_type = ASequence::size_type; - using AGCObject = ASequence::AGCObject; + using size_type = xo::scm::ASequence::size_type; + using AGCObject = xo::scm::ASequence::AGCObject; + using Copaque = xo::scm::ASequence::Copaque; + using Opaque = xo::scm::ASequence::Opaque; ///@} /** @defgroup scm-sequence-dlist-methods **/ ///@{ + // const methods /** true iff sequence is empty **/ static bool is_empty(const DList & self) noexcept; /** true iff sequence is finite **/ @@ -52,6 +55,7 @@ namespace xo { /** return element @p index of this sequence **/ static obj at(const DList & self, size_type index); + // non-const methods ///@} }; diff --git a/include/xo/object2/sequence/ASequence.hpp b/include/xo/object2/sequence/ASequence.hpp index 301d5be8..99687473 100644 --- a/include/xo/object2/sequence/ASequence.hpp +++ b/include/xo/object2/sequence/ASequence.hpp @@ -2,13 +2,13 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: - * --input [./idl/Sequence.json5] + * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: * [abstract_facet.hpp.j2] * 3. idl for facet methods - * [./idl/Sequence.json5] + * [idl/Sequence.json5] **/ #pragma once @@ -19,6 +19,8 @@ #include #include +// {pretext} here + namespace xo { namespace scm { @@ -36,6 +38,8 @@ public: // types /** integer identifying a type **/ using typeseq = xo::facet::typeseq; + using Copaque = const void *; + using Opaque = void *; /** type for length of a sequence **/ using size_type = std::size_t; /** facet for types with GC support **/ @@ -48,11 +52,11 @@ public: /** RTTI: unique id# for actual runtime data representation **/ virtual typeseq _typeseq() const noexcept = 0; /** true iff sequence is empty **/ - virtual bool is_empty(Copaque data) const noexcept = 0; + virtual bool is_empty(Copaque data) const noexcept = 0; /** true iff sequence is finite **/ - virtual bool is_finite(Copaque data) const noexcept = 0; + virtual bool is_finite(Copaque data) const noexcept = 0; /** return element @p index of this sequence **/ - virtual obj at(Copaque data, size_type index) const = 0; + virtual obj at(Copaque data, size_type index) const = 0; // nonconst methods ///@} @@ -74,4 +78,4 @@ using ISequence_ImplType = xo::facet::FacetImplType; } /*namespace scm*/ } /*namespace xo*/ -/* */ +/* ASequence.hpp */ \ No newline at end of file diff --git a/include/xo/object2/sequence/ISequence_Any.hpp b/include/xo/object2/sequence/ISequence_Any.hpp index dc9d73fc..9f5901f2 100644 --- a/include/xo/object2/sequence/ISequence_Any.hpp +++ b/include/xo/object2/sequence/ISequence_Any.hpp @@ -2,19 +2,18 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: - * --input [./idl/Sequence.json5] + * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: * [iface_facet_any.hpp.j2] * 3. idl for facet methods - * [./idl/Sequence.json5] + * [idl/Sequence.json5] **/ #pragma once #include "ASequence.hpp" -#include #include namespace xo { namespace scm { class ISequence_Any; } } @@ -43,6 +42,7 @@ namespace scm { /** @defgroup scm-sequence-any-type-traits **/ ///@{ + /** integer identifying a type **/ using typeseq = xo::facet::typeseq; using size_type = ASequence::size_type; using AGCObject = ASequence::AGCObject; @@ -57,16 +57,16 @@ namespace scm { // const methods typeseq _typeseq() const noexcept override { return s_typeseq; } - [[noreturn]] bool is_empty(Copaque) const noexcept override { _fatal(); } - [[noreturn]] bool is_finite(Copaque) const noexcept override { _fatal(); } - [[noreturn]] obj at(Copaque, size_type) const override { _fatal(); } + [[noreturn]] bool is_empty(Copaque) const noexcept override { _fatal(); } + [[noreturn]] bool is_finite(Copaque) const noexcept override { _fatal(); } + [[noreturn]] obj at(Copaque, size_type) const override { _fatal(); } // nonconst methods ///@} private: - /** @defgroup scm-sequence-any-private-methods **/ + /** @defgraoup scm-sequence-any-private-methods **/ ///@{ [[noreturn]] static void _fatal(); @@ -86,4 +86,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo */ -/* ISequence_Any.hpp */ +/* ISequence_Any.hpp */ \ No newline at end of file diff --git a/include/xo/object2/sequence/ISequence_Xfer.hpp b/include/xo/object2/sequence/ISequence_Xfer.hpp index 3bcad3d8..60abc5aa 100644 --- a/include/xo/object2/sequence/ISequence_Xfer.hpp +++ b/include/xo/object2/sequence/ISequence_Xfer.hpp @@ -2,18 +2,18 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: - * --input [./idl/Sequence.json5] + * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: * [iface_facet_any.hpp.j2] * 3. idl for facet methods - * [./idl/Sequence.json5] + * [idl/Sequence.json5] **/ #pragma once -#include "ASequence.hpp" +#include namespace xo { namespace scm { @@ -24,7 +24,10 @@ namespace scm { public: /** @defgroup scm-sequence-xfer-type-traits **/ ///@{ + /** actual implementation (not generated; often delegates to DRepr) **/ using Impl = ISequence_DRepr; + /** integer identifying a type **/ + using typeseq = ASequence::typeseq; using size_type = ASequence::size_type; using AGCObject = ASequence::AGCObject; ///@} @@ -39,13 +42,13 @@ namespace scm { // const methods typeseq _typeseq() const noexcept override { return s_typeseq; } - bool is_empty(Copaque data) const noexcept override { + bool is_empty(Copaque data) const noexcept override { return I::is_empty(_dcast(data)); } - bool is_finite(Copaque data) const noexcept override { + bool is_finite(Copaque data) const noexcept override { return I::is_finite(_dcast(data)); } - obj at(Copaque data, size_type index) const override { + obj at(Copaque data, size_type index) const override { return I::at(_dcast(data), index); } @@ -82,4 +85,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo*/ -/* end ISequence_Xfer.hpp */ +/* end ISequence_Xfer.hpp */ \ No newline at end of file diff --git a/include/xo/object2/sequence/RSequence.hpp b/include/xo/object2/sequence/RSequence.hpp index a63ca8a0..26ec1735 100644 --- a/include/xo/object2/sequence/RSequence.hpp +++ b/include/xo/object2/sequence/RSequence.hpp @@ -2,13 +2,13 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: - * --input [./idl/Sequence.json5] + * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: * [iface_facet_any.hpp.j2] * 3. idl for facet methods - * [./idl/Sequence.json5] + * [idl/Sequence.json5] **/ #pragma once @@ -30,6 +30,7 @@ public: ///@{ using ObjectType = Object; using DataPtr = Object::DataPtr; + using typeseq = xo::reflect::typeseq; using size_type = ASequence::size_type; using AGCObject = ASequence::AGCObject; ///@} @@ -38,26 +39,27 @@ public: ///@{ RSequence() {} RSequence(Object::DataPtr data) : Object{std::move(data)} {} + RSequence(const ASequence * iface, void * data) + requires std::is_same_v + : Object(iface, data) {} ///@} /** @defgroup scm-sequence-router-methods **/ ///@{ // const methods - int32_t _typeseq() const noexcept { return O::iface()->_typeseq(); } - bool is_empty() const noexcept override { + typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + bool is_empty() const noexcept { return O::iface()->is_empty(O::data()); } - bool is_finite() const noexcept override { + bool is_finite() const noexcept { return O::iface()->is_finite(O::data()); } - obj at(size_type index) const override { + obj at(size_type index) const { return O::iface()->at(O::data(), index); } - // non-const methods - // << do something for non-const methods >> - // + // non-const methods (still const in router!) ///@} /** @defgroup scm-sequence-member-vars **/ diff --git a/src/object2/ISequence_Any.cpp b/src/object2/ISequence_Any.cpp index a7781e97..8461d750 100644 --- a/src/object2/ISequence_Any.cpp +++ b/src/object2/ISequence_Any.cpp @@ -32,7 +32,10 @@ bool ISequence_Any::_valid = valid_facet_implementation(); +// nonconst methods + + } /*namespace scm*/ } /*namespace xo*/ -/* end ISequence_Any.cpp */ +/* end ISequence_Any.cpp */ \ No newline at end of file diff --git a/src/object2/ISequence_DList.cpp b/src/object2/ISequence_DList.cpp index 71dcf744..b216b7e5 100644 --- a/src/object2/ISequence_DList.cpp +++ b/src/object2/ISequence_DList.cpp @@ -11,8 +11,7 @@ * [idl/ISequence_DList.json5] **/ -#include "IGCObject_DList.hpp" // apparently need this with clang 15 -#include "ISequence_DList.hpp" +#include "list/ISequence_DList.hpp" namespace xo { namespace scm { @@ -38,4 +37,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end ISequence_DList.cpp */ +/* end ISequence_DList.cpp */ \ No newline at end of file From e6d1e935a520c4825f4cccf1bdc083d788a76e74 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 00:13:27 -0500 Subject: [PATCH 053/176] xo-object2: tidy: IPrintable_DList -> list/ subdir --- CMakeLists.txt | 24 +++++++++---------- idl/IPrintable_DList.json5 | 1 + idl/ISequence_DList.json5 | 3 +-- .../object2/{ => list}/IPrintable_DList.hpp | 11 ++++++--- src/object2/DList.cpp | 2 +- src/object2/IPrintable_DList.cpp | 7 +++--- src/object2/object2_register_facets.cpp | 2 +- src/object2/object2_register_types.cpp | 2 +- utest/Printable.test.cpp | 2 +- 9 files changed, 29 insertions(+), 25 deletions(-) rename include/xo/object2/{ => list}/IPrintable_DList.hpp (81%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0141c62..81000f8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,18 +40,6 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) -# note: manual target; generated code committed to git -xo_add_genfacetimpl( - TARGET xo-object2-facetimpl-printable-float - FACET_PKG xo_printable2 - FACET Printable - REPR Float - INPUT idl/IPrintable_DFloat.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR . - OUTPUT_CPP_DIR src/object2 -) - # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-list @@ -60,6 +48,18 @@ xo_add_genfacetimpl( REPR List INPUT idl/IPrintable_DList.json5 OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR list + OUTPUT_CPP_DIR src/object2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-float + FACET_PKG xo_printable2 + FACET Printable + REPR Float + INPUT idl/IPrintable_DFloat.json5 + OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR . OUTPUT_CPP_DIR src/object2 ) diff --git a/idl/IPrintable_DList.json5 b/idl/IPrintable_DList.json5 index 478ce7c2..640d7d1d 100644 --- a/idl/IPrintable_DList.json5 +++ b/idl/IPrintable_DList.json5 @@ -2,6 +2,7 @@ mode: "implementation", includes: [ "", "" ], + local_types: [ ], namespace1: "xo", namespace2: "scm", facet_idl: "idl/Printable.json5", diff --git a/idl/ISequence_DList.json5 b/idl/ISequence_DList.json5 index 8edbd16a..677285da 100644 --- a/idl/ISequence_DList.json5 +++ b/idl/ISequence_DList.json5 @@ -8,6 +8,5 @@ brief: "provide ASequence interface for DList state", using_doxygen: true, repr: "DList", - doc: [ "doc for something or other" - ], + doc: [ "implement ASequence for DList" ], } \ No newline at end of file diff --git a/include/xo/object2/IPrintable_DList.hpp b/include/xo/object2/list/IPrintable_DList.hpp similarity index 81% rename from include/xo/object2/IPrintable_DList.hpp rename to include/xo/object2/list/IPrintable_DList.hpp index ac4c5315..4371fdfb 100644 --- a/include/xo/object2/IPrintable_DList.hpp +++ b/include/xo/object2/list/IPrintable_DList.hpp @@ -2,17 +2,18 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DList.json5] * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] + * [iface_facet_repr.hpp.j2] * 3. idl for facet methods * [idl/IPrintable_DList.json5] **/ #pragma once +#include "Printable.hpp" #include #include #include "DList.hpp" @@ -41,17 +42,21 @@ namespace xo { /** @defgroup scm-printable-dlist-type-traits **/ ///@{ using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; ///@} /** @defgroup scm-printable-dlist-methods **/ ///@{ + // const methods /** Pretty-printing support for this object. See [xo-indentlog/xo/indentlog/pretty.hpp] **/ static bool pretty(const DList & self, const ppindentinfo & ppii); + // non-const methods ///@} }; } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 19e09e11..ccd5193c 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -4,7 +4,7 @@ **/ #include "DList.hpp" -#include "IPrintable_DList.hpp" +#include "list/IPrintable_DList.hpp" #include #include #include diff --git a/src/object2/IPrintable_DList.cpp b/src/object2/IPrintable_DList.cpp index bdcf6694..384d8b60 100644 --- a/src/object2/IPrintable_DList.cpp +++ b/src/object2/IPrintable_DList.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DList.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -11,8 +11,7 @@ * [idl/IPrintable_DList.json5] **/ -#include "IPrintable_DList.hpp" -#include +#include "list/IPrintable_DList.hpp" namespace xo { namespace scm { @@ -26,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DList.cpp */ +/* end IPrintable_DList.cpp */ \ No newline at end of file diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 9cf67988..704af85f 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index b8b68756..ff2c6eb9 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -10,7 +10,7 @@ #include "IGCObject_DInteger.hpp" #include "string/IGCObject_DString.hpp" -#include "IPrintable_DList.hpp" +#include "list/IPrintable_DList.hpp" //#include "IPrintable_DFloat.hpp" #include "IPrintable_DInteger.hpp" diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index f61e06aa..45e824e0 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include From 503fd41c782f596ba3ff6fcfcc7f33d35520eab9 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 00:32:50 -0500 Subject: [PATCH 054/176] xo-object2: tidy IGCObject_DList --- CMakeLists.txt | 12 ++++ idl/IGCObject_DList.json5 | 15 +++++ include/xo/object2/DList.hpp | 7 +++ include/xo/object2/IGCObject_DList.hpp | 47 --------------- include/xo/object2/ListOps.hpp | 2 +- include/xo/object2/list/IGCObject_DList.hpp | 65 +++++++++++++++++++++ src/object2/DList.cpp | 32 ++++++++++ src/object2/IGCObject_DList.cpp | 58 +++++++----------- src/object2/object2_register_facets.cpp | 2 +- src/object2/object2_register_types.cpp | 2 +- utest/Printable.test.cpp | 2 +- utest/X1Collector.test.cpp | 2 +- 12 files changed, 158 insertions(+), 88 deletions(-) create mode 100644 idl/IGCObject_DList.json5 delete mode 100644 include/xo/object2/IGCObject_DList.hpp create mode 100644 include/xo/object2/list/IGCObject_DList.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 81000f8d..53046556 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-gcobject-list + FACET_PKG xo_gc + FACET GCObject + REPR List + INPUT idl/IGCObject_DList.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR list + OUTPUT_CPP_DIR src/object2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-float diff --git a/idl/IGCObject_DList.json5 b/idl/IGCObject_DList.json5 new file mode 100644 index 00000000..342fc299 --- /dev/null +++ b/idl/IGCObject_DList.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ +// "", +// "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DList", + using_doxygen: true, + repr: "DList", + doc: [ "implement AGCObject for DList" ], +} diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index eecb4310..611fb664 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -19,6 +19,7 @@ namespace xo { using size_type = std::size_t; using AGCObject = xo::mm::AGCObject; using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; using ppindentinfo = xo::print::ppindentinfo; public: @@ -51,6 +52,12 @@ namespace xo { /** pretty-printing driver; combine layout+printing **/ bool pretty(const ppindentinfo & ppii) const; + // GCObject facet + + size_type shallow_size() const noexcept; + DList * shallow_copy(obj mm) const noexcept; + size_type forward_children(obj gc) noexcept; + /** first member of list **/ obj head_; /** remainder of list **/ diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp deleted file mode 100644 index eba4a7d1..00000000 --- a/include/xo/object2/IGCObject_DList.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/** @file IGCObject_DList.hpp - * - * @author Roland Conybeare, Dec 2025 - **/ - -#pragma once - -#include -#include -#include -#include -//#include "DList.hpp" // circular - -namespace xo { - namespace scm { struct IGCObject_DList; } - namespace scm { struct DList; } - - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::mm::IGCObject_Xfer - ; - }; - } - - namespace scm { - /* changes here coordinate with: - * IGCObject_XFer - */ - struct IGCObject_DList { - public: - using AAllocator = xo::mm::AAllocator; - using ACollector = xo::mm::ACollector; - using size_type = std::size_t; - - static size_type shallow_size(const DList & d) noexcept; - static DList * shallow_copy(const DList & d, obj mm) noexcept; - static size_type forward_children(DList & d, obj gc) noexcept; - }; - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IGCObject_DList.hpp */ diff --git a/include/xo/object2/ListOps.hpp b/include/xo/object2/ListOps.hpp index 90041cac..98161116 100644 --- a/include/xo/object2/ListOps.hpp +++ b/include/xo/object2/ListOps.hpp @@ -5,7 +5,7 @@ #pragma once -#include "IGCObject_DList.hpp" +#include "list/IGCObject_DList.hpp" #include "DList.hpp" namespace xo { diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp new file mode 100644 index 00000000..e87cdd96 --- /dev/null +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -0,0 +1,65 @@ +/** @file IGCObject_DList.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DList.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DList.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include "DList.hpp" + +namespace xo { namespace scm { class IGCObject_DList; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DList + **/ + class IGCObject_DList { + public: + /** @defgroup scm-gcobject-dlist-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dlist-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DList & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DList & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DList & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index ccd5193c..769ef1e3 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -5,9 +5,11 @@ #include "DList.hpp" #include "list/IPrintable_DList.hpp" +#include "list/IGCObject_DList.hpp" #include #include #include +#include #include #include @@ -145,6 +147,36 @@ namespace xo { return false; } } + + auto + DList::shallow_size() const noexcept -> size_type + { + return sizeof(DList); + } + + DList * + DList::shallow_copy(obj mm) const noexcept + { + DList * copy = (DList *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + auto + DList::forward_children(obj gc) noexcept -> size_type + { + scope log(XO_DEBUG(true)); + + gc.forward_inplace(head_.iface(), (void **)&(head_.data_)); + + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&rest_)); + + return shallow_size(); + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 4266075d..06584687 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -1,53 +1,39 @@ /** @file IGCObject_DList.cpp * - * @author Roland Conybeare, Dec 2025 - **/ + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DList.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DList.json5] +**/ -#include "IGCObject_DList.hpp" -#include "DList.hpp" -#include +#include "list/IGCObject_DList.hpp" namespace xo { - using xo::mm::AGCObject; - using xo::mm::AAllocator; - //using xo::facet::with_facet; - using xo::facet::obj; - using xo::facet::typeseq; - using std::size_t; - namespace scm { - size_t - IGCObject_DList::shallow_size(const DList &) noexcept + auto + IGCObject_DList::shallow_size(const DList & self) noexcept -> size_type { - return sizeof(DList); + return self.shallow_size(); } - DList * - IGCObject_DList::shallow_copy(const DList & src, - obj mm) noexcept + auto + IGCObject_DList::shallow_copy(const DList & self, obj mm) noexcept -> Opaque { - DList * copy = (DList *)mm.alloc_copy((std::byte *)&src); - - if (copy) - *copy = src; - - return copy; + return self.shallow_copy(mm); } - size_t - IGCObject_DList::forward_children(DList & src, - obj gc) noexcept + auto + IGCObject_DList::forward_children(DList & self, obj gc) noexcept -> size_type { - scope log(XO_DEBUG(true)); - - gc.forward_inplace(src.head_.iface(), (void **)&(src.head_.data_)); - - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&src.rest_)); - - return shallow_size(src); + return self.forward_children(gc); } + } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DList.cpp */ +/* end IGCObject_DList.cpp */ \ No newline at end of file diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 704af85f..b9a8d3ac 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -5,7 +5,7 @@ #include "object2_register_facets.hpp" -#include +#include #include #include #include diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index ff2c6eb9..a7e95da2 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -5,7 +5,7 @@ #include "object2_register_types.hpp" -#include "IGCObject_DList.hpp" +#include "list/IGCObject_DList.hpp" #include "IGCObject_DFloat.hpp" #include "IGCObject_DInteger.hpp" #include "string/IGCObject_DString.hpp" diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index 45e824e0..76a2b17a 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -9,7 +9,7 @@ #include "object2_register_facets.hpp" #include -#include +#include #include #include diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 2ad93810..f100f38e 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -9,7 +9,7 @@ #include "object2_register_types.hpp" #include "IGCObject_DFloat.hpp" -#include "IGCObject_DList.hpp" +#include "list/IGCObject_DList.hpp" #include #include From 9244302cc1a4de4e9f07717773c2d052c64ae82b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 00:46:39 -0500 Subject: [PATCH 055/176] xo-object2: streamline GCObject_DFloat + codegen --- CMakeLists.txt | 12 ++++ idl/IGCObject_DFloat.json5 | 15 +++++ include/xo/object2/DFloat.hpp | 9 ++- include/xo/object2/IGCObject_DFloat.hpp | 45 ------------- .../xo/object2/number/IGCObject_DFloat.hpp | 67 +++++++++++++++++++ src/object2/DFloat.cpp | 25 +++++++ src/object2/IGCObject_DFloat.cpp | 49 ++++++-------- src/object2/object2_register_facets.cpp | 2 +- src/object2/object2_register_types.cpp | 2 +- utest/X1Collector.test.cpp | 2 +- 10 files changed, 151 insertions(+), 77 deletions(-) create mode 100644 idl/IGCObject_DFloat.json5 delete mode 100644 include/xo/object2/IGCObject_DFloat.hpp create mode 100644 include/xo/object2/number/IGCObject_DFloat.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 53046556..ff21115c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-gcobject-float + FACET_PKG xo_gc + FACET GCObject + REPR Float + INPUT idl/IGCObject_DFloat.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR number + OUTPUT_CPP_DIR src/object2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-string diff --git a/idl/IGCObject_DFloat.json5 b/idl/IGCObject_DFloat.json5 new file mode 100644 index 00000000..6120808b --- /dev/null +++ b/idl/IGCObject_DFloat.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DFloat", + using_doxygen: true, + repr: "DFloat", + doc: [ "implement AGCObject for DFloat" ], +} diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index ab38d078..a46a990d 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -6,6 +6,7 @@ #pragma once #include +#include #include #include @@ -13,6 +14,7 @@ namespace xo { namespace scm { struct DFloat { using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; using ppindentinfo = xo::print::ppindentinfo; using value_type = double; @@ -27,9 +29,14 @@ namespace xo { double value() const noexcept { return value_; } + operator double() const noexcept { return value_; } + bool pretty(const ppindentinfo & ppii) const; - operator double() const noexcept { return value_; } + // GCObject facet + std::size_t shallow_size() const noexcept; + DFloat * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/IGCObject_DFloat.hpp b/include/xo/object2/IGCObject_DFloat.hpp deleted file mode 100644 index 58b931bc..00000000 --- a/include/xo/object2/IGCObject_DFloat.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/** @file IGCObject_DFloat.hpp - * - * @author Roland Conybeare, Dec 2025 - **/ - -#pragma once - -#include -#include -#include -#include -#include "DFloat.hpp" - -namespace xo { - namespace scm { struct IGCObject_DFloat; } - - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::mm::IGCObject_Xfer - ; - }; - } - - namespace scm { - /* changes here coordinate with: - * IGCObject_Xfer - */ - struct IGCObject_DFloat { - public: - using AAllocator = xo::mm::AAllocator; - using ACollector = xo::mm::ACollector; - using size_type = std::size_t; - - static size_type shallow_size(const DFloat & d) noexcept; - static DFloat * shallow_copy(const DFloat & d, obj mm) noexcept; - static size_type forward_children(DFloat & d, obj gc) noexcept; - }; - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IGCObject_DFloat.hpp */ diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp new file mode 100644 index 00000000..c57c89ea --- /dev/null +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DFloat.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DFloat.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DFloat.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DFloat.hpp" + +namespace xo { namespace scm { class IGCObject_DFloat; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DFloat + **/ + class IGCObject_DFloat { + public: + /** @defgroup scm-gcobject-dfloat-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dfloat-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DFloat & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DFloat & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DFloat & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index 52940efe..7fc0bfbf 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -9,6 +9,7 @@ namespace xo { using xo::facet::typeseq; using xo::print::ppdetail_atomic; + using std::size_t; namespace scm { DFloat * @@ -25,6 +26,30 @@ namespace xo { { return ppdetail_atomic::print_pretty(ppii, value_); } + + size_t + DFloat::shallow_size() const noexcept + { + return sizeof(DFloat); + } + + DFloat * + DFloat::shallow_copy(obj mm) const noexcept + { + DFloat * copy = (DFloat *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + size_t + DFloat::forward_children(obj) noexcept + { + return shallow_size(); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index be4849ac..ef4214a7 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -1,46 +1,39 @@ /** @file IGCObject_DFloat.cpp * - * @author Roland Conybeare, Dec 2025 - **/ + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DFloat.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DFloat.json5] +**/ -#include "IGCObject_DFloat.hpp" -#include "xo/alloc2/alloc/AAllocator.hpp" -#include "xo/facet/obj.hpp" -#include +#include "number/IGCObject_DFloat.hpp" namespace xo { - using xo::mm::AAllocator; - using xo::facet::obj; - using xo::facet::typeseq; - using std::size_t; - namespace scm { - size_t - IGCObject_DFloat::shallow_size(const DFloat &) noexcept + auto + IGCObject_DFloat::shallow_size(const DFloat & self) noexcept -> size_type { - return sizeof(DFloat); + return self.shallow_size(); } - DFloat * - IGCObject_DFloat::shallow_copy(const DFloat & src, - obj mm) noexcept + auto + IGCObject_DFloat::shallow_copy(const DFloat & self, obj mm) noexcept -> Opaque { - DFloat * copy = (DFloat *)mm.alloc_copy((std::byte *)&src); - - if (copy) - *copy = src; - - return copy; + return self.shallow_copy(mm); } - size_t - IGCObject_DFloat::forward_children(DFloat & src, - obj) noexcept + auto + IGCObject_DFloat::forward_children(DFloat & self, obj gc) noexcept -> size_type { - return shallow_size(src); + return self.forward_children(gc); } } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DFloat.cpp */ +/* end IGCObject_DFloat.cpp */ \ No newline at end of file diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index b9a8d3ac..efbb2a08 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -6,7 +6,7 @@ #include "object2_register_facets.hpp" #include -#include +#include #include #include diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index a7e95da2..9c6a9196 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -6,7 +6,7 @@ #include "object2_register_types.hpp" #include "list/IGCObject_DList.hpp" -#include "IGCObject_DFloat.hpp" +#include "number/IGCObject_DFloat.hpp" #include "IGCObject_DInteger.hpp" #include "string/IGCObject_DString.hpp" diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index f100f38e..330db905 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -8,7 +8,7 @@ #include "DList.hpp" #include "object2_register_types.hpp" -#include "IGCObject_DFloat.hpp" +#include "number/IGCObject_DFloat.hpp" #include "list/IGCObject_DList.hpp" #include From 028dea804754a1f08d7656cff8e3f6465324a159 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 00:50:12 -0500 Subject: [PATCH 056/176] xo-object2: streamline IPrintable_DFloat + codegen --- CMakeLists.txt | 2 +- idl/IPrintable_DFloat.json5 | 1 + include/xo/object2/{ => number}/IPrintable_DFloat.hpp | 9 +++++++-- src/object2/IPrintable_DFloat.cpp | 4 ++-- src/object2/object2_register_facets.cpp | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) rename include/xo/object2/{ => number}/IPrintable_DFloat.hpp (82%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff21115c..396bac1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,7 @@ xo_add_genfacetimpl( REPR Float INPUT idl/IPrintable_DFloat.json5 OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR . + OUTPUT_IMPL_SUBDIR number OUTPUT_CPP_DIR src/object2 ) diff --git a/idl/IPrintable_DFloat.json5 b/idl/IPrintable_DFloat.json5 index 10673d3f..7351c1b2 100644 --- a/idl/IPrintable_DFloat.json5 +++ b/idl/IPrintable_DFloat.json5 @@ -2,6 +2,7 @@ mode: "implementation", includes: [ "", "" ], + local_types: [ ], namespace1: "xo", namespace2: "scm", facet_idl: "idl/Printable.json5", diff --git a/include/xo/object2/IPrintable_DFloat.hpp b/include/xo/object2/number/IPrintable_DFloat.hpp similarity index 82% rename from include/xo/object2/IPrintable_DFloat.hpp rename to include/xo/object2/number/IPrintable_DFloat.hpp index 0ac94b9f..17eab5d2 100644 --- a/include/xo/object2/IPrintable_DFloat.hpp +++ b/include/xo/object2/number/IPrintable_DFloat.hpp @@ -2,17 +2,18 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] + * [iface_facet_repr.hpp.j2] * 3. idl for facet methods * [idl/IPrintable_DFloat.json5] **/ #pragma once +#include "Printable.hpp" #include #include #include "DFloat.hpp" @@ -41,13 +42,17 @@ namespace xo { /** @defgroup scm-printable-dfloat-type-traits **/ ///@{ using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; ///@} /** @defgroup scm-printable-dfloat-methods **/ ///@{ + // const methods /** Pretty-printing support for this object. See [xo-indentlog/xo/indentlog/pretty.hpp] **/ static bool pretty(const DFloat & self, const ppindentinfo & ppii); + // non-const methods ///@} }; diff --git a/src/object2/IPrintable_DFloat.cpp b/src/object2/IPrintable_DFloat.cpp index b459e384..b83613e5 100644 --- a/src/object2/IPrintable_DFloat.cpp +++ b/src/object2/IPrintable_DFloat.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -11,7 +11,7 @@ * [idl/IPrintable_DFloat.json5] **/ -#include "IPrintable_DFloat.hpp" +#include "number/IPrintable_DFloat.hpp" namespace xo { namespace scm { diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index efbb2a08..94de94c6 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include From 5e6db993ee7204404efc40b3f56230c34e665c8d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 00:58:55 -0500 Subject: [PATCH 057/176] xo-object2: tidy IGCObject_DInteger + codegen --- CMakeLists.txt | 12 ++++ idl/IGCObject_DInteger.json5 | 15 +++++ include/xo/object2/DInteger.hpp | 8 +++ include/xo/object2/IGCObject_DInteger.hpp | 45 ------------- .../xo/object2/number/IGCObject_DInteger.hpp | 67 +++++++++++++++++++ src/object2/DInteger.cpp | 25 +++++++ src/object2/IGCObject_DInteger.cpp | 49 ++++++-------- src/object2/object2_register_facets.cpp | 2 +- src/object2/object2_register_types.cpp | 2 +- utest/Printable.test.cpp | 2 +- 10 files changed, 151 insertions(+), 76 deletions(-) create mode 100644 idl/IGCObject_DInteger.json5 delete mode 100644 include/xo/object2/IGCObject_DInteger.hpp create mode 100644 include/xo/object2/number/IGCObject_DInteger.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 396bac1a..a07933af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-gcobject-integer + FACET_PKG xo_gc + FACET GCObject + REPR Integer + INPUT idl/IGCObject_DInteger.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR number + OUTPUT_CPP_DIR src/object2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-string diff --git a/idl/IGCObject_DInteger.json5 b/idl/IGCObject_DInteger.json5 new file mode 100644 index 00000000..65f24371 --- /dev/null +++ b/idl/IGCObject_DInteger.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DInteger", + using_doxygen: true, + repr: "DInteger", + doc: [ "implement AGCObject for DInteger" ], +} diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index 8cb109f4..c56a4be1 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -5,6 +5,7 @@ #pragma once +#include #include #include #include @@ -14,6 +15,7 @@ namespace xo { namespace scm { struct DInteger { using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; using ppindentinfo = xo::print::ppindentinfo; using value_type = long; @@ -32,6 +34,12 @@ namespace xo { operator long() const noexcept { return value_; } + // GCObject facet + + std::size_t shallow_size() const noexcept; + DInteger * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + private: /** boxed integer value **/ long value_; diff --git a/include/xo/object2/IGCObject_DInteger.hpp b/include/xo/object2/IGCObject_DInteger.hpp deleted file mode 100644 index b3061980..00000000 --- a/include/xo/object2/IGCObject_DInteger.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/** @file IGCObject_DInteger.hpp - * - * @author Roland Conybeare, Dec 2025 - **/ - -#pragma once - -#include -#include "xo/alloc2/alloc/AAllocator.hpp" -#include -#include -#include "DInteger.hpp" - -namespace xo { - namespace scm { struct IGCObject_DInteger; } - - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::mm::IGCObject_Xfer - ; - }; - } - - namespace scm { - /* changes here coordinate with: - * IGCObject_Xfer - */ - struct IGCObject_DInteger { - public: - using AAllocator = xo::mm::AAllocator; - using ACollector = xo::mm::ACollector; - using size_type = std::size_t; - - static size_type shallow_size(const DInteger & d) noexcept; - static DInteger * shallow_copy(const DInteger & d, obj mm) noexcept; - static size_type forward_children(DInteger & d, obj gc) noexcept; - }; - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IGCObject_DInteger.hpp */ diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp new file mode 100644 index 00000000..10a5c685 --- /dev/null +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DInteger.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DInteger.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DInteger.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DInteger.hpp" + +namespace xo { namespace scm { class IGCObject_DInteger; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DInteger + **/ + class IGCObject_DInteger { + public: + /** @defgroup scm-gcobject-dinteger-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dinteger-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DInteger & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DInteger & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DInteger & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 6c670ccd..284806d1 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -26,6 +26,31 @@ namespace xo { { return ppdetail_atomic::print_pretty(ppii, value_); } + + size_t + DInteger::shallow_size() const noexcept + { + return sizeof(DInteger); + } + + DInteger * + DInteger::shallow_copy(obj mm) const noexcept + { + DInteger * copy = (DInteger *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + size_t + DInteger::forward_children(obj) noexcept + { + return shallow_size(); + } + + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index cbc27f63..8b8a0112 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -1,46 +1,39 @@ /** @file IGCObject_DInteger.cpp * - * @author Roland Conybeare, Dec 2025 - **/ + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DInteger.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DInteger.json5] +**/ -#include "IGCObject_DInteger.hpp" -#include "xo/alloc2/alloc/AAllocator.hpp" -#include "xo/facet/obj.hpp" -#include +#include "number/IGCObject_DInteger.hpp" namespace xo { - using xo::mm::AAllocator; - using xo::facet::obj; - using xo::facet::typeseq; - using std::size_t; - namespace scm { - size_t - IGCObject_DInteger::shallow_size(const DInteger &) noexcept + auto + IGCObject_DInteger::shallow_size(const DInteger & self) noexcept -> size_type { - return sizeof(DInteger); + return self.shallow_size(); } - DInteger * - IGCObject_DInteger::shallow_copy(const DInteger & src, - obj mm) noexcept + auto + IGCObject_DInteger::shallow_copy(const DInteger & self, obj mm) noexcept -> Opaque { - DInteger * copy = (DInteger *)mm.alloc_copy((std::byte *)&src); - - if (copy) - *copy = src; - - return copy; + return self.shallow_copy(mm); } - size_t - IGCObject_DInteger::forward_children(DInteger & src, - obj) noexcept + auto + IGCObject_DInteger::forward_children(DInteger & self, obj gc) noexcept -> size_type { - return shallow_size(src); + return self.forward_children(gc); } } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DInteger.cpp */ +/* end IGCObject_DInteger.cpp */ \ No newline at end of file diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 94de94c6..0ea0db57 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index 9c6a9196..2c9de20b 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -7,7 +7,7 @@ #include "list/IGCObject_DList.hpp" #include "number/IGCObject_DFloat.hpp" -#include "IGCObject_DInteger.hpp" +#include "number/IGCObject_DInteger.hpp" #include "string/IGCObject_DString.hpp" #include "list/IPrintable_DList.hpp" diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index 76a2b17a..6c09ca90 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include From 287384e37ac9283ff6b006b196e2ca4b429c6fe1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 01:02:50 -0500 Subject: [PATCH 058/176] xo-object2: tidy IPrintable_DInteger + codegen --- CMakeLists.txt | 12 ++++++++++++ idl/IPrintable_DInteger.json5 | 13 +++++++++++++ .../xo/object2/{ => number}/IPrintable_DInteger.hpp | 12 +++++++++--- src/object2/IPrintable_DInteger.cpp | 6 +++--- src/object2/object2_register_facets.cpp | 2 +- src/object2/object2_register_types.cpp | 2 +- 6 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 idl/IPrintable_DInteger.json5 rename include/xo/object2/{ => number}/IPrintable_DInteger.hpp (79%) diff --git a/CMakeLists.txt b/CMakeLists.txt index a07933af..961c965a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-integer + FACET_PKG xo_printable2 + FACET Printable + REPR Integer + INPUT idl/IPrintable_DInteger.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR number + OUTPUT_CPP_DIR src/object2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-integer diff --git a/idl/IPrintable_DInteger.json5 b/idl/IPrintable_DInteger.json5 new file mode 100644 index 00000000..1a2e5490 --- /dev/null +++ b/idl/IPrintable_DInteger.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DInteger", + using_doxygen: true, + repr: "DInteger", + doc: [ "implement APrintable for DInteger" ], +} diff --git a/include/xo/object2/IPrintable_DInteger.hpp b/include/xo/object2/number/IPrintable_DInteger.hpp similarity index 79% rename from include/xo/object2/IPrintable_DInteger.hpp rename to include/xo/object2/number/IPrintable_DInteger.hpp index 60c9821c..95a9e108 100644 --- a/include/xo/object2/IPrintable_DInteger.hpp +++ b/include/xo/object2/number/IPrintable_DInteger.hpp @@ -2,18 +2,20 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DInteger.json5] * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] + * [iface_facet_repr.hpp.j2] * 3. idl for facet methods * [idl/IPrintable_DInteger.json5] **/ #pragma once +#include "Printable.hpp" #include +#include #include "DInteger.hpp" namespace xo { namespace scm { class IPrintable_DInteger; } } @@ -40,17 +42,21 @@ namespace xo { /** @defgroup scm-printable-dinteger-type-traits **/ ///@{ using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; ///@} /** @defgroup scm-printable-dinteger-methods **/ ///@{ + // const methods /** Pretty-printing support for this object. See [xo-indentlog/xo/indentlog/pretty.hpp] **/ static bool pretty(const DInteger & self, const ppindentinfo & ppii); + // non-const methods ///@} }; } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/src/object2/IPrintable_DInteger.cpp b/src/object2/IPrintable_DInteger.cpp index 8e9bc774..889cfa8c 100644 --- a/src/object2/IPrintable_DInteger.cpp +++ b/src/object2/IPrintable_DInteger.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DInteger.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -11,7 +11,7 @@ * [idl/IPrintable_DInteger.json5] **/ -#include "IPrintable_DInteger.hpp" +#include "number/IPrintable_DInteger.hpp" namespace xo { namespace scm { @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DInteger.cpp */ +/* end IPrintable_DInteger.cpp */ \ No newline at end of file diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 0ea0db57..8dcb2c11 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index 2c9de20b..e9695a37 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -12,7 +12,7 @@ #include "list/IPrintable_DList.hpp" //#include "IPrintable_DFloat.hpp" -#include "IPrintable_DInteger.hpp" +#include "number/IPrintable_DInteger.hpp" #include #include From f374e75f7b9f23ae11622234434c9555449a7972 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 10:46:38 -0500 Subject: [PATCH 059/176] xo-object2: + StringOps + utest --- include/xo/object2/StringOps.hpp | 36 +++++++++++++++++++++ utest/CMakeLists.txt | 1 + utest/DString.test.cpp | 2 +- utest/StringOps.test.cpp | 54 ++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 include/xo/object2/StringOps.hpp create mode 100644 utest/StringOps.test.cpp diff --git a/include/xo/object2/StringOps.hpp b/include/xo/object2/StringOps.hpp new file mode 100644 index 00000000..3cc71988 --- /dev/null +++ b/include/xo/object2/StringOps.hpp @@ -0,0 +1,36 @@ +/** @file StringOps.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "string/IGCObject_DString.hpp" +#include "DString.hpp" + +namespace xo { + namespace scm { + /** @brief string functions + * + * note: separate from DString + **/ + struct StringOps { + using AGCObject = xo::mm::AGCObject; + using AAllocator = xo::mm::AAllocator; + using size_type = DString::size_type; + + template + static obj empty(obj mm, + size_type cap); + }; + + template + obj + StringOps::empty(obj mm, size_type cap) + { + return obj(DString::empty(mm, cap)); + } + } +} + +/* end StringOps.hpp */ diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index a681e52c..7207b7db 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -4,6 +4,7 @@ set(UTEST_EXE utest.object2) set(UTEST_SRCS object2_utest_main.cpp DString.test.cpp + StringOps.test.cpp X1Collector.test.cpp Printable.test.cpp ) diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index 213f5023..226d63c8 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -3,7 +3,7 @@ * @author Roland Conybeare, Jan 2026 **/ -#include +#include #include #include #include diff --git a/utest/StringOps.test.cpp b/utest/StringOps.test.cpp new file mode 100644 index 00000000..60069b53 --- /dev/null +++ b/utest/StringOps.test.cpp @@ -0,0 +1,54 @@ +/** @file StringOps.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include +#include +#include +#include + +namespace xo { + using xo::scm::StringOps; + using xo::scm::DString; + using xo::mm::AAllocator; + using xo::mm::AGCObject; + using xo::mm::DArena; + using xo::mm::ArenaConfig; + using xo::facet::with_facet; + using xo::facet::obj; + + namespace ut { + TEST_CASE("StringOps-empty", "[object2][StringOps]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + obj s = StringOps::empty(alloc, 16); + + REQUIRE(s.data() != nullptr); + REQUIRE(s.data()->capacity() == 16); + REQUIRE(s.data()->size() == 0); + REQUIRE(s.data()->chars()[0] == '\0'); + } + + TEST_CASE("StringOps-empty-with-content", "[object2][StringOps]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + obj s = StringOps::empty(alloc, 32); + + s.data()->sprintf("hello %s %d", "world", 42); + + REQUIRE(s.data()->size() == 14); + REQUIRE(std::strcmp(s.data()->chars(), "hello world 42") == 0); + } + } /*namespace ut*/ +} /*namespace xo*/ + +/* end StringOps.test.cpp */ From b628dbd1874090b5fc29ef85068d2d221c6f61c2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 11:17:55 -0500 Subject: [PATCH 060/176] xo-object2: + StringOps::from_cstr + utest --- include/xo/object2/StringOps.hpp | 11 +++++++++++ utest/StringOps.test.cpp | 20 ++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/xo/object2/StringOps.hpp b/include/xo/object2/StringOps.hpp index 3cc71988..a8e231e9 100644 --- a/include/xo/object2/StringOps.hpp +++ b/include/xo/object2/StringOps.hpp @@ -22,6 +22,10 @@ namespace xo { template static obj empty(obj mm, size_type cap); + + template + static obj from_cstr(obj mm, + const char * cstr); }; template @@ -30,6 +34,13 @@ namespace xo { { return obj(DString::empty(mm, cap)); } + + template + obj + StringOps::from_cstr(obj mm, const char * cstr) + { + return obj(DString::from_cstr(mm, cstr)); + } } } diff --git a/utest/StringOps.test.cpp b/utest/StringOps.test.cpp index 60069b53..bfd3fbd3 100644 --- a/utest/StringOps.test.cpp +++ b/utest/StringOps.test.cpp @@ -26,7 +26,7 @@ namespace xo { DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); - obj s = StringOps::empty(alloc, 16); + auto s = StringOps::empty(alloc, 16); REQUIRE(s.data() != nullptr); REQUIRE(s.data()->capacity() == 16); @@ -41,13 +41,29 @@ namespace xo { DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); - obj s = StringOps::empty(alloc, 32); + auto s = StringOps::empty(alloc, 32); s.data()->sprintf("hello %s %d", "world", 42); REQUIRE(s.data()->size() == 14); REQUIRE(std::strcmp(s.data()->chars(), "hello world 42") == 0); } + + TEST_CASE("StringOps-from_cstr", "[object2][StringOps]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + const char * cstr = "hello world"; + auto s = StringOps::from_cstr(alloc, cstr); + + REQUIRE(s.data() != nullptr); + REQUIRE(s.data()->capacity() == 12); + REQUIRE(s.data()->size() == 11); + REQUIRE(std::strcmp(s.data()->chars(), cstr) == 0); + } } /*namespace ut*/ } /*namespace xo*/ From ede658219c5fe3bcd1f55755b9eeae88756c9ee4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 11:25:26 -0500 Subject: [PATCH 061/176] xo-object2: + StringOps.clone + utest --- include/xo/object2/StringOps.hpp | 15 +++++++++++++++ utest/StringOps.test.cpp | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/xo/object2/StringOps.hpp b/include/xo/object2/StringOps.hpp index a8e231e9..96d9da15 100644 --- a/include/xo/object2/StringOps.hpp +++ b/include/xo/object2/StringOps.hpp @@ -19,13 +19,21 @@ namespace xo { using AAllocator = xo::mm::AAllocator; using size_type = DString::size_type; + /** wrapper for DString.empty() **/ template static obj empty(obj mm, size_type cap); + /** wrapper for DString.from_cstr() **/ template static obj from_cstr(obj mm, const char * cstr); + + /** wrapper for DString.clone() **/ + template + static obj clone(obj mm, + obj src); }; template @@ -41,6 +49,13 @@ namespace xo { { return obj(DString::from_cstr(mm, cstr)); } + + template + obj + StringOps::clone(obj mm, obj src) + { + return obj(DString::clone(mm, src.data())); + } } } diff --git a/utest/StringOps.test.cpp b/utest/StringOps.test.cpp index bfd3fbd3..2fabb0ea 100644 --- a/utest/StringOps.test.cpp +++ b/utest/StringOps.test.cpp @@ -64,6 +64,23 @@ namespace xo { REQUIRE(s.data()->size() == 11); REQUIRE(std::strcmp(s.data()->chars(), cstr) == 0); } + + TEST_CASE("StringOps-clone", "[object2][StringOps]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + auto src = StringOps::from_cstr(alloc, "hello world"); + auto copy = StringOps::clone(alloc, src); + + REQUIRE(copy.data() != nullptr); + REQUIRE(copy.data() != src.data()); + REQUIRE(copy.data()->size() == src.data()->size()); + REQUIRE(copy.data()->capacity() == src.data()->capacity()); + REQUIRE(std::strcmp(copy.data()->chars(), src.data()->chars()) == 0); + } } /*namespace ut*/ } /*namespace xo*/ From aea37f2523b0a1b79b6b721577c1a64825ce6e8f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 11:29:35 -0500 Subject: [PATCH 062/176] xo-object2: + StringOps.printf() + utest --- include/xo/object2/StringOps.hpp | 18 ++++++++++++++++++ utest/StringOps.test.cpp | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/xo/object2/StringOps.hpp b/include/xo/object2/StringOps.hpp index 96d9da15..70441b4b 100644 --- a/include/xo/object2/StringOps.hpp +++ b/include/xo/object2/StringOps.hpp @@ -34,6 +34,13 @@ namespace xo { typename ASrcFacet = AGCObject> static obj clone(obj mm, obj src); + + /** wrapper for DString.printf() **/ + template + static obj printf(obj mm, + size_type cap, + const char * fmt, + Args&&... args); }; template @@ -56,6 +63,17 @@ namespace xo { { return obj(DString::clone(mm, src.data())); } + + template + obj + StringOps::printf(obj mm, + size_type cap, + const char * fmt, + Args&&... args) + { + return obj(DString::printf(mm, cap, fmt, + std::forward(args)...)); + } } } diff --git a/utest/StringOps.test.cpp b/utest/StringOps.test.cpp index 2fabb0ea..26464f90 100644 --- a/utest/StringOps.test.cpp +++ b/utest/StringOps.test.cpp @@ -81,6 +81,21 @@ namespace xo { REQUIRE(copy.data()->capacity() == src.data()->capacity()); REQUIRE(std::strcmp(copy.data()->chars(), src.data()->chars()) == 0); } + + TEST_CASE("StringOps-printf", "[object2][StringOps]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + auto s = StringOps::printf(alloc, 32, "hello %s %d", "world", 42); + + REQUIRE(s.data() != nullptr); + REQUIRE(s.data()->capacity() == 32); + REQUIRE(s.data()->size() == 14); + REQUIRE(std::strcmp(s.data()->chars(), "hello world 42") == 0); + } } /*namespace ut*/ } /*namespace xo*/ From bf555ddd10a72b66afa54a633df38059469cd1f0 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 13:15:18 -0500 Subject: [PATCH 063/176] xo-object2: + DArray [WIP] + utest --- include/xo/object2/DArray.hpp | 121 ++++++++++++++++++++++++++++++++++ src/object2/CMakeLists.txt | 1 + src/object2/DArray.cpp | 53 +++++++++++++++ utest/CMakeLists.txt | 1 + utest/DArray.test.cpp | 96 +++++++++++++++++++++++++++ 5 files changed, 272 insertions(+) create mode 100644 include/xo/object2/DArray.hpp create mode 100644 src/object2/DArray.cpp create mode 100644 utest/DArray.test.cpp diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp new file mode 100644 index 00000000..2de3b312 --- /dev/null +++ b/include/xo/object2/DArray.hpp @@ -0,0 +1,121 @@ +/** @file DArray.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace xo { + namespace scm { + /** @class DArray + * @brief Polymorphic array implementation with gc hooks + * + * 1D Array implementation for Schematika + * Like DString, this implementation has max capacity + * fixed at construction time, but not part of type. + * Can reallocate to change + **/ + struct DArray { + public: + /** @defgroup darray-types type traits **/ + ///@{ + + /** type for array size **/ + using size_type = std::uint32_t; + /** xo allocator facet **/ + using AAllocator = xo::mm::AAllocator; + /** garbage collector facet **/ + using ACollector = xo::mm::ACollector; + /** gc-aware object facet **/ + using AGCObject = xo::mm::AGCObject; + /** pretty-printer state for APrintable **/ + using ppindentinfo = xo::print::ppindentinfo; + + ///@} + /** @defgroup darray-ctors constructors **/ + ///@{ + + /** default ctor. zero capacity sentinel **/ + DArray() = default; + + /** not simply copyable because of flexible array. + * Need allocator. See @ref clone + **/ + DArray(const DArray &) = delete; + + /** create empty array with space for @p cap elements + * using memory from allocator @p mm. + * Nullptr if space exhausted + **/ + static DArray * empty(obj mm, + size_type cap); + + ///@} + /** @defgroup darray-access acecss methods **/ + ///@{ + /** true iff array is empty **/ + bool is_empty() const noexcept { return size_ == 0; } + /** only support finite arrays :-) **/ + bool is_finite() const noexcept { return true; } + /** return element @p index of this array (0-based) **/ + obj at(size_type index) const; + ///@} + /** @defgroup darray-iterators iterators **/ + ///@{ + + ///@} + /** @defgroup darray-assign assignment **/ + ///@{ + /** append @p elt at the end of array. + * true on success, false otherwise + **/ + bool push_back(obj elt) noexcept; + ///@} + /** @defgroup darray-general general methods **/ + ///@{ + + ///@} + /** @defgroup darray-conversion-operators conversion operators **/ + ///@{ + + ///@} + /** @defgroup darray-sequence-methods **/ + ///@{ + + ///@} + /** @defgroup darray-printable-methods **/ + ///@{ + + ///@} + /** @defgroup darray-gcobject-methods **/ + ///@{ + + ///@} + + private: + /** @defgroup darray-instance-variables instance variables **/ + ///@{ + + /** extent of @ref elts_ array **/ + size_type capacity_ = 0; + /** array size + * Invariant: size_ <= capacity_ + **/ + size_type size_ = 0; + /** array elements, using flexible array **/ + obj elts_[]; + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DArray.hpp */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 5764d98b..6e3ba706 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -12,6 +12,7 @@ set(SELF_SRCS IPrintable_DFloat.cpp IPrintable_DInteger.cpp IPrintable_DString.cpp + DArray.cpp DList.cpp DFloat.cpp DInteger.cpp diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp new file mode 100644 index 00000000..1039427e --- /dev/null +++ b/src/object2/DArray.cpp @@ -0,0 +1,53 @@ +/** @file DArray.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DArray.hpp" + +namespace xo { + using xo::mm::AGCObject; + using xo::facet::typeseq; + + namespace scm { + DArray * + DArray::empty(obj mm, + size_type cap) + { + assert(cap > 0); + + DArray * result = nullptr; + + if (cap > 0) { + void * mem = mm.alloc(typeseq::id(), + sizeof(DArray) + cap * sizeof(obj)); + + result = new (mem) DArray(); + + assert(result); + + result->capacity_ = cap; + result->size_ = 0; + } + + return result; + } + + bool + DArray::push_back(obj elt) noexcept { + if (size_ >= capacity_) { + return false; + } else { + static_assert(!std::is_trivially_constructible_v>); + + void * mem = &(elts_[size_]); + + new (mem) obj(elt); + + ++(this->size_); + + return true; + } + } + } /*namespace scm*/ +} /*namespace xo*/ diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 7207b7db..573fefd6 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -3,6 +3,7 @@ set(UTEST_EXE utest.object2) set(UTEST_SRCS object2_utest_main.cpp + DArray.test.cpp DString.test.cpp StringOps.test.cpp X1Collector.test.cpp diff --git a/utest/DArray.test.cpp b/utest/DArray.test.cpp new file mode 100644 index 00000000..14282f8c --- /dev/null +++ b/utest/DArray.test.cpp @@ -0,0 +1,96 @@ +/** @file DArray.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include +#include +#include +#include +#include + +namespace xo { + using xo::scm::DArray; + using xo::scm::DInteger; + using xo::mm::AAllocator; + using xo::mm::AGCObject; + using xo::mm::DArena; + using xo::mm::ArenaConfig; + using xo::facet::with_facet; + using xo::facet::obj; + + namespace ut { + TEST_CASE("DArray-empty", "[object2][DArray]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DArray * arr = DArray::empty(alloc, 16); + + REQUIRE(arr != nullptr); + REQUIRE(arr->is_empty() == true); + REQUIRE(arr->is_finite() == true); + } + + TEST_CASE("DArray-push_back", "[object2][DArray]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DArray * arr = DArray::empty(alloc, 16); + REQUIRE(arr != nullptr); + + obj elt = DInteger::box(alloc, 42); + + bool ok = arr->push_back(elt); + + REQUIRE(ok == true); + REQUIRE(arr->is_empty() == false); + } + + TEST_CASE("DArray-push_back-multiple", "[object2][DArray]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DArray * arr = DArray::empty(alloc, 4); + REQUIRE(arr != nullptr); + + for (int i = 0; i < 4; ++i) { + obj elt = DInteger::box(alloc, 100 + i); + bool ok = arr->push_back(elt); + REQUIRE(ok == true); + } + + REQUIRE(arr->is_empty() == false); + } + + TEST_CASE("DArray-push_back-overflow", "[object2][DArray]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DArray * arr = DArray::empty(alloc, 2); + REQUIRE(arr != nullptr); + + obj e1 = DInteger::box(alloc, 1); + obj e2 = DInteger::box(alloc, 2); + obj e3 = DInteger::box(alloc, 3); + + REQUIRE(arr->push_back(e1) == true); + REQUIRE(arr->push_back(e2) == true); + REQUIRE(arr->push_back(e3) == false); + } + + } /*namespace ut*/ +} /*namespace xo*/ + +/* end DArray.test.cpp */ From 698b44a92fd49a1bf24c1db0406d913f588f0b8e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 13:41:24 -0500 Subject: [PATCH 064/176] xo-object2: + DArray::at() + utests --- include/xo/object2/DArray.hpp | 4 ++ include/xo/object2/DString.hpp | 5 ++- src/object2/DArray.cpp | 15 ++++++++ src/object2/DString.cpp | 3 ++ utest/DArray.test.cpp | 67 +++++++++++++++++++++++++++++++++- 5 files changed, 90 insertions(+), 4 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 2de3b312..f07941cb 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -64,6 +64,10 @@ namespace xo { bool is_empty() const noexcept { return size_ == 0; } /** only support finite arrays :-) **/ bool is_finite() const noexcept { return true; } + /** array capacity **/ + size_type capacity() const noexcept { return capacity_; } + /** current array size (number of elements) **/ + size_type size() const noexcept { return size_; } /** return element @p index of this array (0-based) **/ obj at(size_type index) const; ///@} diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index a029da3f..6f3fa4ec 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +//#include namespace xo { namespace scm { @@ -34,6 +34,7 @@ namespace xo { using traits_type = std::char_traits; /** type of each character in this DString **/ using value_type = char; + /** type for string index / size **/ using size_type = std::uint32_t; /** representation for a read/write iterator **/ using iterator = char *; @@ -57,7 +58,7 @@ namespace xo { **/ DString(const DString &) = delete; - /** create empty string with space for @cap chars + /** create empty string with space for @p cap chars * (including null terminator). * Use memory from allocator @p mm **/ diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 1039427e..676086d4 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -4,6 +4,8 @@ **/ #include "DArray.hpp" +#include +#include namespace xo { using xo::mm::AGCObject; @@ -33,6 +35,19 @@ namespace xo { return result; } + obj + DArray::at(size_type ix) const + { + if (ix < size_) { + return elts_[ix]; + } else { + throw std::runtime_error(tostr("DArray::at: out-of-range index where [0..z) expected", + xtag("index", ix), + xtag("z", this->size()))); + return obj(); + } + } + bool DArray::push_back(obj elt) noexcept { if (size_ >= capacity_) { diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index 517f3f97..8787f687 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -26,6 +26,9 @@ namespace xo { sizeof(DString) + cap); result = new (mem) DString(); + + assert(result); + result->capacity_ = cap; result->size_ = 0; if (cap > 0) { diff --git a/utest/DArray.test.cpp b/utest/DArray.test.cpp index 14282f8c..aa718d44 100644 --- a/utest/DArray.test.cpp +++ b/utest/DArray.test.cpp @@ -5,11 +5,13 @@ #include #include +#include #include #include #include namespace xo { + using xo::scm::ListOps; using xo::scm::DArray; using xo::scm::DInteger; using xo::mm::AAllocator; @@ -20,6 +22,18 @@ namespace xo { using xo::facet::obj; namespace ut { + TEST_CASE("DArray-nullctor", "[object2][DArray]") + { + DArray arr; + + REQUIRE(arr.size() == 0); + REQUIRE(arr.capacity() == 0); + + REQUIRE(arr.is_empty());; + + REQUIRE(arr.push_back(ListOps::nil()) == false); + } + TEST_CASE("DArray-empty", "[object2][DArray]") { ArenaConfig cfg { .name_ = "testarena", @@ -30,7 +44,10 @@ namespace xo { DArray * arr = DArray::empty(alloc, 16); REQUIRE(arr != nullptr); + REQUIRE(arr->capacity() == 16); + REQUIRE(arr->is_empty() == true); + REQUIRE(arr->size() == 0); REQUIRE(arr->is_finite() == true); } @@ -43,6 +60,8 @@ namespace xo { DArray * arr = DArray::empty(alloc, 16); REQUIRE(arr != nullptr); + REQUIRE(arr->capacity() == 16); + REQUIRE(arr->size() == 0); obj elt = DInteger::box(alloc, 42); @@ -50,6 +69,8 @@ namespace xo { REQUIRE(ok == true); REQUIRE(arr->is_empty() == false); + REQUIRE(arr->size() == 1); + REQUIRE(arr->capacity() == 16); } TEST_CASE("DArray-push_back-multiple", "[object2][DArray]") @@ -61,14 +82,21 @@ namespace xo { DArray * arr = DArray::empty(alloc, 4); REQUIRE(arr != nullptr); + REQUIRE(arr->capacity() == 4); + REQUIRE(arr->size() == 0); for (int i = 0; i < 4; ++i) { + REQUIRE(arr->capacity() == 4); + REQUIRE(arr->size() == i); + obj elt = DInteger::box(alloc, 100 + i); bool ok = arr->push_back(elt); REQUIRE(ok == true); - } - REQUIRE(arr->is_empty() == false); + REQUIRE(arr->capacity() == 4); + REQUIRE(arr->is_empty() == false); + REQUIRE(arr->size() == i+1); + } } TEST_CASE("DArray-push_back-overflow", "[object2][DArray]") @@ -79,15 +107,50 @@ namespace xo { auto alloc = with_facet::mkobj(&arena); DArray * arr = DArray::empty(alloc, 2); + REQUIRE(arr != nullptr); + REQUIRE(arr->capacity() == 2); + REQUIRE(arr->size() == 0); obj e1 = DInteger::box(alloc, 1); obj e2 = DInteger::box(alloc, 2); obj e3 = DInteger::box(alloc, 3); REQUIRE(arr->push_back(e1) == true); + REQUIRE(arr->size() == 1); REQUIRE(arr->push_back(e2) == true); + REQUIRE(arr->size() == 2); REQUIRE(arr->push_back(e3) == false); + REQUIRE(arr->size() == 2); + REQUIRE(arr->capacity() == 2); + } + + TEST_CASE("DArray-at", "[object2][DArray]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DArray * arr = DArray::empty(alloc, 4); + + REQUIRE(arr != nullptr); + REQUIRE(arr->size() == 0); + REQUIRE(arr->capacity() == 4); + + obj e0 = DInteger::box(alloc, 100); + obj e1 = DInteger::box(alloc, 200); + obj e2 = DInteger::box(alloc, 300); + + arr->push_back(e0); + arr->push_back(e1); + arr->push_back(e2); + + REQUIRE(arr->size() == 3); + + REQUIRE(arr->at(0).data() == e0.data()); + REQUIRE(arr->at(1).data() == e1.data()); + REQUIRE(arr->at(2).data() == e2.data()); } } /*namespace ut*/ From eae117a5d3848f3277622502f6c26bb6b73f717f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 14:15:24 -0500 Subject: [PATCH 065/176] xo-object2: + ISequence_DArray + codegen --- CMakeLists.txt | 12 ++++ idl/ISequence_DArray.json5 | 12 ++++ include/xo/object2/array/ISequence_DArray.hpp | 64 +++++++++++++++++++ src/object2/CMakeLists.txt | 1 + src/object2/ISequence_DArray.cpp | 40 ++++++++++++ src/object2/object2_register_facets.cpp | 9 +++ 6 files changed, 138 insertions(+) create mode 100644 idl/ISequence_DArray.json5 create mode 100644 include/xo/object2/array/ISequence_DArray.hpp create mode 100644 src/object2/ISequence_DArray.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 961c965a..529b7372 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-sequence-array + FACET_PKG xo_object2 + FACET Sequence + REPR Array + INPUT idl/ISequence_DArray.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR array + OUTPUT_CPP_DIR src/object2 +) + # ---------------------------------------------------------------- # must complete definition of expression lib before configuring examples diff --git a/idl/ISequence_DArray.json5 b/idl/ISequence_DArray.json5 new file mode 100644 index 00000000..198410da --- /dev/null +++ b/idl/ISequence_DArray.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Sequence.json5", + brief: "provide ASequence interface for DArray state", + using_doxygen: true, + repr: "DArray", + doc: [ "implement ASequence for DArray" ], +} diff --git a/include/xo/object2/array/ISequence_DArray.hpp b/include/xo/object2/array/ISequence_DArray.hpp new file mode 100644 index 00000000..27f47db3 --- /dev/null +++ b/include/xo/object2/array/ISequence_DArray.hpp @@ -0,0 +1,64 @@ +/** @file ISequence_DArray.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/ISequence_DArray.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/ISequence_DArray.json5] + **/ + +#pragma once + +#include "Sequence.hpp" +#include "DArray.hpp" + +namespace xo { namespace scm { class ISequence_DArray; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::ISequence_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class ISequence_DArray + **/ + class ISequence_DArray { + public: + /** @defgroup scm-sequence-darray-type-traits **/ + ///@{ + using size_type = xo::scm::ASequence::size_type; + using AGCObject = xo::scm::ASequence::AGCObject; + using Copaque = xo::scm::ASequence::Copaque; + using Opaque = xo::scm::ASequence::Opaque; + ///@} + /** @defgroup scm-sequence-darray-methods **/ + ///@{ + // const methods + /** true iff sequence is empty **/ + static bool is_empty(const DArray & self) noexcept; + /** true iff sequence is finite **/ + static bool is_finite(const DArray & self) noexcept; + /** return element @p index of this sequence **/ + static obj at(const DArray & self, size_type index); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 6e3ba706..4c8645fe 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -7,6 +7,7 @@ set(SELF_SRCS IGCObject_DList.cpp IGCObject_DString.cpp ISequence_Any.cpp + ISequence_DArray.cpp ISequence_DList.cpp IPrintable_DList.cpp IPrintable_DFloat.cpp diff --git a/src/object2/ISequence_DArray.cpp b/src/object2/ISequence_DArray.cpp new file mode 100644 index 00000000..40ffe36a --- /dev/null +++ b/src/object2/ISequence_DArray.cpp @@ -0,0 +1,40 @@ +/** @file ISequence_DArray.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/ISequence_DArray.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/ISequence_DArray.json5] +**/ + +#include "array/ISequence_DArray.hpp" + +namespace xo { + namespace scm { + auto + ISequence_DArray::is_empty(const DArray & self) noexcept -> bool + { + return self.is_empty(); + } + + auto + ISequence_DArray::is_finite(const DArray & self) noexcept -> bool + { + return self.is_finite(); + } + + auto + ISequence_DArray::at(const DArray & self, size_type index) -> obj + { + return self.at(index); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end ISequence_DArray.cpp */ \ No newline at end of file diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 8dcb2c11..94cd7492 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -15,6 +15,9 @@ #include #include +#include +#include + #include #include #include @@ -27,6 +30,7 @@ namespace xo { using xo::scm::DList; using xo::scm::DFloat; using xo::scm::DString; + using xo::scm::DArray; using xo::facet::FacetRegistry; using xo::facet::typeseq; @@ -38,6 +42,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -48,14 +53,18 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DList.tseq", typeseq::id())); log && log(xtag("DFloat.tseq", typeseq::id())); log && log(xtag("DInteger.tseq", typeseq::id())); log && log(xtag("DString.tseq", typeseq::id())); + log && log(xtag("DArray.tseq", typeseq::id())); log && log(xtag("AAllocator.tseq", typeseq::id())); log && log(xtag("APrintable.tseq", typeseq::id())); log && log(xtag("AGCObject.tseq", typeseq::id())); + log && log(xtag("ASequence.tseq", typeseq::id())); return true; } From f5b071f103f2193c91365f51d5ed50fd32e7a07e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 14:29:09 -0500 Subject: [PATCH 066/176] xo-object2: + DArray gc hooks for AGCObject --- include/xo/object2/DArray.hpp | 7 +++++- src/object2/DArray.cpp | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index f07941cb..417318a0 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -100,7 +100,12 @@ namespace xo { ///@} /** @defgroup darray-gcobject-methods **/ ///@{ - + /** shallow memory consumption. Excludes child objects **/ + AAllocator::size_type shallow_size() const noexcept; + /** return shallow copy of this array, using memory from @p mm **/ + DArray * shallow_copy(obj mm) const noexcept; + /** forward elements to @p gc to-space; replace originals with forarding pointers **/ + AAllocator::size_type forward_children(obj gc) noexcept; ///@} private: diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 676086d4..392404cb 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -6,6 +6,7 @@ #include "DArray.hpp" #include #include +#include namespace xo { using xo::mm::AGCObject; @@ -64,5 +65,44 @@ namespace xo { return true; } } + + // gc hooks for IGCObject_DArray + + std::size_t + DArray::shallow_size() const noexcept + { + return sizeof(DArray); + } + + DArray * + DArray::shallow_copy(obj mm) const noexcept + { + DArray * copy = (DArray *)mm.alloc_copy((std::byte *)this); + + if (copy) { + copy->capacity_ = capacity_; + copy->size_ = size_; + + constexpr auto c_obj_z = sizeof(obj); + + /* memcpy sufficient for obj */ + ::memcpy((void*)&(copy->elts_[0]), (void*)&(elts_[0]), capacity_ * c_obj_z); + } + + return copy; + } + + std::size_t + DArray::forward_children(obj gc) noexcept + { + for (size_type i = 0; i < size_; ++i) { + obj & elt = elts_[i]; + + gc.forward_inplace(elt.iface(), (void **)&(elt.data_)); + } + + return shallow_size(); + } + } /*namespace scm*/ } /*namespace xo*/ From 17f090d9330b3bbd0fdbe62ad90a0eb0be4d072e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 14:29:28 -0500 Subject: [PATCH 067/176] xo-object2: retire obsolete log output --- src/object2/DList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 769ef1e3..81512218 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -168,7 +168,7 @@ namespace xo { auto DList::forward_children(obj gc) noexcept -> size_type { - scope log(XO_DEBUG(true)); + //scope log(XO_DEBUG(true)); gc.forward_inplace(head_.iface(), (void **)&(head_.data_)); From fbd3064e73d0d86356691227774c2c58c4dc0868 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 14:40:09 -0500 Subject: [PATCH 068/176] xo-object2: + IGCObject_DArray --- CMakeLists.txt | 12 ++++ idl/IGCObject_DArray.json5 | 15 +++++ include/xo/object2/array/IGCObject_DArray.hpp | 67 +++++++++++++++++++ src/object2/CMakeLists.txt | 1 + src/object2/IGCObject_DArray.cpp | 39 +++++++++++ src/object2/object2_register_facets.cpp | 2 + 6 files changed, 136 insertions(+) create mode 100644 idl/IGCObject_DArray.json5 create mode 100644 include/xo/object2/array/IGCObject_DArray.hpp create mode 100644 src/object2/IGCObject_DArray.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 529b7372..c7962ed7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-gcobject-array + FACET_PKG xo_gc + FACET GCObject + REPR Array + INPUT idl/IGCObject_DArray.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR array + OUTPUT_CPP_DIR src/object2 +) + # ---------------------------------------------------------------- # must complete definition of expression lib before configuring examples diff --git a/idl/IGCObject_DArray.json5 b/idl/IGCObject_DArray.json5 new file mode 100644 index 00000000..e8aeed3b --- /dev/null +++ b/idl/IGCObject_DArray.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DArray", + using_doxygen: true, + repr: "DArray", + doc: [ "implement AGCObject for DArray" ], +} diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp new file mode 100644 index 00000000..0b2279f1 --- /dev/null +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DArray.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DArray.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DArray.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DArray.hpp" + +namespace xo { namespace scm { class IGCObject_DArray; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DArray + **/ + class IGCObject_DArray { + public: + /** @defgroup scm-gcobject-darray-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-darray-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DArray & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DArray & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DArray & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 4c8645fe..3ab39f32 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -2,6 +2,7 @@ set(SELF_LIB xo_object2) set(SELF_SRCS + IGCObject_DArray.cpp IGCObject_DFloat.cpp IGCObject_DInteger.cpp IGCObject_DList.cpp diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp new file mode 100644 index 00000000..a2ee4bc1 --- /dev/null +++ b/src/object2/IGCObject_DArray.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DArray.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DArray.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DArray.json5] +**/ + +#include "array/IGCObject_DArray.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DArray::shallow_size(const DArray & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DArray::shallow_copy(const DArray & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DArray::forward_children(DArray & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DArray.cpp */ \ No newline at end of file diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 94cd7492..93438600 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -5,6 +5,7 @@ #include "object2_register_facets.hpp" +#include #include #include #include @@ -53,6 +54,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); log && log(xtag("DList.tseq", typeseq::id())); From f30ef137ee92127a573b568ceb24b1b76a9174a4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 15:28:13 -0500 Subject: [PATCH 069/176] xo-object2: ++ Collector utest w/ DInteger + scaffodl DArray --- include/xo/object2/DArray.hpp | 1 + src/object2/object2_register_types.cpp | 13 +++++---- utest/X1Collector.test.cpp | 39 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 417318a0..33896473 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -57,6 +57,7 @@ namespace xo { static DArray * empty(obj mm, size_type cap); + ///@} /** @defgroup darray-access acecss methods **/ ///@{ diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index e9695a37..c2079a40 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -5,14 +5,15 @@ #include "object2_register_types.hpp" -#include "list/IGCObject_DList.hpp" #include "number/IGCObject_DFloat.hpp" #include "number/IGCObject_DInteger.hpp" #include "string/IGCObject_DString.hpp" +#include "list/IGCObject_DList.hpp" +#include "array/IGCObject_DArray.hpp" -#include "list/IPrintable_DList.hpp" +//#include "list/IPrintable_DList.hpp" //#include "IPrintable_DFloat.hpp" -#include "number/IPrintable_DInteger.hpp" +//#include "number/IPrintable_DInteger.hpp" #include #include @@ -32,14 +33,16 @@ namespace xo { bool ok = true; - ok &= gc.install_type(impl_for()); - ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + + ok &= gc.install_type(impl_for()); + return ok; } } diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 330db905..85610da2 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -5,10 +5,13 @@ #include "ListOps.hpp" #include "DFloat.hpp" +#include "DInteger.hpp" #include "DList.hpp" +#include "DArray.hpp" #include "object2_register_types.hpp" #include "number/IGCObject_DFloat.hpp" +#include "number/IGCObject_DInteger.hpp" #include "list/IGCObject_DList.hpp" #include @@ -29,7 +32,9 @@ namespace ut { using xo::scm::object2_register_types; using xo::scm::ListOps; using xo::scm::DList; + using xo::scm::DArray; using xo::scm::DFloat; + using xo::scm::DInteger; using xo::mm::AAllocator; using xo::mm::ACollector; using xo::mm::AllocHeader; @@ -76,6 +81,10 @@ namespace ut { TEST_CASE("x1", "[gc][x1]") { + /** + * This is a basic Collector test for xo-object2 data types + **/ + constexpr bool c_debug_flag = false; scope log(XO_DEBUG(c_debug_flag)); @@ -166,18 +175,28 @@ namespace ut { ok = c_o.is_type_installed(typeseq::id()); REQUIRE(ok); + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); ok = c_o.is_type_installed(typeseq::id()); REQUIRE(ok); + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); auto x0_o = DFloat::box(gc_o, 3.1415927); c_o.add_gc_root(&x0_o); REQUIRE(to_0->allocated() == sizeof(AllocHeader) + sizeof(DFloat)); + auto n1_o = DInteger::box(gc_o, 42); + c_o.add_gc_root(&n1_o); + REQUIRE(to_0->allocated() == (sizeof(AllocHeader) + sizeof(DFloat) + + sizeof(AllocHeader) + sizeof(DInteger))); + //DList * l0 = DList::list(gc_o, x0_o); //auto l0_o = with_facet::mkobj(l0); auto l0_o = ListOps::list(gc_o, x0_o); c_o.add_gc_root(&l0_o); REQUIRE(to_0->allocated() == (sizeof(AllocHeader) + sizeof(DFloat) + + sizeof(AllocHeader) + sizeof(DInteger) + sizeof(AllocHeader) + sizeof(DList))); { @@ -195,6 +214,20 @@ namespace ut { REQUIRE(info.size() < sizeof(DFloat) + padding::c_alloc_alignment); } + { + REQUIRE(n1_o.iface() != nullptr); + REQUIRE(n1_o.data() != nullptr); + REQUIRE(gc.contains(role::to_space(), n1_o.data())); + + /* check alloc info for newly-allocated object */ + AllocInfo info = gc.alloc_info((std::byte *)n1_o.data()); + + REQUIRE(info.age() == 0); + REQUIRE(info.tseq() == typeseq::id().seqno()); + REQUIRE(info.size() >= sizeof(DInteger)); + REQUIRE(info.size() < sizeof(DInteger) + padding::c_alloc_alignment); + } + { REQUIRE(l0_o.iface() != nullptr); REQUIRE(l0_o.data() != nullptr); @@ -220,11 +253,17 @@ namespace ut { REQUIRE(!gc.contains(role::from_space(), x0_o.data())); REQUIRE(gc.contains(role::to_space(), x0_o.data())); REQUIRE(x0_o.data()->value() == 3.1415927); + + REQUIRE(!gc.contains(role::from_space(), n1_o.data())); + REQUIRE(gc.contains(role::to_space(), n1_o.data())); + REQUIRE(n1_o.data()->value() == 42); + REQUIRE(!gc.contains(role::from_space(), l0_o.data())); REQUIRE(gc.contains(role::to_space(), l0_o.data())); REQUIRE(l0_o.data()->is_empty() == false); REQUIRE((void*)l0_o.data()->head_.data() == (void*)x0_o.data()); + REQUIRE((void*)l0_o.data()->rest_ == (void*)DList::_nil()); } catch (std::exception & ex) { std::cerr << "caught exception: " << ex.what() << std::endl; From c7ff46bd36714baa0b7745d711feb9ed72fee234 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 15:37:42 -0500 Subject: [PATCH 070/176] xo-object2: + DArray::array() n-ary factory method --- include/xo/object2/DArray.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 33896473..afa4769a 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace xo { @@ -57,6 +58,12 @@ namespace xo { static DArray * empty(obj mm, size_type cap); + /** create array containing elements @p args, using memory from @p mm. + * Nullptr if space exhausted. + **/ + template + requires (std::same_as> && ...) + static DArray * array(obj mm, Args... args); ///@} /** @defgroup darray-access acecss methods **/ @@ -125,6 +132,18 @@ namespace xo { ///@} }; + template + requires (std::same_as> && ...) + DArray * + DArray::array(obj mm, Args... args) + { + DArray * result = empty(mm, sizeof...(args)); + if (result) { + (result->push_back(args), ...); + } + return result; + } + } /*namespace scm*/ } /*namespace xo*/ From 3052ecdbcfaf068d812df5f88c72d8d56f60ef39 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 17:21:37 -0500 Subject: [PATCH 071/176] xo-object: + DString.compare() + utest --- include/xo/object2/DString.hpp | 6 +++++- src/object2/DString.cpp | 6 ++++++ utest/DString.test.cpp | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index 6f3fa4ec..39890498 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -164,6 +164,11 @@ namespace xo { return size_; } + /** lexicographically compare two strings. + * @return <0 if lhs < rhs, 0 if equal, >0 if lhs > rhs + **/ + static int compare(const DString & lhs, const DString & rhs) noexcept; + // TODO - behave like std::string, to the extent feasible // insert // insert_range @@ -181,7 +186,6 @@ namespace xo { // find_first_not_of // find_last_of // find_last_not_of - // compare // starts_with // end_with // contains diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index 8787f687..d96f712b 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -84,6 +84,12 @@ namespace xo { return *this; } + int + DString::compare(const DString & lhs, const DString & rhs) noexcept + { + return ::strcmp(lhs.chars_, rhs.chars_); + } + auto DString::fixup_size() noexcept -> size_type { diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index 226d63c8..c779c42f 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -292,6 +292,25 @@ namespace xo { REQUIRE(s->size() == 7); REQUIRE(std::strcmp(s->chars(), "hello w") == 0); } + + TEST_CASE("DString-compare", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s1 = DString::from_cstr(alloc, "apple"); + DString * s2 = DString::from_cstr(alloc, "apple"); + DString * s3 = DString::from_cstr(alloc, "banana"); + DString * s4 = DString::from_cstr(alloc, "aardvark"); + + REQUIRE(DString::compare(*s1, *s2) == 0); + REQUIRE(DString::compare(*s1, *s3) < 0); + REQUIRE(DString::compare(*s3, *s1) > 0); + REQUIRE(DString::compare(*s1, *s4) > 0); + REQUIRE(DString::compare(*s4, *s1) < 0); + } } /*namespace ut*/ } /*namespace xo*/ From 11365c95ac9b75c42a9f5e1adc8b282da0a782f6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 17:22:03 -0500 Subject: [PATCH 072/176] xo-object2: allow 0-capacity DArrays + utest --- include/xo/object2/DArray.hpp | 3 +++ src/object2/DArray.cpp | 16 ++++++--------- utest/DArray.test.cpp | 38 +++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index afa4769a..0dc13cd1 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -60,6 +60,9 @@ namespace xo { /** create array containing elements @p args, using memory from @p mm. * Nullptr if space exhausted. + * + * Use: + * Darray * v = DArray::array(mm, e1, e2, e3); **/ template requires (std::same_as> && ...) diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 392404cb..1b4138c6 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -17,21 +17,17 @@ namespace xo { DArray::empty(obj mm, size_type cap) { - assert(cap > 0); - DArray * result = nullptr; - if (cap > 0) { - void * mem = mm.alloc(typeseq::id(), - sizeof(DArray) + cap * sizeof(obj)); + void * mem = mm.alloc(typeseq::id(), + sizeof(DArray) + cap * sizeof(obj)); - result = new (mem) DArray(); + result = new (mem) DArray(); - assert(result); + assert(result); - result->capacity_ = cap; - result->size_ = 0; - } + result->capacity_ = cap; + result->size_ = 0; return result; } diff --git a/utest/DArray.test.cpp b/utest/DArray.test.cpp index aa718d44..84afbe11 100644 --- a/utest/DArray.test.cpp +++ b/utest/DArray.test.cpp @@ -153,6 +153,44 @@ namespace xo { REQUIRE(arr->at(2).data() == e2.data()); } + TEST_CASE("DArray-array", "[object2][DArray]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + obj e0 = DInteger::box(alloc, 10); + obj e1 = DInteger::box(alloc, 20); + obj e2 = DInteger::box(alloc, 30); + + DArray * arr = DArray::array(alloc, e0, e1, e2); + + REQUIRE(arr != nullptr); + REQUIRE(arr->size() == 3); + REQUIRE(arr->capacity() == 3); + REQUIRE(arr->is_empty() == false); + + REQUIRE(arr->at(0).data() == e0.data()); + REQUIRE(arr->at(1).data() == e1.data()); + REQUIRE(arr->at(2).data() == e2.data()); + } + + TEST_CASE("DArray-array-empty", "[object2][DArray]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DArray * arr = DArray::array(alloc); + + REQUIRE(arr != nullptr); + REQUIRE(arr->size() == 0); + REQUIRE(arr->capacity() == 0); + REQUIRE(arr->is_empty() == true); + } + } /*namespace ut*/ } /*namespace xo*/ From e752e5ae7ba885e03847c5644f6c3ada5cc8ee16 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 17:23:15 -0500 Subject: [PATCH 073/176] xo-object2: + operator==() for DString --- include/xo/object2/DString.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index 39890498..35e0527f 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -245,6 +245,11 @@ namespace xo { ///@} }; + + inline bool operator==(const DString & lhs, const DString & rhs) { + return DString::compare(lhs, rhs) == 0; + } + } /*namespace scm*/ } /*namespace xo*/ From e346514c06aa72eff15a84b3616da57ae8f249bf Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 17:28:54 -0500 Subject: [PATCH 074/176] xo-object2: + string comparison operators --- include/xo/object2/DString.hpp | 20 +++++++++++++++ utest/DString.test.cpp | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index 35e0527f..da891e7f 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -250,6 +250,26 @@ namespace xo { return DString::compare(lhs, rhs) == 0; } + inline bool operator!=(const DString & lhs, const DString & rhs) { + return DString::compare(lhs, rhs) != 0; + } + + inline bool operator<(const DString & lhs, const DString & rhs) { + return DString::compare(lhs, rhs) < 0; + } + + inline bool operator<=(const DString & lhs, const DString & rhs) { + return DString::compare(lhs, rhs) <= 0; + } + + inline bool operator>(const DString & lhs, const DString & rhs) { + return DString::compare(lhs, rhs) > 0; + } + + inline bool operator>=(const DString & lhs, const DString & rhs) { + return DString::compare(lhs, rhs) >= 0; + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index c779c42f..19ade045 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -311,6 +311,53 @@ namespace xo { REQUIRE(DString::compare(*s1, *s4) > 0); REQUIRE(DString::compare(*s4, *s1) < 0); } + + TEST_CASE("DString-comparison-operators", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * apple1 = DString::from_cstr(alloc, "apple"); + DString * apple2 = DString::from_cstr(alloc, "apple"); + DString * banana = DString::from_cstr(alloc, "banana"); + + // operator== + REQUIRE(*apple1 == *apple1); + REQUIRE(*apple2 == *apple2); + REQUIRE(*banana == *banana); + REQUIRE(*apple1 == *apple2); + + REQUIRE_FALSE(*apple1 == *banana); + + // operator!= + REQUIRE(*apple1 != *banana); + REQUIRE_FALSE(*apple1 != *apple1); + REQUIRE_FALSE(*apple2 != *apple2); + REQUIRE_FALSE(*apple1 != *apple2); + REQUIRE_FALSE(*banana != *banana); + + // operator< + REQUIRE(*apple1 < *banana); + REQUIRE_FALSE(*banana < *apple1); + REQUIRE_FALSE(*apple1 < *apple2); + + // operator<= + REQUIRE(*apple1 <= *banana); + REQUIRE(*apple1 <= *apple2); + REQUIRE_FALSE(*banana <= *apple1); + + // operator> + REQUIRE(*banana > *apple1); + REQUIRE_FALSE(*apple1 > *banana); + REQUIRE_FALSE(*apple1 > *apple2); + + // operator>= + REQUIRE(*banana >= *apple1); + REQUIRE(*apple1 >= *apple2); + REQUIRE_FALSE(*apple1 >= *banana); + } } /*namespace ut*/ } /*namespace xo*/ From a16ab7e7c2338732be1012fe7bfb89f6fc971660 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 17:39:17 -0500 Subject: [PATCH 075/176] xo-objectd2: + DString.hash() + utest --- include/xo/object2/DString.hpp | 15 +++++++++++++++ utest/DString.test.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index da891e7f..fb236721 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include //#include @@ -169,6 +170,11 @@ namespace xo { **/ static int compare(const DString & lhs, const DString & rhs) noexcept; + /** compute hash of string contents **/ + std::size_t hash() const noexcept { + return std::hash{}(std::string_view(chars_, size_)); + } + // TODO - behave like std::string, to the extent feasible // insert // insert_range @@ -273,4 +279,13 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ +namespace std { + template <> + struct hash { + std::size_t operator()(const xo::scm::DString & x) const noexcept { + return x.hash(); + } + }; +} /*namespace std*/ + /* end DString.hpp */ diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index 19ade045..21f33bd8 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -358,6 +358,35 @@ namespace xo { REQUIRE(*apple1 >= *apple2); REQUIRE_FALSE(*apple1 >= *banana); } + + TEST_CASE("DString-hash", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + DString * s1 = DString::from_cstr(alloc, "hello"); + DString * s2 = DString::from_cstr(alloc, "hello"); + DString * s3 = DString::from_cstr(alloc, "world"); + DString * empty1 = DString::empty(alloc, 16); + DString * empty2 = DString::empty(alloc, 32); + + // same content produces same hash + REQUIRE(s1->hash() == s2->hash()); + + // empty strings have same hash + REQUIRE(empty1->hash() == empty2->hash()); + + // different content produces different hash (not guaranteed, but highly likely) + REQUIRE(s1->hash() != s3->hash()); + + // std::hash specialization works + std::hash hasher; + REQUIRE(hasher(*s1) == s1->hash()); + REQUIRE(hasher(*s2) == s2->hash()); + REQUIRE(hasher(*s1) == hasher(*s2)); + } } /*namespace ut*/ } /*namespace xo*/ From d87caecce87914740aae13ad01bfe4976ba369ca Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 19:37:32 -0500 Subject: [PATCH 076/176] xo-object2: + DString::from_view() --- include/xo/object2/DString.hpp | 6 ++++++ src/object2/DString.cpp | 19 +++++++++++++++++++ utest/DString.test.cpp | 25 +++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index fb236721..2092f7dd 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -72,6 +72,12 @@ namespace xo { static DString * from_cstr(obj mm, const char * cstr); + /** create string containing a copy of @p sv. + * Use memory from allocator @p mm + **/ + static DString * from_view(obj mm, + std::string_view sv); + /** clone existing string **/ static DString * clone(obj mm, const DString * src); diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index d96f712b..93bdf5b8 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -57,6 +57,25 @@ namespace xo { return result; } + DString * + DString::from_view(obj mm, + std::string_view sv) + { + size_type len = sv.size(); + size_type cap = len + 1; + + void * mem = mm.alloc(typeseq::id(), + sizeof(DString) + cap); + + DString * result = new (mem) DString(); + result->capacity_ = cap; + result->size_ = len; + std::memcpy(result->chars_, sv.data(), len); + result->chars_[len] = '\0'; + + return result; + } + DString * DString::clone(obj mm, const DString * src) { diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index 21f33bd8..124cebb5 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -50,6 +50,31 @@ namespace xo { REQUIRE(std::strcmp(s->chars(), cstr) == 0); } + TEST_CASE("DString-from_view", "[object2][DString]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = with_facet::mkobj(&arena); + + std::string_view sv = "hello world"; + DString * s = DString::from_view(alloc, sv); + + REQUIRE(s != nullptr); + REQUIRE(s->capacity() == 12); + REQUIRE(s->size() == 11); + REQUIRE(std::strcmp(s->chars(), "hello world") == 0); + + // test with substring (not null-terminated) + std::string_view sub = sv.substr(0, 5); + DString * s2 = DString::from_view(alloc, sub); + + REQUIRE(s2 != nullptr); + REQUIRE(s2->capacity() == 6); + REQUIRE(s2->size() == 5); + REQUIRE(std::strcmp(s2->chars(), "hello") == 0); + } + TEST_CASE("DString-assign", "[object2][DString]") { ArenaConfig cfg { .name_ = "testarena", From 87ddccd7172bac60a211d011294aa95750479420 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 13:05:58 -0500 Subject: [PATCH 077/176] xo-expression2: + DUniqueString, use in StringTable --- include/xo/object2/DString.hpp | 23 ++++++++++++++++++++++- src/object2/DString.cpp | 30 ++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index 2092f7dd..f35fe44f 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -73,11 +73,18 @@ namespace xo { const char * cstr); /** create string containing a copy of @p sv. - * Use memory from allocator @p mm + * Use memory from allocator @p mm. **/ static DString * from_view(obj mm, std::string_view sv); + /** create string containing a copy of @p sv. + * Use memory from allocator @p mm via sub_alloc. + * (load-bearing for StringTable) + **/ + static DString * from_view_suballoc(obj mm, + std::string_view sv); + /** clone existing string **/ static DString * clone(obj mm, const DString * src); @@ -244,6 +251,20 @@ namespace xo { ///@} + private: + /** @defgroup dstring-impl-methods implementation methods **/ + ///@{ + + /** create instance from view @p sv, using memory from @p mm. + * @p suballoc_flag chooses whether to use alloc() or suballoc(). + * Load-bearing for StringTable + **/ + static DString * _from_view_aux(obj mm, + std::string_view sv, + bool suballoc_flag); + + ///@} + private: /** @defgroup dstring-instance-variables instance variables **/ ///@{ diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index 93bdf5b8..ee9885b7 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -58,16 +58,24 @@ namespace xo { } DString * - DString::from_view(obj mm, - std::string_view sv) + DString::_from_view_aux(obj mm, + std::string_view sv, + bool suballoc_flag) { size_type len = sv.size(); size_type cap = len + 1; - void * mem = mm.alloc(typeseq::id(), - sizeof(DString) + cap); + auto tseq = typeseq::id(); + void * mem = nullptr; + size_type mem_z = sizeof(DString) + cap; + + if (suballoc_flag) + mem = mm.sub_alloc(mem_z, false /*!complete_flag*/); + else + mem = mm.alloc(tseq, mem_z); DString * result = new (mem) DString(); + result->capacity_ = cap; result->size_ = len; std::memcpy(result->chars_, sv.data(), len); @@ -76,6 +84,20 @@ namespace xo { return result; } + DString * + DString::from_view(obj mm, + std::string_view sv) + { + return _from_view_aux(mm, sv, false /*!suballoc_flag*/); + } + + DString * + DString::from_view_suballoc(obj mm, + std::string_view sv) + { + return _from_view_aux(mm, sv, true /*suballoc_flag*/); + } + DString * DString::clone(obj mm, const DString * src) { From 013c1a4896d34ef51e1958f52e47108c7e274d32 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 16:10:00 -0500 Subject: [PATCH 078/176] xo-gc: + CollectorTypeRegistry for streamlined init --- cmake/xo_object2Config.cmake.in | 1 + include/xo/object2/init_object2.hpp | 21 ++++++++++++++++ src/object2/CMakeLists.txt | 2 ++ src/object2/init_object2.cpp | 39 +++++++++++++++++++++++++++++ utest/DString.test.cpp | 11 +++++++- utest/X1Collector.test.cpp | 18 ++++++++++++- utest/object2_utest_main.cpp | 20 ++++++++++++++- 7 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 include/xo/object2/init_object2.hpp create mode 100644 src/object2/init_object2.cpp diff --git a/cmake/xo_object2Config.cmake.in b/cmake/xo_object2Config.cmake.in index 45104c22..36d3bb62 100644 --- a/cmake/xo_object2Config.cmake.in +++ b/cmake/xo_object2Config.cmake.in @@ -3,6 +3,7 @@ include(CMakeFindDependencyMacro) find_dependency(xo_gc) find_dependency(xo_printable2) +find_dependency(subsys) find_dependency(indentlog) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") check_required_components("@PROJECT_NAME@") diff --git a/include/xo/object2/init_object2.hpp b/include/xo/object2/init_object2.hpp new file mode 100644 index 00000000..5c26e76d --- /dev/null +++ b/include/xo/object2/init_object2.hpp @@ -0,0 +1,21 @@ +/** @file init_object2.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + /* tag to represent the xo-expression2/ subsystem within ordered initialization */ + enum S_object2_tag {}; + + template <> + struct InitSubsys { + static void init(); + static InitEvidence require(); + }; +} /*namespace xo*/ + +/* end init_object2.hpp */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 3ab39f32..a87c349b 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -19,6 +19,7 @@ set(SELF_SRCS DFloat.cpp DInteger.cpp DString.cpp + init_object2.cpp object2_register_types.cpp object2_register_facets.cpp ) @@ -27,4 +28,5 @@ xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 $ # note: deps here must also appear in cmake/xo_object2Config.cmake.in xo_dependency(${SELF_LIB} xo_gc) xo_dependency(${SELF_LIB} xo_printable2) +xo_dependency(${SELF_LIB} subsys) xo_dependency(${SELF_LIB} indentlog) diff --git a/src/object2/init_object2.cpp b/src/object2/init_object2.cpp new file mode 100644 index 00000000..b5e57aba --- /dev/null +++ b/src/object2/init_object2.cpp @@ -0,0 +1,39 @@ +/** @file init_object2.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_object2.hpp" +#include "object2_register_facets.hpp" +#include "object2_register_types.hpp" +#include + +namespace xo { + using xo::scm::object2_register_facets; + using xo::scm::object2_register_types; + using xo::mm::CollectorTypeRegistry; + + void + InitSubsys::init() + { + object2_register_facets(); + + CollectorTypeRegistry::instance().register_types(&object2_register_types); + } + + InitEvidence + InitSubsys::require() + { + InitEvidence retval; + + /* direct subsystem deps for xo-object2/ */ + // retval ^= InitSubsys::require(); + + /* xo-expression2/'s own initialization code */ + retval ^= Subsystem::provide("object2", &init); + + return retval; + } +} /*namespace xo*/ + +/* end init_object2.cpp */ diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index 124cebb5..39dffef5 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -3,7 +3,8 @@ * @author Roland Conybeare, Jan 2026 **/ -#include +#include "init_object2.hpp" +#include "StringOps.hpp" #include #include #include @@ -19,6 +20,14 @@ namespace xo { using xo::facet::obj; namespace ut { + static InitEvidence s_init = (InitSubsys::require()); + + TEST_CASE("DString-init", "[object2][DString]") + { + // real purpose: ensure s_init survives static linking + REQUIRE(s_init.evidence()); + } + TEST_CASE("DString-empty", "[object2][DString]") { ArenaConfig cfg { .name_ = "testarena", diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 85610da2..0f20e68a 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -3,6 +3,7 @@ * @author Roland Conybeare, Dec 2025 **/ +#include "init_object2.hpp" #include "ListOps.hpp" #include "DFloat.hpp" #include "DInteger.hpp" @@ -14,6 +15,7 @@ #include "number/IGCObject_DInteger.hpp" #include "list/IGCObject_DList.hpp" +#include #include #include @@ -23,18 +25,22 @@ #include #include +#include + #include #include #include namespace ut { + using xo::S_object2_tag; using xo::scm::object2_register_types; using xo::scm::ListOps; using xo::scm::DList; using xo::scm::DArray; using xo::scm::DFloat; using xo::scm::DInteger; + using xo::mm::CollectorTypeRegistry; using xo::mm::AAllocator; using xo::mm::ACollector; using xo::mm::AllocHeader; @@ -49,6 +55,9 @@ namespace ut { using xo::mm::padding; using xo::facet::with_facet; using xo::facet::typeseq; + using xo::Subsystem; + using xo::InitEvidence; + using xo::InitSubsys; using xo::scope; using xo::xtag; @@ -79,8 +88,13 @@ namespace ut { }; } + static InitEvidence s_init = (InitSubsys::require()); + TEST_CASE("x1", "[gc][x1]") { + // real purpose: ensure s_init survives static linking + REQUIRE(s_init.evidence()); + /** * This is a basic Collector test for xo-object2 data types **/ @@ -89,6 +103,8 @@ namespace ut { scope log(XO_DEBUG(c_debug_flag)); for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) { + scope log(XO_DEBUG(true), xtag("i_tc", i_tc)); + try { const testcase_x1 & tc = s_testcase_v[i_tc]; @@ -169,7 +185,7 @@ namespace ut { auto c_o = with_facet::mkobj(&gc); /* register object types */ - bool ok = object2_register_types(c_o); + bool ok = CollectorTypeRegistry::instance().install_types(c_o); REQUIRE(ok); diff --git a/utest/object2_utest_main.cpp b/utest/object2_utest_main.cpp index a3dcb813..d868f233 100644 --- a/utest/object2_utest_main.cpp +++ b/utest/object2_utest_main.cpp @@ -1,6 +1,24 @@ /* file object2_utest_main.cpp */ -#define CATCH_CONFIG_MAIN +#include + +#define CATCH_CONFIG_RUNNER #include "catch2/catch.hpp" +int +main(int argc, char* argv[]) +{ + using xo::Subsystem; + + // Your custom initialization code here + Subsystem::initialize_all(); + + // Run Catch2's test session + int result = Catch::Session().run(argc, argv); + + // cleanup here, if any + + return result; +} + /* end object2_utest_main.cpp */ From 4536fa500087e06209700b20809e486054e2240f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 20 Jan 2026 12:40:26 -0500 Subject: [PATCH 079/176] xo-reader2: + pretty-printing for ParserResult + use in utest --- include/xo/object2/DString.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index f35fe44f..eea8ea5c 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -279,6 +279,15 @@ namespace xo { ///@} }; + inline std::ostream & operator<<(std::ostream & os, const DString * x) { + if (x) { + os << std::string_view(*x); + } else { + os << "nullptr"; + } + return os; + } + inline bool operator==(const DString & lhs, const DString & rhs) { return DString::compare(lhs, rhs) == 0; } From 77f3997017f69b179529e7638b12de89b3600595 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 20 Jan 2026 22:11:19 -0500 Subject: [PATCH 080/176] xo-object2: bugfix: subdir structure in CMakeLists.txt genfacet --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7962ed7..9c2671e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,8 +119,8 @@ xo_add_genfacetimpl( FACET Printable REPR String INPUT idl/IPrintable_DString.json5 - OUTPUT_HPP_DIR include/xo/object2/string - OUTPUT_IMPL_SUBDIR . + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR string OUTPUT_CPP_DIR src/object2 ) @@ -131,8 +131,8 @@ xo_add_genfacetimpl( FACET GCObject REPR String INPUT idl/IGCObject_DString.json5 - OUTPUT_HPP_DIR include/xo/object2/string - OUTPUT_IMPL_SUBDIR . + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR string OUTPUT_CPP_DIR src/object2 ) From fde41994222900e860f1708165b83615b73f6909 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 20 Jan 2026 22:13:01 -0500 Subject: [PATCH 081/176] xo-reader2 xo-object2: regenerate facets from idl --- CMakeLists.txt | 2 ++ include/xo/object2/Sequence.hpp | 2 +- include/xo/object2/list/IGCObject_DList.hpp | 2 +- include/xo/object2/list/IPrintable_DList.hpp | 2 +- include/xo/object2/list/ISequence_DList.hpp | 2 +- include/xo/object2/number/IGCObject_DFloat.hpp | 2 +- include/xo/object2/number/IGCObject_DInteger.hpp | 2 +- include/xo/object2/number/IPrintable_DFloat.hpp | 2 +- include/xo/object2/number/IPrintable_DInteger.hpp | 2 +- include/xo/object2/sequence/ASequence.hpp | 2 +- include/xo/object2/sequence/ISequence_Any.hpp | 2 +- include/xo/object2/sequence/ISequence_Xfer.hpp | 2 +- include/xo/object2/sequence/RSequence.hpp | 2 +- include/xo/object2/string/IGCObject_DString.hpp | 3 ++- include/xo/object2/string/IPrintable_DString.hpp | 3 ++- src/object2/IGCObject_DFloat.cpp | 2 +- src/object2/IGCObject_DInteger.cpp | 2 +- src/object2/IGCObject_DList.cpp | 2 +- src/object2/IGCObject_DString.cpp | 2 +- src/object2/IPrintable_DFloat.cpp | 2 +- src/object2/IPrintable_DInteger.cpp | 2 +- src/object2/IPrintable_DList.cpp | 2 +- src/object2/IPrintable_DString.cpp | 2 +- src/object2/ISequence_DList.cpp | 2 +- 24 files changed, 27 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c2671e0..ee93bf7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,6 +160,8 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +xo_add_genfacet_all(xo-object2-genfacet-all) + # ---------------------------------------------------------------- # must complete definition of expression lib before configuring examples diff --git a/include/xo/object2/Sequence.hpp b/include/xo/object2/Sequence.hpp index fc934084..7866f91b 100644 --- a/include/xo/object2/Sequence.hpp +++ b/include/xo/object2/Sequence.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Sequence.json5] * 2. jinja2 template for facet .hpp file: diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index e87cdd96..19000df6 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DList.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/list/IPrintable_DList.hpp b/include/xo/object2/list/IPrintable_DList.hpp index 4371fdfb..d068bda1 100644 --- a/include/xo/object2/list/IPrintable_DList.hpp +++ b/include/xo/object2/list/IPrintable_DList.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DList.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/list/ISequence_DList.hpp b/include/xo/object2/list/ISequence_DList.hpp index 81289db9..d7c44e3b 100644 --- a/include/xo/object2/list/ISequence_DList.hpp +++ b/include/xo/object2/list/ISequence_DList.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/ISequence_DList.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index c57c89ea..b27163c2 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 10a5c685..6aa3c9fc 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DInteger.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/number/IPrintable_DFloat.hpp b/include/xo/object2/number/IPrintable_DFloat.hpp index 17eab5d2..2bcaf1d2 100644 --- a/include/xo/object2/number/IPrintable_DFloat.hpp +++ b/include/xo/object2/number/IPrintable_DFloat.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/number/IPrintable_DInteger.hpp b/include/xo/object2/number/IPrintable_DInteger.hpp index 95a9e108..a13334d6 100644 --- a/include/xo/object2/number/IPrintable_DInteger.hpp +++ b/include/xo/object2/number/IPrintable_DInteger.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DInteger.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/sequence/ASequence.hpp b/include/xo/object2/sequence/ASequence.hpp index 99687473..5281e0ea 100644 --- a/include/xo/object2/sequence/ASequence.hpp +++ b/include/xo/object2/sequence/ASequence.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/sequence/ISequence_Any.hpp b/include/xo/object2/sequence/ISequence_Any.hpp index 9f5901f2..0e7c5c10 100644 --- a/include/xo/object2/sequence/ISequence_Any.hpp +++ b/include/xo/object2/sequence/ISequence_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/sequence/ISequence_Xfer.hpp b/include/xo/object2/sequence/ISequence_Xfer.hpp index 60abc5aa..f3dc8b35 100644 --- a/include/xo/object2/sequence/ISequence_Xfer.hpp +++ b/include/xo/object2/sequence/ISequence_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/sequence/RSequence.hpp b/include/xo/object2/sequence/RSequence.hpp index 26ec1735..be4fafb0 100644 --- a/include/xo/object2/sequence/RSequence.hpp +++ b/include/xo/object2/sequence/RSequence.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/string/IGCObject_DString.hpp b/include/xo/object2/string/IGCObject_DString.hpp index ad12cb80..95a19483 100644 --- a/include/xo/object2/string/IGCObject_DString.hpp +++ b/include/xo/object2/string/IGCObject_DString.hpp @@ -6,13 +6,14 @@ * arguments: * --input [idl/IGCObject_DString.json5] * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] + * [iface_facet_repr.hpp.j2] * 3. idl for facet methods * [idl/IGCObject_DString.json5] **/ #pragma once +#include "GCObject.hpp" #include #include #include "DString.hpp" diff --git a/include/xo/object2/string/IPrintable_DString.hpp b/include/xo/object2/string/IPrintable_DString.hpp index d1d3f22a..f1be1374 100644 --- a/include/xo/object2/string/IPrintable_DString.hpp +++ b/include/xo/object2/string/IPrintable_DString.hpp @@ -6,13 +6,14 @@ * arguments: * --input [idl/IPrintable_DString.json5] * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] + * [iface_facet_repr.hpp.j2] * 3. idl for facet methods * [idl/IPrintable_DString.json5] **/ #pragma once +#include "Printable.hpp" #include #include #include "DString.hpp" diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index ef4214a7..3c44db5d 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 8b8a0112..91d8e4a1 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DInteger.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 06584687..b9d36cc5 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DList.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/object2/IGCObject_DString.cpp b/src/object2/IGCObject_DString.cpp index d411686a..1eff4da5 100644 --- a/src/object2/IGCObject_DString.cpp +++ b/src/object2/IGCObject_DString.cpp @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DString.cpp */ +/* end IGCObject_DString.cpp */ \ No newline at end of file diff --git a/src/object2/IPrintable_DFloat.cpp b/src/object2/IPrintable_DFloat.cpp index b83613e5..0c0a6789 100644 --- a/src/object2/IPrintable_DFloat.cpp +++ b/src/object2/IPrintable_DFloat.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/object2/IPrintable_DInteger.cpp b/src/object2/IPrintable_DInteger.cpp index 889cfa8c..8924a72c 100644 --- a/src/object2/IPrintable_DInteger.cpp +++ b/src/object2/IPrintable_DInteger.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DInteger.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/object2/IPrintable_DList.cpp b/src/object2/IPrintable_DList.cpp index 384d8b60..095b323d 100644 --- a/src/object2/IPrintable_DList.cpp +++ b/src/object2/IPrintable_DList.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DList.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/object2/IPrintable_DString.cpp b/src/object2/IPrintable_DString.cpp index f47aa3fa..86d4565e 100644 --- a/src/object2/IPrintable_DString.cpp +++ b/src/object2/IPrintable_DString.cpp @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DString.cpp */ +/* end IPrintable_DString.cpp */ \ No newline at end of file diff --git a/src/object2/ISequence_DList.cpp b/src/object2/ISequence_DList.cpp index b216b7e5..3c9c2437 100644 --- a/src/object2/ISequence_DList.cpp +++ b/src/object2/ISequence_DList.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/ISequence_DList.json5] * 2. jinja2 template for abstract facet .hpp file: From b456d7ac85bc98b3b28d8d97148a8ed862ef025b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 23 Jan 2026 15:44:13 -0500 Subject: [PATCH 082/176] xo-object2: + DBoolean w/ AGCObject, APrintable facets --- CMakeLists.txt | 36 ++++++++++ idl/IGCObject_DBoolean.json5 | 15 +++++ idl/IPrintable_DBoolean.json5 | 13 ++++ include/xo/object2/DBoolean.hpp | 57 ++++++++++++++++ .../xo/object2/boolean/IGCObject_DBoolean.hpp | 67 +++++++++++++++++++ .../object2/boolean/IPrintable_DBoolean.hpp | 62 +++++++++++++++++ src/object2/CMakeLists.txt | 3 + src/object2/DBoolean.cpp | 57 ++++++++++++++++ src/object2/IGCObject_DBoolean.cpp | 39 +++++++++++ src/object2/IPrintable_DBoolean.cpp | 28 ++++++++ src/object2/object2_register_facets.cpp | 10 +++ src/object2/object2_register_types.cpp | 3 + 12 files changed, 390 insertions(+) create mode 100644 idl/IGCObject_DBoolean.json5 create mode 100644 idl/IPrintable_DBoolean.json5 create mode 100644 include/xo/object2/DBoolean.hpp create mode 100644 include/xo/object2/boolean/IGCObject_DBoolean.hpp create mode 100644 include/xo/object2/boolean/IPrintable_DBoolean.hpp create mode 100644 src/object2/DBoolean.cpp create mode 100644 src/object2/IGCObject_DBoolean.cpp create mode 100644 src/object2/IPrintable_DBoolean.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ee93bf7e..261b59df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,8 @@ xo_add_genfacet( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-list @@ -64,6 +66,34 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-boolean + FACET_PKG xo_printable2 + FACET Printable + REPR Boolean + INPUT idl/IPrintable_DBoolean.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR boolean + OUTPUT_CPP_DIR src/object2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-gcobject-boolean + FACET_PKG xo_gc + FACET GCObject + REPR Boolean + INPUT idl/IGCObject_DBoolean.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR boolean + OUTPUT_CPP_DIR src/object2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-float @@ -88,6 +118,8 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-integer @@ -112,6 +144,8 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-string @@ -136,6 +170,8 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-array diff --git a/idl/IGCObject_DBoolean.json5 b/idl/IGCObject_DBoolean.json5 new file mode 100644 index 00000000..de3663c4 --- /dev/null +++ b/idl/IGCObject_DBoolean.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DBoolean", + using_doxygen: true, + repr: "DBoolean", + doc: [ "implement AGCObject for DBoolean" ], +} diff --git a/idl/IPrintable_DBoolean.json5 b/idl/IPrintable_DBoolean.json5 new file mode 100644 index 00000000..599a1923 --- /dev/null +++ b/idl/IPrintable_DBoolean.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DBoolean", + using_doxygen: true, + repr: "DBoolean", + doc: [ "implement APrintable for DBoolean" ], +} diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp new file mode 100644 index 00000000..e951cfba --- /dev/null +++ b/include/xo/object2/DBoolean.hpp @@ -0,0 +1,57 @@ +/** @file DBoolean.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include +#include +#include +#include +#include + +namespace xo { + namespace scm { + struct DBoolean { + using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; + using ppindentinfo = xo::print::ppindentinfo; + using value_type = long; + + explicit DBoolean(bool x) : value_{x} {} + + /** will likely want this to default to ANumeric, once we have it **/ + template + static obj box(obj mm, bool x); + + /** allocate boxed value @p x using memory from @p mm **/ + static DBoolean * _box(obj mm, bool x); + + bool value() const noexcept { return value_; } + + bool pretty(const ppindentinfo & ppii) const; + + operator bool() const noexcept { return value_; } + + // GCObject facet + + std::size_t shallow_size() const noexcept; + DBoolean * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + private: + /** boxed boolean value **/ + bool value_; + }; + + template + obj + DBoolean::box(obj mm, bool x) { + return obj(_box(mm, x)); + } + + } /*nmaespace obj*/ +} /*namespace xo*/ + +/* end DBoolean.hpp */ diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp new file mode 100644 index 00000000..e075874c --- /dev/null +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DBoolean.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DBoolean.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DBoolean.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DBoolean.hpp" + +namespace xo { namespace scm { class IGCObject_DBoolean; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DBoolean + **/ + class IGCObject_DBoolean { + public: + /** @defgroup scm-gcobject-dboolean-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dboolean-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DBoolean & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DBoolean & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DBoolean & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/object2/boolean/IPrintable_DBoolean.hpp b/include/xo/object2/boolean/IPrintable_DBoolean.hpp new file mode 100644 index 00000000..e17f169a --- /dev/null +++ b/include/xo/object2/boolean/IPrintable_DBoolean.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DBoolean.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DBoolean.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DBoolean.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DBoolean.hpp" + +namespace xo { namespace scm { class IPrintable_DBoolean; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DBoolean + **/ + class IPrintable_DBoolean { + public: + /** @defgroup scm-printable-dboolean-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dboolean-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DBoolean & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index a87c349b..430e50c2 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -4,6 +4,7 @@ set(SELF_LIB xo_object2) set(SELF_SRCS IGCObject_DArray.cpp IGCObject_DFloat.cpp + IGCObject_DBoolean.cpp IGCObject_DInteger.cpp IGCObject_DList.cpp IGCObject_DString.cpp @@ -11,6 +12,7 @@ set(SELF_SRCS ISequence_DArray.cpp ISequence_DList.cpp IPrintable_DList.cpp + IPrintable_DBoolean.cpp IPrintable_DFloat.cpp IPrintable_DInteger.cpp IPrintable_DString.cpp @@ -18,6 +20,7 @@ set(SELF_SRCS DList.cpp DFloat.cpp DInteger.cpp + DBoolean.cpp DString.cpp init_object2.cpp object2_register_types.cpp diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp new file mode 100644 index 00000000..341e656d --- /dev/null +++ b/src/object2/DBoolean.cpp @@ -0,0 +1,57 @@ +/** @file DBoolean.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DBoolean.hpp" +#include +#include + +namespace xo { + using xo::facet::typeseq; + using xo::print::ppdetail_atomic; + + namespace scm { + DBoolean * + DBoolean::_box(obj mm, bool x) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DBoolean)); + + return new (mem) DBoolean(x); + } + + bool + DBoolean::pretty(const ppindentinfo & ppii) const + { + return ppdetail_atomic::print_pretty(ppii, value_); + } + + size_t + DBoolean::shallow_size() const noexcept + { + return sizeof(DBoolean); + } + + DBoolean * + DBoolean::shallow_copy(obj mm) const noexcept + { + DBoolean * copy = (DBoolean *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + size_t + DBoolean::forward_children(obj) noexcept + { + return shallow_size(); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DBoolean.cpp */ diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp new file mode 100644 index 00000000..72aa0b1b --- /dev/null +++ b/src/object2/IGCObject_DBoolean.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DBoolean.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DBoolean.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DBoolean.json5] +**/ + +#include "boolean/IGCObject_DBoolean.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DBoolean::shallow_size(const DBoolean & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DBoolean::shallow_copy(const DBoolean & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DBoolean::forward_children(DBoolean & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DBoolean.cpp */ \ No newline at end of file diff --git a/src/object2/IPrintable_DBoolean.cpp b/src/object2/IPrintable_DBoolean.cpp new file mode 100644 index 00000000..d8fddd87 --- /dev/null +++ b/src/object2/IPrintable_DBoolean.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DBoolean.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DBoolean.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DBoolean.json5] +**/ + +#include "boolean/IPrintable_DBoolean.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DBoolean::pretty(const DBoolean & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DBoolean.cpp */ \ No newline at end of file diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 93438600..ebf320c4 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -7,11 +7,13 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -29,9 +31,11 @@ namespace xo { using xo::mm::AAllocator; using xo::mm::AGCObject; using xo::scm::DList; + using xo::scm::DBoolean; using xo::scm::DFloat; using xo::scm::DString; using xo::scm::DArray; + using xo::facet::DVariantPlaceholder; using xo::facet::FacetRegistry; using xo::facet::typeseq; @@ -45,6 +49,9 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -57,7 +64,10 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + log && log(xtag("DVariantPlaceholder.tseq", typeseq::id())); + log && log(xtag("DList.tseq", typeseq::id())); + log && log(xtag("DBoolean.tseq", typeseq::id())); log && log(xtag("DFloat.tseq", typeseq::id())); log && log(xtag("DInteger.tseq", typeseq::id())); log && log(xtag("DString.tseq", typeseq::id())); diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index c2079a40..275995f8 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -5,6 +5,7 @@ #include "object2_register_types.hpp" +#include "boolean/IGCObject_DBoolean.hpp" #include "number/IGCObject_DFloat.hpp" #include "number/IGCObject_DInteger.hpp" #include "string/IGCObject_DString.hpp" @@ -33,6 +34,8 @@ namespace xo { bool ok = true; + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); From 29a2f9b7c93341beb9d1a7f978832a80b484ba61 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 23 Jan 2026 16:34:33 -0500 Subject: [PATCH 083/176] xo-reader2: fix clearing result in SchematikaReader --- include/xo/object2/DBoolean.hpp | 2 +- src/object2/DBoolean.cpp | 4 +++- src/object2/object2_register_facets.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index e951cfba..69dd1c16 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -42,7 +42,7 @@ namespace xo { private: /** boxed boolean value **/ - bool value_; + bool value_ = false; }; template diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp index 341e656d..a926b0ec 100644 --- a/src/object2/DBoolean.cpp +++ b/src/object2/DBoolean.cpp @@ -24,7 +24,9 @@ namespace xo { bool DBoolean::pretty(const ppindentinfo & ppii) const { - return ppdetail_atomic::print_pretty(ppii, value_); + return ppdetail_atomic::print_pretty + (ppii, + (value_ ? "true" : "false")); } size_t diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index ebf320c4..be68e009 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -67,7 +67,7 @@ namespace xo { log && log(xtag("DVariantPlaceholder.tseq", typeseq::id())); log && log(xtag("DList.tseq", typeseq::id())); - log && log(xtag("DBoolean.tseq", typeseq::id())); + log && log(xtag("DBoolean.tseq", typeseq::id())); log && log(xtag("DFloat.tseq", typeseq::id())); log && log(xtag("DInteger.tseq", typeseq::id())); log && log(xtag("DString.tseq", typeseq::id())); From eeb36655aab87609c72bfd308808a13a6f5cabf1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 25 Jan 2026 10:03:41 -0500 Subject: [PATCH 084/176] xo-object2: + DString.from_str() --- include/xo/object2/DString.hpp | 6 ++++++ src/object2/DString.cpp | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index eea8ea5c..a6cedb00 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -78,6 +78,12 @@ namespace xo { static DString * from_view(obj mm, std::string_view sv); + /** create string containing a copy @p str. + * Use memory from allocator @p mm. + **/ + static DString * from_str(obj mm, + const std::string & str); + /** create string containing a copy of @p sv. * Use memory from allocator @p mm via sub_alloc. * (load-bearing for StringTable) diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index ee9885b7..69baa5d6 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -91,6 +91,15 @@ namespace xo { return _from_view_aux(mm, sv, false /*!suballoc_flag*/); } + DString * + DString::from_str(obj mm, + const std::string & str) + { + return _from_view_aux(mm, + std::string_view(str), + false /*!suballoc_flag*/); + } + DString * DString::from_view_suballoc(obj mm, std::string_view sv) From 24dc68c2dbff82b26a9f80883a7190581cb65e10 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 25 Jan 2026 10:08:32 -0500 Subject: [PATCH 085/176] xo-object2: doc: + glossary.rst --- doc/glossary.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/glossary.rst diff --git a/doc/glossary.rst b/doc/glossary.rst new file mode 100644 index 00000000..4cabbbd5 --- /dev/null +++ b/doc/glossary.rst @@ -0,0 +1 @@ +gco = gc-aware object From 6605b459f3ea066ec6faee8d4833e28a972118c6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 25 Jan 2026 10:13:22 -0500 Subject: [PATCH 086/176] xo-object2: GCObjectConversion for double (via DFloat) --- cmake/xo_object2Config.cmake.in | 1 + .../number/GCObjectConversion_DFloat.hpp | 29 +++++++++++++ src/object2/CMakeLists.txt | 8 ++-- src/object2/GCObjectConversion_DFloat.cpp | 41 +++++++++++++++++++ 4 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 include/xo/object2/number/GCObjectConversion_DFloat.hpp create mode 100644 src/object2/GCObjectConversion_DFloat.cpp diff --git a/cmake/xo_object2Config.cmake.in b/cmake/xo_object2Config.cmake.in index 36d3bb62..6773adb7 100644 --- a/cmake/xo_object2Config.cmake.in +++ b/cmake/xo_object2Config.cmake.in @@ -1,6 +1,7 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) +find_dependency(reflect) find_dependency(xo_gc) find_dependency(xo_printable2) find_dependency(subsys) diff --git a/include/xo/object2/number/GCObjectConversion_DFloat.hpp b/include/xo/object2/number/GCObjectConversion_DFloat.hpp new file mode 100644 index 00000000..8ce4b2b6 --- /dev/null +++ b/include/xo/object2/number/GCObjectConversion_DFloat.hpp @@ -0,0 +1,29 @@ +/** @file GCObjectConversion_DFloat.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "DFloat.hpp" +#include "number/IGCObject_DFloat.hpp" +#include + +namespace xo { + namespace scm { + + template <> + struct GCObjectConversion { + static_assert(std::is_same_v); + + using AGCObject = xo::mm::AGCObject; + using AAllocator = xo::mm::AAllocator; + + static obj to_gco(obj mm, const double & x); + static double from_gco(obj mm, obj gco); + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end GCObjectConversion_DFloat.hpp */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 430e50c2..2902a4ee 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -2,6 +2,10 @@ set(SELF_LIB xo_object2) set(SELF_SRCS + init_object2.cpp + object2_register_types.cpp + object2_register_facets.cpp + GCObjectConversion_DFloat.cpp IGCObject_DArray.cpp IGCObject_DFloat.cpp IGCObject_DBoolean.cpp @@ -22,13 +26,11 @@ set(SELF_SRCS DInteger.cpp DBoolean.cpp DString.cpp - init_object2.cpp - object2_register_types.cpp - object2_register_facets.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) # note: deps here must also appear in cmake/xo_object2Config.cmake.in +xo_dependency(${SELF_LIB} reflect) xo_dependency(${SELF_LIB} xo_gc) xo_dependency(${SELF_LIB} xo_printable2) xo_dependency(${SELF_LIB} subsys) diff --git a/src/object2/GCObjectConversion_DFloat.cpp b/src/object2/GCObjectConversion_DFloat.cpp new file mode 100644 index 00000000..a99c68ce --- /dev/null +++ b/src/object2/GCObjectConversion_DFloat.cpp @@ -0,0 +1,41 @@ +/** @file GCObjectConversion_DFloat.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "number/GCObjectConversion_DFloat.hpp" +#include + +namespace xo { + using xo::mm::AGCObject; + + namespace scm { + + obj + GCObjectConversion::to_gco(obj mm, + const double & x) + { + return DFloat::box(mm, x); + } + + double + GCObjectConversion::from_gco(obj mm, + obj gco) + { + (void)mm; + + auto float_obj = obj::from(gco); + + if (!float_obj) { + throw std::runtime_error + (tostr("Object obj found where Float expected", + xtag("obj", gco))); + } + + return float_obj.data()->value(); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end GCObjectConversion_DFloat.cpp */ From 7ab8d4e82125c9fb252adf7f1140aa9dc81d7b0a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 25 Jan 2026 10:14:00 -0500 Subject: [PATCH 087/176] xo-object2: add DFloat conversion header in gen .hpp --- idl/IGCObject_DFloat.json5 | 1 + 1 file changed, 1 insertion(+) diff --git a/idl/IGCObject_DFloat.json5 b/idl/IGCObject_DFloat.json5 index 6120808b..9aba2a34 100644 --- a/idl/IGCObject_DFloat.json5 +++ b/idl/IGCObject_DFloat.json5 @@ -1,6 +1,7 @@ { mode: "implementation", includes: [ + "", "", "" ], From eef4a1db5d93b7e4a8b1fbb3b095ca017310768f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 12:38:17 -0500 Subject: [PATCH 088/176] xo-procedure2 xo-object2: + polymorphic primitive support --- include/xo/object2/DArray.hpp | 2 +- .../number/GCObjectConversion_DFloat.hpp | 2 +- .../number/GCObjectConversion_DInteger.hpp | 29 +++++++++++++ src/object2/CMakeLists.txt | 1 + src/object2/GCObjectConversion_DFloat.cpp | 2 +- src/object2/GCObjectConversion_DInteger.cpp | 41 +++++++++++++++++++ 6 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 include/xo/object2/number/GCObjectConversion_DInteger.hpp create mode 100644 src/object2/GCObjectConversion_DInteger.cpp diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 0dc13cd1..097b9a45 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -23,7 +23,7 @@ namespace xo { * fixed at construction time, but not part of type. * Can reallocate to change **/ - struct DArray { + class DArray { public: /** @defgroup darray-types type traits **/ ///@{ diff --git a/include/xo/object2/number/GCObjectConversion_DFloat.hpp b/include/xo/object2/number/GCObjectConversion_DFloat.hpp index 8ce4b2b6..959eeca0 100644 --- a/include/xo/object2/number/GCObjectConversion_DFloat.hpp +++ b/include/xo/object2/number/GCObjectConversion_DFloat.hpp @@ -19,7 +19,7 @@ namespace xo { using AGCObject = xo::mm::AGCObject; using AAllocator = xo::mm::AAllocator; - static obj to_gco(obj mm, const double & x); + static obj to_gco(obj mm, double x); static double from_gco(obj mm, obj gco); }; diff --git a/include/xo/object2/number/GCObjectConversion_DInteger.hpp b/include/xo/object2/number/GCObjectConversion_DInteger.hpp new file mode 100644 index 00000000..458312c9 --- /dev/null +++ b/include/xo/object2/number/GCObjectConversion_DInteger.hpp @@ -0,0 +1,29 @@ +/** @file GCObjectConversion_DInteger.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "DInteger.hpp" +#include "number/IGCObject_DInteger.hpp" +#include + +namespace xo { + namespace scm { + + template <> + struct GCObjectConversion { + static_assert(std::is_same_v); + + using AGCObject = xo::mm::AGCObject; + using AAllocator = xo::mm::AAllocator; + + static obj to_gco(obj mm, long x); + static long from_gco(obj mm, obj gco); + }; + + } +} /*namespace xo*/ + +/* end GCObjectConversion_DInteger.hpp */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 2902a4ee..2ea8a07f 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -6,6 +6,7 @@ set(SELF_SRCS object2_register_types.cpp object2_register_facets.cpp GCObjectConversion_DFloat.cpp + GCObjectConversion_DInteger.cpp IGCObject_DArray.cpp IGCObject_DFloat.cpp IGCObject_DBoolean.cpp diff --git a/src/object2/GCObjectConversion_DFloat.cpp b/src/object2/GCObjectConversion_DFloat.cpp index a99c68ce..794431d2 100644 --- a/src/object2/GCObjectConversion_DFloat.cpp +++ b/src/object2/GCObjectConversion_DFloat.cpp @@ -13,7 +13,7 @@ namespace xo { obj GCObjectConversion::to_gco(obj mm, - const double & x) + double x) { return DFloat::box(mm, x); } diff --git a/src/object2/GCObjectConversion_DInteger.cpp b/src/object2/GCObjectConversion_DInteger.cpp new file mode 100644 index 00000000..bdaf8a18 --- /dev/null +++ b/src/object2/GCObjectConversion_DInteger.cpp @@ -0,0 +1,41 @@ +/** @file GCObjectConversion_DInteger.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "number/GCObjectConversion_DInteger.hpp" +#include + +namespace xo { + using xo::mm::AGCObject; + + namespace scm { + + obj + GCObjectConversion::to_gco(obj mm, + long x) + { + return DInteger::box(mm, x); + } + + long + GCObjectConversion::from_gco(obj mm, + obj gco) + { + (void)mm; + + auto int_obj = obj::from(gco); + + if (!int_obj) { + throw std::runtime_error + (tostr("Object obj found where Integer expected", + xtag("obj", gco))); + } + + return int_obj.data()->value(); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end GCObjectConversion_DFloat.cpp */ From 19961facb54e077f4bf121d68444cbe03b5ad324 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 29 Jan 2026 15:12:00 -0500 Subject: [PATCH 089/176] xo-object2: implement APrintable for DArray --- CMakeLists.txt | 12 ++++++ include/xo/object2/DArray.hpp | 3 ++ .../xo/object2/number/IGCObject_DFloat.hpp | 1 + src/object2/CMakeLists.txt | 1 + src/object2/DArray.cpp | 41 +++++++++++++++++++ 5 files changed, 58 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 261b59df..83b24223 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,6 +184,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-array + FACET_PKG xo_printable2 + FACET Printable + REPR Array + INPUT idl/IPrintable_DArray.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR array + OUTPUT_CPP_DIR src/object2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-array diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 097b9a45..f50936e3 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -108,6 +108,9 @@ namespace xo { /** @defgroup darray-printable-methods **/ ///@{ + /** pretty-printing support **/ + bool pretty(const ppindentinfo & ppii) const; + ///@} /** @defgroup darray-gcobject-methods **/ ///@{ diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index b27163c2..a5a01fff 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -14,6 +14,7 @@ #pragma once #include "GCObject.hpp" +#include #include #include #include "DFloat.hpp" diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 2ea8a07f..609290e8 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -16,6 +16,7 @@ set(SELF_SRCS ISequence_Any.cpp ISequence_DArray.cpp ISequence_DList.cpp + IPrintable_DArray.cpp IPrintable_DList.cpp IPrintable_DBoolean.cpp IPrintable_DFloat.cpp diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 1b4138c6..b1343a67 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -4,11 +4,16 @@ **/ #include "DArray.hpp" +#include +#include +#include #include #include #include namespace xo { + using xo::print::APrintable; + using xo::facet::FacetRegistry; using xo::mm::AGCObject; using xo::facet::typeseq; @@ -62,6 +67,42 @@ namespace xo { } } + // printing support + + bool + DArray::pretty(const ppindentinfo & ppii) const + { + using xo::print::ppstate; + + ppstate * pps = ppii.pps(); + + if (ppii.upto()) { + /* perhaps print on one line */ + pps->write("["); + + for (size_t i = 0, n = this->size(); i < n; ++i ) { + if (i > 0) + pps->write(" "); + + obj elt + = FacetRegistry::instance().variant(this->at(i)); + + assert(elt.data()); + + if (!pps->print_upto(elt)) + return false; + + ++i; + } + + pps->write("]"); + return true; + } else { + pps->write("[...]"); + return false; + } + } + // gc hooks for IGCObject_DArray std::size_t From 9ec403b2d7286e8bcb283c373acaf0b10ab9a073 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 29 Jan 2026 15:17:57 -0500 Subject: [PATCH 090/176] xo-reader2: + PSM,SSM on_parsed_formal_arglist() --- src/object2/object2_register_facets.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index be68e009..a910e276 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -62,6 +63,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); log && log(xtag("DVariantPlaceholder.tseq", typeseq::id())); From 200b967552f733cda5fcdc4674f145a354de4ee4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 29 Jan 2026 15:19:35 -0500 Subject: [PATCH 091/176] xo-object2: missed generated (Printable,Array) code + .json5 --- idl/IPrintable_DArray.json5 | 13 ++++ .../xo/object2/array/IPrintable_DArray.hpp | 62 +++++++++++++++++++ src/object2/IPrintable_DArray.cpp | 28 +++++++++ 3 files changed, 103 insertions(+) create mode 100644 idl/IPrintable_DArray.json5 create mode 100644 include/xo/object2/array/IPrintable_DArray.hpp create mode 100644 src/object2/IPrintable_DArray.cpp diff --git a/idl/IPrintable_DArray.json5 b/idl/IPrintable_DArray.json5 new file mode 100644 index 00000000..df0ef171 --- /dev/null +++ b/idl/IPrintable_DArray.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DArray", + using_doxygen: true, + repr: "DArray", + doc: [ "implement APrintable for DArray" ], +} diff --git a/include/xo/object2/array/IPrintable_DArray.hpp b/include/xo/object2/array/IPrintable_DArray.hpp new file mode 100644 index 00000000..1b3a4663 --- /dev/null +++ b/include/xo/object2/array/IPrintable_DArray.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DArray.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DArray.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DArray.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DArray.hpp" + +namespace xo { namespace scm { class IPrintable_DArray; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DArray + **/ + class IPrintable_DArray { + public: + /** @defgroup scm-printable-darray-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-darray-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DArray & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/IPrintable_DArray.cpp b/src/object2/IPrintable_DArray.cpp new file mode 100644 index 00000000..d444800b --- /dev/null +++ b/src/object2/IPrintable_DArray.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DArray.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DArray.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DArray.json5] +**/ + +#include "array/IPrintable_DArray.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DArray::pretty(const DArray & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DArray.cpp */ \ No newline at end of file From 0a7b2bec12476c729bbcf90dcf7b3b25fac41e05 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 30 Jan 2026 20:08:41 -0500 Subject: [PATCH 092/176] xo-expression2 xo-reader2 DSequenceExpr, DSequenceSsm [WIP] --- include/xo/object2/DArray.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index f50936e3..e95f67f6 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -68,6 +68,8 @@ namespace xo { requires (std::same_as> && ...) static DArray * array(obj mm, Args... args); + obj operator[](size_type index) const noexcept { return elts_[index]; } + ///@} /** @defgroup darray-access acecss methods **/ ///@{ From a0c27ca5bdbe1df918a97684b4e17471b542fe7f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 31 Jan 2026 01:13:26 -0500 Subject: [PATCH 093/176] xo-objecdt2: bugfix: dup loop increment --- src/object2/DArray.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index b1343a67..65162511 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -91,8 +91,6 @@ namespace xo { if (!pps->print_upto(elt)) return false; - - ++i; } pps->write("]"); From 1da2d17c3095520a74fe93a5448281857da791df Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 31 Jan 2026 01:44:53 -0500 Subject: [PATCH 094/176] xo-expression2 xo-gc: DSequenceExpr builds [WIP] --- include/xo/object2/GCObjectConverter.hpp | 158 ++++++++++++++ src/object2/GCObjectConverter.cpp | 258 +++++++++++++++++++++++ 2 files changed, 416 insertions(+) create mode 100644 include/xo/object2/GCObjectConverter.hpp create mode 100644 src/object2/GCObjectConverter.cpp diff --git a/include/xo/object2/GCObjectConverter.hpp b/include/xo/object2/GCObjectConverter.hpp new file mode 100644 index 00000000..bf244f48 --- /dev/null +++ b/include/xo/object2/GCObjectConverter.hpp @@ -0,0 +1,158 @@ +/** @file GCObjectConverter.hpp + * + * @author Roland Conybeare, Nov 2025 + **/ + +#pragma once + +#include +#include +#include +//#include "xo/reflect/TaggedPtr.hpp" +#include + +namespace xo { + namespace scm { + /* Convert between xo::reflect::TaggedPtr and xo::Object for + * a particular wrapped c++ type + */ + struct Converter { + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + using TaggedPtr = xo::reflect::TaggedPtr; + /** convert from some reflected T* @p src to + * obj dest + * using memory from allocator @p mm + **/ + using ConvertToObjectFn = obj (*)(obj mm, + TaggedPtr src); + /** convert from obj @p src to some refected T* @p dest + * using memory from allocator @p mm. + * + * NOTE: obj is gc-aware -> will likely reside in + * a collected memory region. + **/ + using ConvertFromObjectFn = TaggedPtr (*)(obj mm, + obj obj); + + public: + Converter() = default; + explicit Converter(ConvertToObjectFn to, + ConvertFromObjectFn from) + : cvt_to_object_{to}, + cvt_from_object_{from} + {} + + /** convert tagged pointer @p tp to new object, + * allocated via @p mm. + * + * Conversion will typically be for some specific type; + * see @ref ObjectConverter + **/ + ConvertToObjectFn cvt_to_object_ = nullptr; + + /** convert object to tagged pointer @p, + * allocated via @p mm. + * + * Conversion will typically be for some specific type; + * see @ref ObjectConverter + **/ + ConvertFromObjectFn cvt_from_object_ = nullptr; + }; + + /** @class ObjectConverter + * @brief Conversion to/from Object + * + * For some instance of type T: + * + * @code + * ObjectConverter & converters = ...; + * T x = ...; + * TaggedPtr tp = Reflect::make_tp(&x); + * TypeId tid = tp.td()->id(); + * + * const Converter * cvt = converters.cvt_.lookup(tid); + * + * if (cvt) { + * // cvt is a converter for T instances + * gp obj = (*(cvt->cvt_to_object_))(mm, + * @endcode + **/ + class ObjectConverter { + public: + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + using Reflect = xo::reflect::Reflect; + using TaggedPtr = xo::reflect::TaggedPtr; + using TypeId = xo::reflect::TypeId; + + /** sets up standard conversions **/ + ObjectConverter(); + + /** singleton instance **/ + static const ObjectConverter & instance(); + + /** establish conversion: use @p fn to convert values of type @tparam T. **/ + template + void establish_conversion(Converter::ConvertToObjectFn to, + Converter::ConvertFromObjectFn from); + + /** convert tagged poitner @p tp to object. allocates memory only from @p mm. + * return nullptr if no converter available and @p throw_flag not set. + * throw exception if no converter available and @p throw_flag set. + **/ + obj tp_to_gco(obj mm, + TaggedPtr tp, + bool throw_flag) const; + + /** convert @p x to object. + * return converted object; if allocated, using only memory from @p mm. + * return nullptr if no converter available, and @p throw_flag not set. + * throw exception if no converter available, and @p throw_flag set. + **/ + template + obj to_gco(obj mm, const T & x, bool throw_flag); + + /** convert object @p obj to tagged pointer, with typeid @p target_id. + * Allocates memory only from @p mm. + * return null TaggedPtr if no converter available and @p throw_flag not set. + * Throw exception if no converter available and @p throw_flag set. + **/ + TaggedPtr tp_from_gco(obj mm, + obj obj, + TypeId target_type_id, + bool throw_flag) const; + + private: + /** expandable type-driven conversion table. + **/ + xo::reflect::TypeDrivenMap cvt_; + }; + + template + void + ObjectConverter::establish_conversion(Converter::ConvertToObjectFn to, + Converter::ConvertFromObjectFn from) + { + using xo::reflect::TypeDescrW; + using xo::reflect::Reflect; + + TypeDescrW td = Reflect::require(); + Converter * cvt = cvt_.require(td); + + *cvt = Converter(to, from); + } + + template + auto + ObjectConverter::to_gco(obj mm, const T & x, bool throw_flag) + -> obj + { + TaggedPtr x_tp = Reflect::make_tp(&x); + + return tp_to_gco(mm, x_tp, throw_flag); + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end GCObjectConverter.hpp */ diff --git a/src/object2/GCObjectConverter.cpp b/src/object2/GCObjectConverter.cpp new file mode 100644 index 00000000..6f3f5b4a --- /dev/null +++ b/src/object2/GCObjectConverter.cpp @@ -0,0 +1,258 @@ +/** @file GCObjectConverter.cpp + * + * @author Roland Conybeare, Nov 2025 + **/ + +#include "GCObjectConverter.hpp" + +#include "DInteger.hpp" +#include "number/IGCObject_DInteger.hpp" + +#include "DFloat.hpp" +#include "number/IGCObject_DFloat.hpp" + +#include "DBoolean.hpp" +#include "boolean/IGCObject_DBoolean.hpp" + +#include "DString.hpp" +#include "string/IGCObject_DString.hpp" + +#include +#include +//#include "xo/alloc/Blob.hpp" + +namespace xo { + using xo::mm::AGCObject; + using xo::reflect::Reflect; + using xo::reflect::TaggedPtr; + using xo::reflect::TypeId; + using xo::facet::obj; + using xo::facet::typeseq; + using xo::mm::AAllocator; + + namespace scm { + namespace { + // DInteger <-> T + + template + obj + int_to_gco(obj mm, TaggedPtr src) + { + T * native = src.recover_native(); + + assert(native); + + return DInteger::box(mm, *native); + } + + template + TaggedPtr + gco_to_int(obj mm, + obj obj) + { + + /* mm cannot be GC allocator! + * That's Object-only + */ + + auto int_obj = xo::facet::obj::from(obj); //Integer::from(obj); + + if (!int_obj) { + throw std::runtime_error + (tostr("Object obj found where Integer expected", + xtag("obj", obj))); + } + + void * mem = mm.alloc(typeseq::id(), sizeof(T)); + + T * p = reinterpret_cast(mem); + + *p = int_obj.data()->value(); + + /* Note: + * retval invalidated when + * *mm cleared/recycled/collected + */ + + return Reflect::make_tp(p); + } + + // DFloat <-> T + + template + xo::facet::obj + float_to_gco(xo::facet::obj mm, + TaggedPtr src) + { + T * native = src.recover_native(); + + assert(native); + + return DFloat::box(mm, *native); + } + + template + TaggedPtr + gco_to_float(obj mm, obj obj) + { + auto float_obj = xo::facet::obj::from(obj); + + if (!float_obj) { + throw std::runtime_error + (tostr("Object obj found where Float expected", + xtag("obj", obj))); + } + + void * mem = mm.alloc(typeseq::id(), sizeof(T)); + + T * p = reinterpret_cast(mem); + + *p = float_obj.data()->value(); + + /* Note: + * retval invalidated when *mm cleared/recycled/collected + */ + + return Reflect::make_tp(p); + } + + // DBoolean <-> T + + obj + bool_to_gco(obj mm, TaggedPtr src) + { + bool * native = src.recover_native(); + + assert(native); + + return DBoolean::box(mm, *native); + } + + TaggedPtr + gco_to_bool(obj /*mm*/, + obj obj) + { + static bool s_true = true; + static bool s_false = false; + + auto bool_obj = xo::facet::obj::from(obj); + + if (!bool_obj) { + throw std::runtime_error + (tostr("Object obj found where Boolean expected", + xtag("obj", obj))); + } + + return Reflect::make_tp(bool_obj.data()->value() ? &s_true : &s_false); + } + + // DString <-> T + // w/ + // T = std::string + + obj + string_to_gco(obj mm, TaggedPtr src) + { + // try std::string.. + + std::string * native = src.recover_native(); + + assert(native); + + DString * dstr = DString::from_str(mm, *native); + + return xo::facet::obj(dstr); + } + + TaggedPtr + gco_to_string(obj mm, obj obj) + { + auto string_obj = xo::facet::obj::from(obj); + + if (!string_obj) { + throw std::runtime_error + (tostr("Object obj founcd where String expected", + xtag("obj", obj))); + } + + // still don't have impl for this + // Need regular std::allocator interface + // + + (void)mm; + assert(false); + } + } + + ObjectConverter::ObjectConverter() + { + this->establish_conversion(&int_to_gco, + &gco_to_int); + this->establish_conversion(&int_to_gco, + &gco_to_int); + + this->establish_conversion(&float_to_gco, + &gco_to_float); + + this->establish_conversion(&bool_to_gco, + &gco_to_bool); + + this->establish_conversion(&string_to_gco, + &gco_to_string); + } + + const ObjectConverter & + ObjectConverter::instance() { + static ObjectConverter s_instance; + + return s_instance; + } + + obj + ObjectConverter::tp_to_gco(obj mm, + TaggedPtr x_tp, + bool throw_flag) const + { + using xo::reflect::Reflect; + using xo::reflect::TaggedPtr; + + const Converter * cvt = cvt_.lookup(x_tp.td()); + + if (cvt) { + return (cvt->cvt_to_object_)(mm, x_tp); + } else { + if (throw_flag) { + throw std::runtime_error + (tostr("no to-object-converter available for instance of type", + xtag("id", x_tp.td()->id()), + xtag("name", x_tp.td()->short_name()))); + } + + return obj(); + } + } + + TaggedPtr + ObjectConverter::tp_from_gco(obj mm, + obj obj, + TypeId target_id, + bool throw_flag) const + { + const Converter * cvt = cvt_.lookup(target_id); + + if (cvt) { + return (cvt->cvt_from_object_)(mm, obj); + } else { + if (throw_flag) { + throw std::runtime_error + (tostr("no from-object-converter available for instance of type", + xtag("id", target_id))); + } + + return TaggedPtr::universal_null(); + } + } + } +} + +/* end GCObjectConverter.cpp */ From 26f931cd9c78deb0a2ccc79b4b1adf91cef7a601 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 1 Feb 2026 22:12:28 -0500 Subject: [PATCH 095/176] xo-interpreter2: work towards utest w/ vsm+reader [WIP] --- utest/Printable.test.cpp | 19 +++++++++---------- utest/X1Collector.test.cpp | 21 ++++++++++----------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index 6c09ca90..64736d22 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -44,7 +44,7 @@ namespace ut { using xo::mm::ACollector; using xo::mm::AGCObject; using xo::mm::DX1Collector; - using xo::mm::CollectorConfig; + using xo::mm::X1CollectorConfig; using xo::mm::ArenaConfig; using xo::print::APrintable; using xo::facet::FacetRegistry; @@ -99,15 +99,14 @@ namespace ut { try { const testcase_pp & tc = s_testcase_v[i_tc]; - CollectorConfig cfg{ - .name_ = "pp_test", - .arena_config_ = ArenaConfig{ - .size_ = tc.gc_gen_size_, - .store_header_flag_ = true}, - .object_types_z_ = 16384, - .gc_trigger_v_{{tc.gc_trigger_threshold_, - tc.gc_trigger_threshold_}}, - .debug_flag_ = c_debug_flag + X1CollectorConfig cfg{ .name_ = "pp_test", + .arena_config_ = ArenaConfig{ + .size_ = tc.gc_gen_size_, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{tc.gc_trigger_threshold_, + tc.gc_trigger_threshold_}}, + .debug_flag_ = c_debug_flag }; DX1Collector gc(cfg); diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 0f20e68a..90122c25 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -48,7 +48,7 @@ namespace ut { using xo::mm::AGCObject; using xo::mm::DX1Collector; using xo::mm::DArena; - using xo::mm::CollectorConfig; + using xo::mm::X1CollectorConfig; using xo::mm::ArenaConfig; using xo::mm::generation; using xo::mm::role; @@ -108,16 +108,15 @@ namespace ut { try { const testcase_x1 & tc = s_testcase_v[i_tc]; - CollectorConfig cfg{ - .name_ = "x1_test", - .arena_config_ = ArenaConfig{ - .size_ = tc.tenured_z_, - .store_header_flag_ = true}, - .object_types_z_ = 16384, - .gc_trigger_v_{{ - tc.incr_gc_threshold_, - tc.full_gc_threshold_}}, - .debug_flag_ = c_debug_flag, + X1CollectorConfig cfg{ .name_ = "x1_test", + .arena_config_ = ArenaConfig{ + .size_ = tc.tenured_z_, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{ + tc.incr_gc_threshold_, + tc.full_gc_threshold_}}, + .debug_flag_ = c_debug_flag, }; DX1Collector gc(cfg); From 019ef5a3a7ae96f3d395aa3c60c116f1f3284c40 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 11:55:50 -0500 Subject: [PATCH 096/176] xo-interpreter2 stack: cleanup memory reporting --- include/xo/object2/init_object2.hpp | 2 +- src/object2/init_object2.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/xo/object2/init_object2.hpp b/include/xo/object2/init_object2.hpp index 5c26e76d..aa3dd510 100644 --- a/include/xo/object2/init_object2.hpp +++ b/include/xo/object2/init_object2.hpp @@ -1,5 +1,5 @@ /** @file init_object2.hpp -* + * * @author Roland Conybeare, Jan 2026 **/ diff --git a/src/object2/init_object2.cpp b/src/object2/init_object2.cpp index b5e57aba..0f804fe0 100644 --- a/src/object2/init_object2.cpp +++ b/src/object2/init_object2.cpp @@ -1,5 +1,5 @@ /** @file init_object2.cpp -* + * * @author Roland Conybeare, Jan 2026 **/ From dde29946d528149b8ababf0d8a35bd3c280f8ade Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 13:23:38 -0500 Subject: [PATCH 097/176] xo-reader2 stack: misc qol improvements + improve reader2 utest --- include/xo/object2/DInteger.hpp | 2 +- include/xo/object2/Integer.hpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 include/xo/object2/Integer.hpp diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index c56a4be1..b03693be 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -28,7 +28,7 @@ namespace xo { /** allocate boxed value @p x using memory from @p mm **/ static DInteger * _box(obj mm, long x); - double value() const noexcept { return value_; } + long value() const noexcept { return value_; } bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/object2/Integer.hpp b/include/xo/object2/Integer.hpp new file mode 100644 index 00000000..7279f97d --- /dev/null +++ b/include/xo/object2/Integer.hpp @@ -0,0 +1,12 @@ +/** @file Integer.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DInteger.hpp" +#include "number/IGCObject_DInteger.hpp" +#include "number/IPrintable_DInteger.hpp" + +/* end Integer.hpp */ From 2da4054e4d3c099a00f55e2426484c48190f4c22 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 13:43:00 -0500 Subject: [PATCH 098/176] xo-reader2 stack: convenience #includes + parsing examples --- include/xo/object2/Float.hpp | 12 ++++++++++++ include/xo/object2/String.hpp | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 include/xo/object2/Float.hpp create mode 100644 include/xo/object2/String.hpp diff --git a/include/xo/object2/Float.hpp b/include/xo/object2/Float.hpp new file mode 100644 index 00000000..94751ecf --- /dev/null +++ b/include/xo/object2/Float.hpp @@ -0,0 +1,12 @@ +/** @file Float.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DFloat.hpp" +#include "number/IGCObject_DFloat.hpp" +#include "number/IPrintable_DFloat.hpp" + +/* end Float.hpp */ diff --git a/include/xo/object2/String.hpp b/include/xo/object2/String.hpp new file mode 100644 index 00000000..b2e6d09b --- /dev/null +++ b/include/xo/object2/String.hpp @@ -0,0 +1,12 @@ +/** @file String.hpp + * + * @author Roland Conybeare, Feb 22026 + **/ + +#pragma once + +#include "DString.hpp" +#include "string/IGCObject_DString.hpp" +#include "string/IPrintable_DString.hpp" + +/* end String.hpp */ From 8b9a2e09d63768bf5ee1814e8065360fd8e79fa2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Feb 2026 16:26:19 -0500 Subject: [PATCH 099/176] xo-interpreter2: apply sequence now working in interpreter --- include/xo/object2/DArray.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index e95f67f6..c6f25221 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -68,7 +68,8 @@ namespace xo { requires (std::same_as> && ...) static DArray * array(obj mm, Args... args); - obj operator[](size_type index) const noexcept { return elts_[index]; } + const obj & operator[](size_type index) const noexcept { return elts_[index]; } + obj & operator[](size_type index) noexcept { return elts_[index]; } ///@} /** @defgroup darray-access acecss methods **/ From d8447d025e4d2d2808e18cb05d9e8607c4993dc3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Feb 2026 10:44:11 -0500 Subject: [PATCH 100/176] xo-interpreter2 stack: work on variable references [WIP] --- include/xo/object2/Boolean.hpp | 12 ++++++++++++ include/xo/object2/String.hpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 include/xo/object2/Boolean.hpp diff --git a/include/xo/object2/Boolean.hpp b/include/xo/object2/Boolean.hpp new file mode 100644 index 00000000..a246ffc0 --- /dev/null +++ b/include/xo/object2/Boolean.hpp @@ -0,0 +1,12 @@ +/** @file Boolean.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DBoolean.hpp" +#include "boolean/IGCObject_DBoolean.hpp" +#include "boolean/IPrintable_DBoolean.hpp" + +/* end Boolean.hpp */ diff --git a/include/xo/object2/String.hpp b/include/xo/object2/String.hpp index b2e6d09b..111b04fb 100644 --- a/include/xo/object2/String.hpp +++ b/include/xo/object2/String.hpp @@ -1,6 +1,6 @@ /** @file String.hpp * - * @author Roland Conybeare, Feb 22026 + * @author Roland Conybeare, Feb 2026 **/ #pragma once From b5d9fdd83d513ca0904caeed8caad978409cbf1b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Feb 2026 15:45:40 -0500 Subject: [PATCH 101/176] xo-reader2 stack: top-level lambda w/ apply parses --- src/object2/DArray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 65162511..401524e0 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -106,7 +106,7 @@ namespace xo { std::size_t DArray::shallow_size() const noexcept { - return sizeof(DArray); + return sizeof(DArray) + (capacity_ * sizeof(obj)); } DArray * From 44758bfed34567344ce67dcae8abba2703bb6cde Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 8 Feb 2026 01:01:03 -0500 Subject: [PATCH 102/176] xo-interpreter2 stack: work on VSM for apply -> closure action [WIP] --- include/xo/object2/Array.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 include/xo/object2/Array.hpp diff --git a/include/xo/object2/Array.hpp b/include/xo/object2/Array.hpp new file mode 100644 index 00000000..12c6eaa5 --- /dev/null +++ b/include/xo/object2/Array.hpp @@ -0,0 +1,14 @@ +/** @file Array.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DArray.hpp" +#include "array/ISequence_DArray.hpp" +#include "array/IGCObject_DArray.hpp" +#include "array/IPrintable_DArray.hpp" + + +/* end Array.hpp */ From e4373b08e26614376a0f638a57cf5fb86e1dbd90 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 8 Feb 2026 23:32:20 -0500 Subject: [PATCH 103/176] xo-interpreter2 stack: lambda expr -> closure runs in VSM utest --- src/object2/DArray.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 401524e0..cee62bca 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -1,5 +1,5 @@ /** @file DArray.cpp -* + * * @author Roland Conybeare, Jan 2026 **/ @@ -121,7 +121,9 @@ namespace xo { constexpr auto c_obj_z = sizeof(obj); /* memcpy sufficient for obj */ - ::memcpy((void*)&(copy->elts_[0]), (void*)&(elts_[0]), capacity_ * c_obj_z); + ::memcpy((void*)&(copy->elts_[0]), + (void*)&(elts_[0]), + capacity_ * c_obj_z); } return copy; From bdccb8bee30c47f8a7ee8883954732384ef66a3b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Feb 2026 18:46:43 -0500 Subject: [PATCH 104/176] xo-interpreter2 stack: work on runtime error representation [WIP] --- CMakeLists.txt | 28 +++++++ idl/IGCObject_DRuntimeError.json5 | 15 ++++ idl/IPrintable_DRuntimeError.json5 | 13 +++ include/xo/object2/DRuntimeError.hpp | 61 ++++++++++++++ include/xo/object2/RuntimeError.hpp | 12 +++ .../object2/error/IGCObject_DRuntimeError.hpp | 65 +++++++++++++++ .../error/IPrintable_DRuntimeError.hpp | 62 ++++++++++++++ src/object2/CMakeLists.txt | 40 +++++---- src/object2/DList.cpp | 4 +- src/object2/DRuntimeError.cpp | 82 +++++++++++++++++++ src/object2/IGCObject_DRuntimeError.cpp | 39 +++++++++ src/object2/IPrintable_DRuntimeError.cpp | 28 +++++++ src/object2/object2_register_facets.cpp | 5 ++ 13 files changed, 439 insertions(+), 15 deletions(-) create mode 100644 idl/IGCObject_DRuntimeError.json5 create mode 100644 idl/IPrintable_DRuntimeError.json5 create mode 100644 include/xo/object2/DRuntimeError.hpp create mode 100644 include/xo/object2/RuntimeError.hpp create mode 100644 include/xo/object2/error/IGCObject_DRuntimeError.hpp create mode 100644 include/xo/object2/error/IPrintable_DRuntimeError.hpp create mode 100644 src/object2/DRuntimeError.cpp create mode 100644 src/object2/IGCObject_DRuntimeError.cpp create mode 100644 src/object2/IPrintable_DRuntimeError.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 83b24223..2fc0ae29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,34 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-runtimeerror + FACET_PKG xo_printable2 + FACET Printable + REPR RuntimeError + INPUT idl/IPrintable_DRuntimeError.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR error + OUTPUT_CPP_DIR src/object2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-gcobject-runtimeerror + FACET_PKG xo_gc + FACET GCObject + REPR RuntimeError + INPUT idl/IGCObject_DRuntimeError.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR error + OUTPUT_CPP_DIR src/object2 +) + +# ---------------------------------------------------------------- + xo_add_genfacet_all(xo-object2-genfacet-all) # ---------------------------------------------------------------- diff --git a/idl/IGCObject_DRuntimeError.json5 b/idl/IGCObject_DRuntimeError.json5 new file mode 100644 index 00000000..9e416b24 --- /dev/null +++ b/idl/IGCObject_DRuntimeError.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ +// "", +// "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DRuntimeError", + using_doxygen: true, + repr: "DRuntimeError", + doc: [ "implement AGCObject for DRuntimeError" ], +} diff --git a/idl/IPrintable_DRuntimeError.json5 b/idl/IPrintable_DRuntimeError.json5 new file mode 100644 index 00000000..2d0f3eff --- /dev/null +++ b/idl/IPrintable_DRuntimeError.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DRuntimeError", + using_doxygen: true, + repr: "DRuntimeError", + doc: [ "implement APrintable for DRuntimeError" ], +} diff --git a/include/xo/object2/DRuntimeError.hpp b/include/xo/object2/DRuntimeError.hpp new file mode 100644 index 00000000..9da75c68 --- /dev/null +++ b/include/xo/object2/DRuntimeError.hpp @@ -0,0 +1,61 @@ +/** @file DRuntimeError.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "String.hpp" +#include + +namespace xo { + namespace scm { + + /** @brief representation for runtime errors + **/ + class DRuntimeError { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using ppindentinfo = xo::print::ppindentinfo; + + public: + /** create instance using memory from allocator @p mm + * @p src_fn identifies the (c++) function/method in which + * error detercted. + * @p error_descr contains human-readable error message; + * will be copied by this function. + **/ + DRuntimeError * _make(obj mm, + DString * src_fn, + DString * error_descr); + + /** @defgroup scm-runtimeerror-printable-facet printable facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + /** @defgroup scm-runtimeerror-gcobject-facet gcobject facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DRuntimeError * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + ///@} + + private: + DRuntimeError(DString * src_fn, DString * error_descr); + + private: + /** source location at which error identified **/ + DString * src_function_ = nullptr; + /** error description (allocated from ErrorArena) **/ + DString * error_descr_ = nullptr; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DRuntimeError.hpp */ diff --git a/include/xo/object2/RuntimeError.hpp b/include/xo/object2/RuntimeError.hpp new file mode 100644 index 00000000..c2a5f65d --- /dev/null +++ b/include/xo/object2/RuntimeError.hpp @@ -0,0 +1,12 @@ +/** @file RuntimeError.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DRuntimeError.hpp" +#include "error/IGCObject_DRuntimeError.hpp" +#include "error/IPrintable_DRuntimeError.hpp" + +/* end RuntimeError.hpp */ diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp new file mode 100644 index 00000000..3bb4d3d8 --- /dev/null +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -0,0 +1,65 @@ +/** @file IGCObject_DRuntimeError.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DRuntimeError.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DRuntimeError.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include "DRuntimeError.hpp" + +namespace xo { namespace scm { class IGCObject_DRuntimeError; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DRuntimeError + **/ + class IGCObject_DRuntimeError { + public: + /** @defgroup scm-gcobject-druntimeerror-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-druntimeerror-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DRuntimeError & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DRuntimeError & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DRuntimeError & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/object2/error/IPrintable_DRuntimeError.hpp b/include/xo/object2/error/IPrintable_DRuntimeError.hpp new file mode 100644 index 00000000..8b5a4d17 --- /dev/null +++ b/include/xo/object2/error/IPrintable_DRuntimeError.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DRuntimeError.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DRuntimeError.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DRuntimeError.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DRuntimeError.hpp" + +namespace xo { namespace scm { class IPrintable_DRuntimeError; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DRuntimeError + **/ + class IPrintable_DRuntimeError { + public: + /** @defgroup scm-printable-druntimeerror-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-druntimeerror-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DRuntimeError & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 609290e8..a5595246 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -5,29 +5,41 @@ set(SELF_SRCS init_object2.cpp object2_register_types.cpp object2_register_facets.cpp + GCObjectConversion_DFloat.cpp GCObjectConversion_DInteger.cpp - IGCObject_DArray.cpp - IGCObject_DFloat.cpp - IGCObject_DBoolean.cpp - IGCObject_DInteger.cpp - IGCObject_DList.cpp - IGCObject_DString.cpp + ISequence_Any.cpp - ISequence_DArray.cpp - ISequence_DList.cpp - IPrintable_DArray.cpp - IPrintable_DList.cpp - IPrintable_DBoolean.cpp - IPrintable_DFloat.cpp - IPrintable_DInteger.cpp - IPrintable_DString.cpp + DArray.cpp + ISequence_DArray.cpp + IGCObject_DArray.cpp + IPrintable_DArray.cpp + DList.cpp + ISequence_DList.cpp + IGCObject_DList.cpp + IPrintable_DList.cpp + DFloat.cpp + IGCObject_DFloat.cpp + IPrintable_DFloat.cpp + DInteger.cpp + IGCObject_DInteger.cpp + IPrintable_DInteger.cpp + DBoolean.cpp + IGCObject_DBoolean.cpp + IPrintable_DBoolean.cpp + DString.cpp + IGCObject_DString.cpp + IPrintable_DString.cpp + + DRuntimeError.cpp + IGCObject_DRuntimeError.cpp + IPrintable_DRuntimeError.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 81512218..73c8cd0d 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -148,6 +148,8 @@ namespace xo { } } + // ----- GCObject facet ------ + auto DList::shallow_size() const noexcept -> size_type { @@ -175,7 +177,7 @@ namespace xo { auto iface = xo::facet::impl_for(); gc.forward_inplace(&iface, (void **)(&rest_)); - return shallow_size(); + return this->shallow_size(); } } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/DRuntimeError.cpp b/src/object2/DRuntimeError.cpp new file mode 100644 index 00000000..972bd0c8 --- /dev/null +++ b/src/object2/DRuntimeError.cpp @@ -0,0 +1,82 @@ +/** @file DRuntimeError.cpp +* + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DRuntimeError.hpp" + +namespace xo { + using xo::mm::AGCObject; + using xo::facet::typeseq; + + namespace scm { + + DRuntimeError * + DRuntimeError::_make(obj mm, + DString * src_fn, + DString * error_descr) + { + void * mem + = mm.alloc(typeseq::id(), + sizeof(DRuntimeError)); + + DRuntimeError * err + = new (mem) DRuntimeError(src_fn, error_descr); + + return err; + } + + DRuntimeError::DRuntimeError(DString * src_fn, + DString * error_descr) : src_function_{src_fn}, + error_descr_{error_descr} + {} + + // ----- GCObject facet ----- + + std::size_t + DRuntimeError::shallow_size() const noexcept + { + return sizeof(DRuntimeError); + } + + DRuntimeError * + DRuntimeError::shallow_copy(obj mm) const noexcept + { + DRuntimeError * copy = (DRuntimeError *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + std::size_t + DRuntimeError::forward_children(obj gc) noexcept + { + { + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&src_function_)); + } + + { + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&error_descr_)); + } + + return this->shallow_size(); + } + + // ----- Printable facet ----- + + bool + DRuntimeError::pretty(const ppindentinfo & ppii) const + { + return ppii.pps()->pretty_struct(ppii, + "DRuntimeError"); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DRuntimeError.cpp */ + diff --git a/src/object2/IGCObject_DRuntimeError.cpp b/src/object2/IGCObject_DRuntimeError.cpp new file mode 100644 index 00000000..d44c4359 --- /dev/null +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DRuntimeError.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DRuntimeError.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DRuntimeError.json5] +**/ + +#include "error/IGCObject_DRuntimeError.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DRuntimeError::shallow_size(const DRuntimeError & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DRuntimeError::shallow_copy(const DRuntimeError & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DRuntimeError.cpp */ diff --git a/src/object2/IPrintable_DRuntimeError.cpp b/src/object2/IPrintable_DRuntimeError.cpp new file mode 100644 index 00000000..eaf084ca --- /dev/null +++ b/src/object2/IPrintable_DRuntimeError.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DRuntimeError.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DRuntimeError.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DRuntimeError.json5] +**/ + +#include "error/IPrintable_DRuntimeError.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DRuntimeError::pretty(const DRuntimeError & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DRuntimeError.cpp */ diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index a910e276..c6358474 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -4,6 +4,7 @@ **/ #include "object2_register_facets.hpp" +#include "RuntimeError.hpp" #include #include @@ -66,6 +67,9 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DVariantPlaceholder.tseq", typeseq::id())); log && log(xtag("DList.tseq", typeseq::id())); @@ -74,6 +78,7 @@ namespace xo { log && log(xtag("DInteger.tseq", typeseq::id())); log && log(xtag("DString.tseq", typeseq::id())); log && log(xtag("DArray.tseq", typeseq::id())); + log && log(xtag("DRuntimeError.tseq", typeseq::id())); log && log(xtag("AAllocator.tseq", typeseq::id())); log && log(xtag("APrintable.tseq", typeseq::id())); From 6b614679e75f2915cceb1a581ada56f13339621b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Feb 2026 20:09:22 -0500 Subject: [PATCH 105/176] xo-interpreter2 stack: work on apply for closures [WIP] --- include/xo/object2/DRuntimeError.hpp | 16 +++++++++++++--- src/object2/DRuntimeError.cpp | 20 +++++++++++++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/xo/object2/DRuntimeError.hpp b/include/xo/object2/DRuntimeError.hpp index 9da75c68..c59de59d 100644 --- a/include/xo/object2/DRuntimeError.hpp +++ b/include/xo/object2/DRuntimeError.hpp @@ -6,6 +6,7 @@ #pragma once #include "String.hpp" +#include #include namespace xo { @@ -15,20 +16,29 @@ namespace xo { **/ class DRuntimeError { public: + using AGCObject = xo::mm::AGCObject; using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; public: + /** convenience shortcut.**/ + static obj make(obj mm, + const char * src_fn, + const char * error_descr); + /** create instance using memory from allocator @p mm * @p src_fn identifies the (c++) function/method in which * error detercted. * @p error_descr contains human-readable error message; * will be copied by this function. **/ - DRuntimeError * _make(obj mm, - DString * src_fn, - DString * error_descr); + static DRuntimeError * _make(obj mm, + DString * src_fn, + DString * error_descr); + + DString * src_function() const noexcept { return src_function_; } + DString * error_descr() const noexcept { return error_descr_; } /** @defgroup scm-runtimeerror-printable-facet printable facet **/ ///@{ diff --git a/src/object2/DRuntimeError.cpp b/src/object2/DRuntimeError.cpp index 972bd0c8..2b9fa62f 100644 --- a/src/object2/DRuntimeError.cpp +++ b/src/object2/DRuntimeError.cpp @@ -3,7 +3,7 @@ * @author Roland Conybeare, Feb 2026 **/ -#include "DRuntimeError.hpp" +#include "RuntimeError.hpp" namespace xo { using xo::mm::AGCObject; @@ -11,6 +11,24 @@ namespace xo { namespace scm { + obj + DRuntimeError::make(obj mm, + const char * src_fn, + const char * error_descr) + { + DRuntimeError * err = DRuntimeError::_make(mm, nullptr, nullptr); + + // pedantic: allocate strings after allocating DRuntimeError instance + + DString * src = DString::from_cstr(mm, src_fn); + DString * err_descr = DString::from_cstr(mm, error_descr); + + err->src_function_ = src; + err->error_descr_ = err_descr; + + return obj(err); + } + DRuntimeError * DRuntimeError::_make(obj mm, DString * src_fn, From 6a85e7e0edd703894c33bd7949a774d500de9cb6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 15:15:39 -0500 Subject: [PATCH 106/176] xo-object2: DList: streamline forward_children() --- src/object2/DList.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 73c8cd0d..0be056d8 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -172,10 +172,12 @@ namespace xo { { //scope log(XO_DEBUG(true)); - gc.forward_inplace(head_.iface(), (void **)&(head_.data_)); + gc.forward_inplace(&head_); + //gc.forward_inplace(head_.iface(), (void **)&(head_.data_)); - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&rest_)); + gc.forward_inplace(&rest_); + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)(&rest_)); return this->shallow_size(); } From 4c1c7467631244d46bcc5726db159b57fd632702 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 16:06:19 -0500 Subject: [PATCH 107/176] xo-interpreter2 stack: apply user-defined lambda passes utest --- src/object2/DArray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index cee62bca..237c9af5 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -135,7 +135,7 @@ namespace xo { for (size_type i = 0; i < size_; ++i) { obj & elt = elts_[i]; - gc.forward_inplace(elt.iface(), (void **)&(elt.data_)); + gc.forward_inplace(&elt); } return shallow_size(); From 3e53b0d10a68c6b70c6b31c155a55bf922ed83e7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Feb 2026 13:06:54 -0500 Subject: [PATCH 108/176] xo-expression2 stack: + mvp DGlobalSymtab impl --- include/xo/object2/DArray.hpp | 7 +++++++ src/object2/DArray.cpp | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index c6f25221..7b758860 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -58,6 +58,13 @@ namespace xo { static DArray * empty(obj mm, size_type cap); + /** create copy of @p src using memory from @p mm + * with capacity for @p new_cap elements + **/ + static DArray * copy(obj mm, + DArray * src, + size_type new_cap); + /** create array containing elements @p args, using memory from @p mm. * Nullptr if space exhausted. * diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 237c9af5..e1414eec 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -37,6 +37,23 @@ namespace xo { return result; } + DArray * + DArray::copy(obj mm, + DArray * src, + size_type new_cap) + { + DArray * dest = empty(mm, new_cap); + + /** could just memcpy here **/ + for (size_type i = 0, n = src->size(); i < n; ++i) { + dest->elts_[i] = src->elts_[i]; + } + + dest->size_ = src->size(); + + return dest; + } + obj DArray::at(size_type ix) const { From 1e715cb94cb318cc19f8a3e102b022e682a6a291 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Feb 2026 13:16:42 -0500 Subject: [PATCH 109/176] xo-object2: streamline DList gc hooks --- src/object2/DList.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 0be056d8..35cb7223 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -33,7 +33,7 @@ namespace xo { obj car, DList * cdr) { - void * mem = mm.alloc(typeseq::id(), sizeof(DList)); + void * mem = mm.alloc_for(); return new (mem) DList(car, cdr); } @@ -159,12 +159,7 @@ namespace xo { DList * DList::shallow_copy(obj mm) const noexcept { - DList * copy = (DList *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return mm.std_copy_for(this); } auto From 22502a787545f547241b8ab17713ede1ddc62eb0 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 09:31:49 -0500 Subject: [PATCH 110/176] xo-alloc2: register DArena facet + subsystem init --- src/object2/init_object2.cpp | 3 ++- src/object2/object2_register_facets.cpp | 31 +++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/object2/init_object2.cpp b/src/object2/init_object2.cpp index 0f804fe0..bcf7608c 100644 --- a/src/object2/init_object2.cpp +++ b/src/object2/init_object2.cpp @@ -7,6 +7,7 @@ #include "object2_register_facets.hpp" #include "object2_register_types.hpp" #include +#include namespace xo { using xo::scm::object2_register_facets; @@ -27,7 +28,7 @@ namespace xo { InitEvidence retval; /* direct subsystem deps for xo-object2/ */ - // retval ^= InitSubsys::require(); + retval ^= InitSubsys::require(); /* xo-expression2/'s own initialization code */ retval ^= Subsystem::provide("object2", &init); diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index c6358474..01d6ef04 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -6,22 +6,29 @@ #include "object2_register_facets.hpp" #include "RuntimeError.hpp" -#include -#include -#include -#include -#include -#include +#include +//#include +#include +#include +#include +#include -#include +//#include +#include +//#include +//#include +//#include +//#include + +//#include #include -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include -#include +//#include #include #include From 65526649cc02b12b9938b88d32e7daafe9fdf2b2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 17:46:51 -0500 Subject: [PATCH 111/176] xo-interpreter2 stack: OUTPUT_CPP_DIR cmake->idl/ --- CMakeLists.txt | 17 ----------------- idl/IGCObject_DArray.json5 | 1 + idl/IGCObject_DBoolean.json5 | 1 + idl/IGCObject_DFloat.json5 | 1 + idl/IGCObject_DInteger.json5 | 1 + idl/IGCObject_DList.json5 | 1 + idl/IGCObject_DRuntimeError.json5 | 1 + idl/IGCObject_DString.json5 | 1 + idl/IPrintable_DArray.json5 | 1 + idl/IPrintable_DBoolean.json5 | 1 + idl/IPrintable_DFloat.json5 | 1 + idl/IPrintable_DInteger.json5 | 1 + idl/IPrintable_DList.json5 | 1 + idl/IPrintable_DRuntimeError.json5 | 1 + idl/IPrintable_DString.json5 | 1 + idl/ISequence_DArray.json5 | 1 + idl/ISequence_DList.json5 | 1 + idl/Sequence.json5 | 2 ++ include/xo/object2/Sequence.hpp | 4 ++-- include/xo/object2/array/IGCObject_DArray.hpp | 2 +- include/xo/object2/array/IPrintable_DArray.hpp | 2 +- include/xo/object2/array/ISequence_DArray.hpp | 2 +- .../xo/object2/boolean/IGCObject_DBoolean.hpp | 2 +- .../xo/object2/boolean/IPrintable_DBoolean.hpp | 2 +- include/xo/object2/list/IGCObject_DList.hpp | 2 +- include/xo/object2/list/IPrintable_DList.hpp | 2 +- include/xo/object2/list/ISequence_DList.hpp | 2 +- include/xo/object2/number/IGCObject_DFloat.hpp | 2 +- .../xo/object2/number/IGCObject_DInteger.hpp | 2 +- include/xo/object2/number/IPrintable_DFloat.hpp | 2 +- .../xo/object2/number/IPrintable_DInteger.hpp | 2 +- include/xo/object2/sequence/ASequence.hpp | 6 ++++-- include/xo/object2/sequence/ISequence_Any.hpp | 9 ++++++--- include/xo/object2/sequence/ISequence_Xfer.hpp | 9 ++++++--- include/xo/object2/sequence/RSequence.hpp | 11 ++++++++--- include/xo/object2/string/IGCObject_DString.hpp | 2 +- .../xo/object2/string/IPrintable_DString.hpp | 2 +- src/object2/IGCObject_DArray.cpp | 4 ++-- src/object2/IGCObject_DBoolean.cpp | 4 ++-- src/object2/IGCObject_DFloat.cpp | 4 ++-- src/object2/IGCObject_DInteger.cpp | 4 ++-- src/object2/IGCObject_DList.cpp | 4 ++-- src/object2/IGCObject_DString.cpp | 4 ++-- src/object2/IPrintable_DArray.cpp | 4 ++-- src/object2/IPrintable_DBoolean.cpp | 4 ++-- src/object2/IPrintable_DFloat.cpp | 4 ++-- src/object2/IPrintable_DInteger.cpp | 4 ++-- src/object2/IPrintable_DList.cpp | 4 ++-- src/object2/IPrintable_DString.cpp | 4 ++-- src/object2/ISequence_Any.cpp | 2 +- src/object2/ISequence_DArray.cpp | 4 ++-- src/object2/ISequence_DList.cpp | 4 ++-- 52 files changed, 87 insertions(+), 73 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fc0ae29..09faf6b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,6 @@ xo_add_genfacet( INPUT idl/Sequence.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR sequence - OUTPUT_CPP_DIR src/object2 ) # ---------------------------------------------------------------- @@ -39,7 +38,6 @@ xo_add_genfacetimpl( INPUT idl/ISequence_DList.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR list - OUTPUT_CPP_DIR src/object2 ) # note: manual target; generated code committed to git @@ -51,7 +49,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DList.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR list - OUTPUT_CPP_DIR src/object2 ) # note: manual target; generated code committed to git @@ -63,7 +60,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DList.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR list - OUTPUT_CPP_DIR src/object2 ) # ---------------------------------------------------------------- @@ -77,7 +73,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DBoolean.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR boolean - OUTPUT_CPP_DIR src/object2 ) # note: manual target; generated code committed to git @@ -89,7 +84,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DBoolean.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR boolean - OUTPUT_CPP_DIR src/object2 ) # ---------------------------------------------------------------- @@ -103,7 +97,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DFloat.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR number - OUTPUT_CPP_DIR src/object2 ) # note: manual target; generated code committed to git @@ -115,7 +108,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DFloat.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR number - OUTPUT_CPP_DIR src/object2 ) # ---------------------------------------------------------------- @@ -129,7 +121,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DInteger.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR number - OUTPUT_CPP_DIR src/object2 ) # note: manual target; generated code committed to git @@ -141,7 +132,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DInteger.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR number - OUTPUT_CPP_DIR src/object2 ) # ---------------------------------------------------------------- @@ -155,7 +145,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DString.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR string - OUTPUT_CPP_DIR src/object2 ) # note: manual target; generated code committed to git @@ -167,7 +156,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DString.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR string - OUTPUT_CPP_DIR src/object2 ) # ---------------------------------------------------------------- @@ -181,7 +169,6 @@ xo_add_genfacetimpl( INPUT idl/ISequence_DArray.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR array - OUTPUT_CPP_DIR src/object2 ) # note: manual target; generated code committed to git @@ -193,7 +180,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DArray.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR array - OUTPUT_CPP_DIR src/object2 ) # note: manual target; generated code committed to git @@ -205,7 +191,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DArray.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR array - OUTPUT_CPP_DIR src/object2 ) # ---------------------------------------------------------------- @@ -219,7 +204,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DRuntimeError.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR error - OUTPUT_CPP_DIR src/object2 ) # note: manual target; generated code committed to git @@ -231,7 +215,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DRuntimeError.json5 OUTPUT_HPP_DIR include/xo/object2 OUTPUT_IMPL_SUBDIR error - OUTPUT_CPP_DIR src/object2 ) # ---------------------------------------------------------------- diff --git a/idl/IGCObject_DArray.json5 b/idl/IGCObject_DArray.json5 index e8aeed3b..3e1115e0 100644 --- a/idl/IGCObject_DArray.json5 +++ b/idl/IGCObject_DArray.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" diff --git a/idl/IGCObject_DBoolean.json5 b/idl/IGCObject_DBoolean.json5 index de3663c4..be131a38 100644 --- a/idl/IGCObject_DBoolean.json5 +++ b/idl/IGCObject_DBoolean.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" diff --git a/idl/IGCObject_DFloat.json5 b/idl/IGCObject_DFloat.json5 index 9aba2a34..2791de0b 100644 --- a/idl/IGCObject_DFloat.json5 +++ b/idl/IGCObject_DFloat.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "", diff --git a/idl/IGCObject_DInteger.json5 b/idl/IGCObject_DInteger.json5 index 65f24371..6b865a4c 100644 --- a/idl/IGCObject_DInteger.json5 +++ b/idl/IGCObject_DInteger.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" diff --git a/idl/IGCObject_DList.json5 b/idl/IGCObject_DList.json5 index 342fc299..e660b0c1 100644 --- a/idl/IGCObject_DList.json5 +++ b/idl/IGCObject_DList.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ // "", // "" diff --git a/idl/IGCObject_DRuntimeError.json5 b/idl/IGCObject_DRuntimeError.json5 index 9e416b24..60d30cc7 100644 --- a/idl/IGCObject_DRuntimeError.json5 +++ b/idl/IGCObject_DRuntimeError.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ // "", // "" diff --git a/idl/IGCObject_DString.json5 b/idl/IGCObject_DString.json5 index 8d0e14e0..60c2165e 100644 --- a/idl/IGCObject_DString.json5 +++ b/idl/IGCObject_DString.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" diff --git a/idl/IPrintable_DArray.json5 b/idl/IPrintable_DArray.json5 index df0ef171..eee19b52 100644 --- a/idl/IPrintable_DArray.json5 +++ b/idl/IPrintable_DArray.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DBoolean.json5 b/idl/IPrintable_DBoolean.json5 index 599a1923..09245363 100644 --- a/idl/IPrintable_DBoolean.json5 +++ b/idl/IPrintable_DBoolean.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DFloat.json5 b/idl/IPrintable_DFloat.json5 index 7351c1b2..427c5dce 100644 --- a/idl/IPrintable_DFloat.json5 +++ b/idl/IPrintable_DFloat.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DInteger.json5 b/idl/IPrintable_DInteger.json5 index 1a2e5490..92c74376 100644 --- a/idl/IPrintable_DInteger.json5 +++ b/idl/IPrintable_DInteger.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DList.json5 b/idl/IPrintable_DList.json5 index 640d7d1d..58b8ea82 100644 --- a/idl/IPrintable_DList.json5 +++ b/idl/IPrintable_DList.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DRuntimeError.json5 b/idl/IPrintable_DRuntimeError.json5 index 2d0f3eff..b9e291e0 100644 --- a/idl/IPrintable_DRuntimeError.json5 +++ b/idl/IPrintable_DRuntimeError.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DString.json5 b/idl/IPrintable_DString.json5 index f032ca46..8caffaab 100644 --- a/idl/IPrintable_DString.json5 +++ b/idl/IPrintable_DString.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/ISequence_DArray.json5 b/idl/ISequence_DArray.json5 index 198410da..1f09b0bb 100644 --- a/idl/ISequence_DArray.json5 +++ b/idl/ISequence_DArray.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ ], local_types: [ ], namespace1: "xo", diff --git a/idl/ISequence_DList.json5 b/idl/ISequence_DList.json5 index 677285da..edf0e8dc 100644 --- a/idl/ISequence_DList.json5 +++ b/idl/ISequence_DList.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/object2", includes: [ "" ], local_types: [ ], namespace1: "xo", diff --git a/idl/Sequence.json5 b/idl/Sequence.json5 index 9ceda9ea..5c5139da 100644 --- a/idl/Sequence.json5 +++ b/idl/Sequence.json5 @@ -1,5 +1,6 @@ { mode: "facet", + output_cpp_dir: "src/object2", includes: [""], // extra includes in Sequence.hpp, if any user_hpp_includes: [], @@ -67,4 +68,5 @@ ], nonconst_methods: [ ], + router_facet_explicit_content: [] } diff --git a/include/xo/object2/Sequence.hpp b/include/xo/object2/Sequence.hpp index 7866f91b..0478fa8b 100644 --- a/include/xo/object2/Sequence.hpp +++ b/include/xo/object2/Sequence.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/Sequence.json5] * 2. jinja2 template for facet .hpp file: @@ -19,4 +19,4 @@ #include "sequence/RSequence.hpp" -/* end Sequence.hpp */ \ No newline at end of file +/* end Sequence.hpp */ diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 0b2279f1..9af6d3c7 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DArray.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/array/IPrintable_DArray.hpp b/include/xo/object2/array/IPrintable_DArray.hpp index 1b3a4663..890cbab5 100644 --- a/include/xo/object2/array/IPrintable_DArray.hpp +++ b/include/xo/object2/array/IPrintable_DArray.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DArray.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/array/ISequence_DArray.hpp b/include/xo/object2/array/ISequence_DArray.hpp index 27f47db3..3b756b94 100644 --- a/include/xo/object2/array/ISequence_DArray.hpp +++ b/include/xo/object2/array/ISequence_DArray.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISequence_DArray.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index e075874c..1d90b60e 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DBoolean.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/boolean/IPrintable_DBoolean.hpp b/include/xo/object2/boolean/IPrintable_DBoolean.hpp index e17f169a..b650c435 100644 --- a/include/xo/object2/boolean/IPrintable_DBoolean.hpp +++ b/include/xo/object2/boolean/IPrintable_DBoolean.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DBoolean.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index 19000df6..7e1f1428 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DList.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/list/IPrintable_DList.hpp b/include/xo/object2/list/IPrintable_DList.hpp index d068bda1..77e7b1d3 100644 --- a/include/xo/object2/list/IPrintable_DList.hpp +++ b/include/xo/object2/list/IPrintable_DList.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DList.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/list/ISequence_DList.hpp b/include/xo/object2/list/ISequence_DList.hpp index d7c44e3b..ac468764 100644 --- a/include/xo/object2/list/ISequence_DList.hpp +++ b/include/xo/object2/list/ISequence_DList.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISequence_DList.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index a5a01fff..9a1dcbdc 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 6aa3c9fc..1136b577 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DInteger.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/number/IPrintable_DFloat.hpp b/include/xo/object2/number/IPrintable_DFloat.hpp index 2bcaf1d2..9506055a 100644 --- a/include/xo/object2/number/IPrintable_DFloat.hpp +++ b/include/xo/object2/number/IPrintable_DFloat.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/number/IPrintable_DInteger.hpp b/include/xo/object2/number/IPrintable_DInteger.hpp index a13334d6..1b5df6c4 100644 --- a/include/xo/object2/number/IPrintable_DInteger.hpp +++ b/include/xo/object2/number/IPrintable_DInteger.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DInteger.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/sequence/ASequence.hpp b/include/xo/object2/sequence/ASequence.hpp index 5281e0ea..53d112e7 100644 --- a/include/xo/object2/sequence/ASequence.hpp +++ b/include/xo/object2/sequence/ASequence.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -51,6 +51,8 @@ public: // const methods /** RTTI: unique id# for actual runtime data representation **/ virtual typeseq _typeseq() const noexcept = 0; + /** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/ + virtual void _drop(Opaque d) const noexcept = 0; /** true iff sequence is empty **/ virtual bool is_empty(Copaque data) const noexcept = 0; /** true iff sequence is finite **/ @@ -78,4 +80,4 @@ using ISequence_ImplType = xo::facet::FacetImplType; } /*namespace scm*/ } /*namespace xo*/ -/* ASequence.hpp */ \ No newline at end of file +/* ASequence.hpp */ diff --git a/include/xo/object2/sequence/ISequence_Any.hpp b/include/xo/object2/sequence/ISequence_Any.hpp index 0e7c5c10..e878f729 100644 --- a/include/xo/object2/sequence/ISequence_Any.hpp +++ b/include/xo/object2/sequence/ISequence_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -55,8 +55,11 @@ namespace scm { // from ASequence - // const methods + // builtin methods typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); } + + // const methods [[noreturn]] bool is_empty(Copaque) const noexcept override { _fatal(); } [[noreturn]] bool is_finite(Copaque) const noexcept override { _fatal(); } [[noreturn]] obj at(Copaque, size_type) const override { _fatal(); } @@ -86,4 +89,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo */ -/* ISequence_Any.hpp */ \ No newline at end of file +/* ISequence_Any.hpp */ diff --git a/include/xo/object2/sequence/ISequence_Xfer.hpp b/include/xo/object2/sequence/ISequence_Xfer.hpp index f3dc8b35..42d6cb1b 100644 --- a/include/xo/object2/sequence/ISequence_Xfer.hpp +++ b/include/xo/object2/sequence/ISequence_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -40,8 +40,11 @@ namespace scm { // from ASequence - // const methods + // builtin methods typeseq _typeseq() const noexcept override { return s_typeseq; } + void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); } + + // const methods bool is_empty(Copaque data) const noexcept override { return I::is_empty(_dcast(data)); } @@ -85,4 +88,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo*/ -/* end ISequence_Xfer.hpp */ \ No newline at end of file +/* end ISequence_Xfer.hpp */ diff --git a/include/xo/object2/sequence/RSequence.hpp b/include/xo/object2/sequence/RSequence.hpp index be4fafb0..76f60059 100644 --- a/include/xo/object2/sequence/RSequence.hpp +++ b/include/xo/object2/sequence/RSequence.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -47,8 +47,13 @@ public: /** @defgroup scm-sequence-router-methods **/ ///@{ - // const methods + // explicit injected content + + // builtin methods typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + void _drop() const noexcept { O::iface()->_drop(O::data()); } + + // const methods bool is_empty() const noexcept { return O::iface()->is_empty(O::data()); } @@ -84,4 +89,4 @@ namespace xo { namespace facet { }; } } -/* end RSequence.hpp */ \ No newline at end of file +/* end RSequence.hpp */ diff --git a/include/xo/object2/string/IGCObject_DString.hpp b/include/xo/object2/string/IGCObject_DString.hpp index 95a19483..159b9e49 100644 --- a/include/xo/object2/string/IGCObject_DString.hpp +++ b/include/xo/object2/string/IGCObject_DString.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/object2/string/IPrintable_DString.hpp b/include/xo/object2/string/IPrintable_DString.hpp index f1be1374..f898a17c 100644 --- a/include/xo/object2/string/IPrintable_DString.hpp +++ b/include/xo/object2/string/IPrintable_DString.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index a2ee4bc1..1063bd45 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DArray.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DArray.cpp */ \ No newline at end of file +/* end IGCObject_DArray.cpp */ diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp index 72aa0b1b..3ef60aea 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DBoolean.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DBoolean.cpp */ \ No newline at end of file +/* end IGCObject_DBoolean.cpp */ diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index 3c44db5d..9e31cf68 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DFloat.cpp */ \ No newline at end of file +/* end IGCObject_DFloat.cpp */ diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 91d8e4a1..55e1fae7 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DInteger.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DInteger.cpp */ \ No newline at end of file +/* end IGCObject_DInteger.cpp */ diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index b9d36cc5..f4e9472b 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DList.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DList.cpp */ \ No newline at end of file +/* end IGCObject_DList.cpp */ diff --git a/src/object2/IGCObject_DString.cpp b/src/object2/IGCObject_DString.cpp index 1eff4da5..d34f0eaf 100644 --- a/src/object2/IGCObject_DString.cpp +++ b/src/object2/IGCObject_DString.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DString.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DString.cpp */ \ No newline at end of file +/* end IGCObject_DString.cpp */ diff --git a/src/object2/IPrintable_DArray.cpp b/src/object2/IPrintable_DArray.cpp index d444800b..b9248516 100644 --- a/src/object2/IPrintable_DArray.cpp +++ b/src/object2/IPrintable_DArray.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DArray.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DArray.cpp */ \ No newline at end of file +/* end IPrintable_DArray.cpp */ diff --git a/src/object2/IPrintable_DBoolean.cpp b/src/object2/IPrintable_DBoolean.cpp index d8fddd87..3b85aa27 100644 --- a/src/object2/IPrintable_DBoolean.cpp +++ b/src/object2/IPrintable_DBoolean.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DBoolean.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DBoolean.cpp */ \ No newline at end of file +/* end IPrintable_DBoolean.cpp */ diff --git a/src/object2/IPrintable_DFloat.cpp b/src/object2/IPrintable_DFloat.cpp index 0c0a6789..f1e8be6d 100644 --- a/src/object2/IPrintable_DFloat.cpp +++ b/src/object2/IPrintable_DFloat.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DFloat.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DFloat.cpp */ \ No newline at end of file +/* end IPrintable_DFloat.cpp */ diff --git a/src/object2/IPrintable_DInteger.cpp b/src/object2/IPrintable_DInteger.cpp index 8924a72c..7a9bbdaa 100644 --- a/src/object2/IPrintable_DInteger.cpp +++ b/src/object2/IPrintable_DInteger.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DInteger.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DInteger.cpp */ \ No newline at end of file +/* end IPrintable_DInteger.cpp */ diff --git a/src/object2/IPrintable_DList.cpp b/src/object2/IPrintable_DList.cpp index 095b323d..a8f9b657 100644 --- a/src/object2/IPrintable_DList.cpp +++ b/src/object2/IPrintable_DList.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DList.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DList.cpp */ \ No newline at end of file +/* end IPrintable_DList.cpp */ diff --git a/src/object2/IPrintable_DString.cpp b/src/object2/IPrintable_DString.cpp index 86d4565e..f5ec4967 100644 --- a/src/object2/IPrintable_DString.cpp +++ b/src/object2/IPrintable_DString.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DString.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DString.cpp */ \ No newline at end of file +/* end IPrintable_DString.cpp */ diff --git a/src/object2/ISequence_Any.cpp b/src/object2/ISequence_Any.cpp index 8461d750..372571f7 100644 --- a/src/object2/ISequence_Any.cpp +++ b/src/object2/ISequence_Any.cpp @@ -38,4 +38,4 @@ ISequence_Any::_valid } /*namespace scm*/ } /*namespace xo*/ -/* end ISequence_Any.cpp */ \ No newline at end of file +/* end ISequence_Any.cpp */ diff --git a/src/object2/ISequence_DArray.cpp b/src/object2/ISequence_DArray.cpp index 40ffe36a..abeeaeee 100644 --- a/src/object2/ISequence_DArray.cpp +++ b/src/object2/ISequence_DArray.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISequence_DArray.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -37,4 +37,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end ISequence_DArray.cpp */ \ No newline at end of file +/* end ISequence_DArray.cpp */ diff --git a/src/object2/ISequence_DList.cpp b/src/object2/ISequence_DList.cpp index 3c9c2437..2bc21862 100644 --- a/src/object2/ISequence_DList.cpp +++ b/src/object2/ISequence_DList.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISequence_DList.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -37,4 +37,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end ISequence_DList.cpp */ \ No newline at end of file +/* end ISequence_DList.cpp */ From c2fa45eb2b62f732bebe5b31de5c401826a314b3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 22:33:32 -0500 Subject: [PATCH 112/176] xo-facet: move output-hpp-dir + subdir to idl/*.json5 --- idl/IGCObject_DArray.json5 | 2 ++ idl/IGCObject_DBoolean.json5 | 2 ++ idl/IGCObject_DFloat.json5 | 2 ++ idl/IGCObject_DInteger.json5 | 2 ++ idl/IGCObject_DList.json5 | 2 ++ idl/IGCObject_DRuntimeError.json5 | 2 ++ idl/IGCObject_DString.json5 | 2 ++ idl/IPrintable_DArray.json5 | 2 ++ idl/IPrintable_DBoolean.json5 | 2 ++ idl/IPrintable_DFloat.json5 | 2 ++ idl/IPrintable_DInteger.json5 | 2 ++ idl/IPrintable_DList.json5 | 2 ++ idl/IPrintable_DRuntimeError.json5 | 2 ++ idl/IPrintable_DString.json5 | 2 ++ idl/ISequence_DArray.json5 | 2 ++ idl/ISequence_DList.json5 | 2 ++ idl/Sequence.json5 | 2 ++ 17 files changed, 34 insertions(+) diff --git a/idl/IGCObject_DArray.json5 b/idl/IGCObject_DArray.json5 index 3e1115e0..bef5bd62 100644 --- a/idl/IGCObject_DArray.json5 +++ b/idl/IGCObject_DArray.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "array", includes: [ "", "" diff --git a/idl/IGCObject_DBoolean.json5 b/idl/IGCObject_DBoolean.json5 index be131a38..c9aaf26b 100644 --- a/idl/IGCObject_DBoolean.json5 +++ b/idl/IGCObject_DBoolean.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "boolean", includes: [ "", "" diff --git a/idl/IGCObject_DFloat.json5 b/idl/IGCObject_DFloat.json5 index 2791de0b..eec1e3e3 100644 --- a/idl/IGCObject_DFloat.json5 +++ b/idl/IGCObject_DFloat.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "number", includes: [ "", "", diff --git a/idl/IGCObject_DInteger.json5 b/idl/IGCObject_DInteger.json5 index 6b865a4c..37d603e5 100644 --- a/idl/IGCObject_DInteger.json5 +++ b/idl/IGCObject_DInteger.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "number", includes: [ "", "" diff --git a/idl/IGCObject_DList.json5 b/idl/IGCObject_DList.json5 index e660b0c1..28fb3352 100644 --- a/idl/IGCObject_DList.json5 +++ b/idl/IGCObject_DList.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "list", includes: [ // "", // "" diff --git a/idl/IGCObject_DRuntimeError.json5 b/idl/IGCObject_DRuntimeError.json5 index 60d30cc7..cfcbe9f6 100644 --- a/idl/IGCObject_DRuntimeError.json5 +++ b/idl/IGCObject_DRuntimeError.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "error", includes: [ // "", // "" diff --git a/idl/IGCObject_DString.json5 b/idl/IGCObject_DString.json5 index 60c2165e..caf33fae 100644 --- a/idl/IGCObject_DString.json5 +++ b/idl/IGCObject_DString.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "string", includes: [ "", "" diff --git a/idl/IPrintable_DArray.json5 b/idl/IPrintable_DArray.json5 index eee19b52..b9bde4f4 100644 --- a/idl/IPrintable_DArray.json5 +++ b/idl/IPrintable_DArray.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "array", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DBoolean.json5 b/idl/IPrintable_DBoolean.json5 index 09245363..db949258 100644 --- a/idl/IPrintable_DBoolean.json5 +++ b/idl/IPrintable_DBoolean.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "boolean", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DFloat.json5 b/idl/IPrintable_DFloat.json5 index 427c5dce..d28680f0 100644 --- a/idl/IPrintable_DFloat.json5 +++ b/idl/IPrintable_DFloat.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "number", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DInteger.json5 b/idl/IPrintable_DInteger.json5 index 92c74376..478da579 100644 --- a/idl/IPrintable_DInteger.json5 +++ b/idl/IPrintable_DInteger.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "number", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DList.json5 b/idl/IPrintable_DList.json5 index 58b8ea82..a7a6bfb6 100644 --- a/idl/IPrintable_DList.json5 +++ b/idl/IPrintable_DList.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "list", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DRuntimeError.json5 b/idl/IPrintable_DRuntimeError.json5 index b9e291e0..a8404925 100644 --- a/idl/IPrintable_DRuntimeError.json5 +++ b/idl/IPrintable_DRuntimeError.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "error", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DString.json5 b/idl/IPrintable_DString.json5 index 8caffaab..8510938b 100644 --- a/idl/IPrintable_DString.json5 +++ b/idl/IPrintable_DString.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "string", includes: [ "", "" ], local_types: [ ], diff --git a/idl/ISequence_DArray.json5 b/idl/ISequence_DArray.json5 index 1f09b0bb..265c3795 100644 --- a/idl/ISequence_DArray.json5 +++ b/idl/ISequence_DArray.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "array", includes: [ ], local_types: [ ], namespace1: "xo", diff --git a/idl/ISequence_DList.json5 b/idl/ISequence_DList.json5 index edf0e8dc..2ff69f04 100644 --- a/idl/ISequence_DList.json5 +++ b/idl/ISequence_DList.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "list", includes: [ "" ], local_types: [ ], namespace1: "xo", diff --git a/idl/Sequence.json5 b/idl/Sequence.json5 index 5c5139da..20271697 100644 --- a/idl/Sequence.json5 +++ b/idl/Sequence.json5 @@ -1,6 +1,8 @@ { mode: "facet", output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "sequence", includes: [""], // extra includes in Sequence.hpp, if any user_hpp_includes: [], From 66492c1d99d0708b79099e72801fb71a243c65b4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 22:46:34 -0500 Subject: [PATCH 113/176] xo-object2: simplify facet codegen --- CMakeLists.txt | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09faf6b7..4b0962de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,6 @@ xo_add_genfacet( TARGET xo-object2-facet-sequence FACET Sequence INPUT idl/Sequence.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR sequence ) # ---------------------------------------------------------------- @@ -36,8 +34,6 @@ xo_add_genfacetimpl( FACET Sequence REPR List INPUT idl/ISequence_DList.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR list ) # note: manual target; generated code committed to git @@ -47,8 +43,6 @@ xo_add_genfacetimpl( FACET Printable REPR List INPUT idl/IPrintable_DList.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR list ) # note: manual target; generated code committed to git @@ -58,8 +52,6 @@ xo_add_genfacetimpl( FACET GCObject REPR List INPUT idl/IGCObject_DList.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR list ) # ---------------------------------------------------------------- @@ -71,8 +63,6 @@ xo_add_genfacetimpl( FACET Printable REPR Boolean INPUT idl/IPrintable_DBoolean.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR boolean ) # note: manual target; generated code committed to git @@ -82,8 +72,6 @@ xo_add_genfacetimpl( FACET GCObject REPR Boolean INPUT idl/IGCObject_DBoolean.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR boolean ) # ---------------------------------------------------------------- @@ -95,8 +83,6 @@ xo_add_genfacetimpl( FACET Printable REPR Float INPUT idl/IPrintable_DFloat.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR number ) # note: manual target; generated code committed to git @@ -106,8 +92,6 @@ xo_add_genfacetimpl( FACET GCObject REPR Float INPUT idl/IGCObject_DFloat.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR number ) # ---------------------------------------------------------------- @@ -119,8 +103,6 @@ xo_add_genfacetimpl( FACET Printable REPR Integer INPUT idl/IPrintable_DInteger.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR number ) # note: manual target; generated code committed to git @@ -130,8 +112,6 @@ xo_add_genfacetimpl( FACET GCObject REPR Integer INPUT idl/IGCObject_DInteger.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR number ) # ---------------------------------------------------------------- @@ -143,8 +123,6 @@ xo_add_genfacetimpl( FACET Printable REPR String INPUT idl/IPrintable_DString.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR string ) # note: manual target; generated code committed to git @@ -154,8 +132,6 @@ xo_add_genfacetimpl( FACET GCObject REPR String INPUT idl/IGCObject_DString.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR string ) # ---------------------------------------------------------------- @@ -167,8 +143,6 @@ xo_add_genfacetimpl( FACET Sequence REPR Array INPUT idl/ISequence_DArray.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR array ) # note: manual target; generated code committed to git @@ -178,8 +152,6 @@ xo_add_genfacetimpl( FACET Printable REPR Array INPUT idl/IPrintable_DArray.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR array ) # note: manual target; generated code committed to git @@ -189,8 +161,6 @@ xo_add_genfacetimpl( FACET GCObject REPR Array INPUT idl/IGCObject_DArray.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR array ) # ---------------------------------------------------------------- @@ -202,9 +172,7 @@ xo_add_genfacetimpl( FACET Printable REPR RuntimeError INPUT idl/IPrintable_DRuntimeError.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR error -) + ) # note: manual target; generated code committed to git xo_add_genfacetimpl( @@ -213,8 +181,6 @@ xo_add_genfacetimpl( FACET GCObject REPR RuntimeError INPUT idl/IGCObject_DRuntimeError.json5 - OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR error ) # ---------------------------------------------------------------- From b64dee41cb285b7376d61fcfd3564d08fdddc963 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Feb 2026 14:42:17 -0500 Subject: [PATCH 114/176] xo-interpreter2 stack: define-expr's work at top-level --- include/xo/object2/DArray.hpp | 12 +++++++++--- src/object2/DArray.cpp | 13 +++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 7b758860..8d7248e5 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -75,9 +75,6 @@ namespace xo { requires (std::same_as> && ...) static DArray * array(obj mm, Args... args); - const obj & operator[](size_type index) const noexcept { return elts_[index]; } - obj & operator[](size_type index) noexcept { return elts_[index]; } - ///@} /** @defgroup darray-access acecss methods **/ ///@{ @@ -91,6 +88,10 @@ namespace xo { size_type size() const noexcept { return size_; } /** return element @p index of this array (0-based) **/ obj at(size_type index) const; + + const obj & operator[](size_type index) const noexcept { return elts_[index]; } + obj & operator[](size_type index) noexcept { return elts_[index]; } + ///@} /** @defgroup darray-iterators iterators **/ ///@{ @@ -106,6 +107,11 @@ namespace xo { /** @defgroup darray-general general methods **/ ///@{ + /** resize to @p new_size. @p new_size may not be larger than capacity + * Return true if resize was accomplished; false otherwise. + **/ + bool resize(size_type new_size) noexcept; + ///@} /** @defgroup darray-conversion-operators conversion operators **/ ///@{ diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index e1414eec..31ced92e 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -84,6 +84,19 @@ namespace xo { } } + bool + DArray::resize(size_type new_z) noexcept { + if (new_z >= capacity_) { + return false; + } else if (new_z > size_) { + // ensure new size is zeroed (we/re not zeroing if/when we shrink) + ::memset((std::byte *)(&elts_[size_]), 0, (std::byte *)(&elts_[new_z]) - (std::byte *)(&elts_[size_])); + } + + this->size_ = new_z; + return true; + } + // printing support bool From 039cd657a814e9d69f1ea525d8606a42dfd1475d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 19 Feb 2026 09:03:02 -0800 Subject: [PATCH 115/176] xo-interpreter2 stack: streamline op== impl + utests --- src/object2/DBoolean.cpp | 2 +- src/object2/DRuntimeError.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp index a926b0ec..ff5fa38a 100644 --- a/src/object2/DBoolean.cpp +++ b/src/object2/DBoolean.cpp @@ -24,7 +24,7 @@ namespace xo { bool DBoolean::pretty(const ppindentinfo & ppii) const { - return ppdetail_atomic::print_pretty + return ppdetail_atomic::print_pretty (ppii, (value_ ? "true" : "false")); } diff --git a/src/object2/DRuntimeError.cpp b/src/object2/DRuntimeError.cpp index 2b9fa62f..b683716e 100644 --- a/src/object2/DRuntimeError.cpp +++ b/src/object2/DRuntimeError.cpp @@ -6,6 +6,7 @@ #include "RuntimeError.hpp" namespace xo { + using xo::print::APrintable; using xo::mm::AGCObject; using xo::facet::typeseq; @@ -89,12 +90,14 @@ namespace xo { bool DRuntimeError::pretty(const ppindentinfo & ppii) const { - return ppii.pps()->pretty_struct(ppii, - "DRuntimeError"); + return ppii.pps()->pretty_struct + (ppii, + "DRuntimeError", + refrtag("src", obj(src_function_)), + refrtag("err", obj(error_descr_))); } } /*namespace scm*/ } /*namespace xo*/ /* end DRuntimeError.cpp */ - From 77f6dcb5412fc06d86e8dfc5042c4b2dad499c39 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 19 Feb 2026 11:56:06 -0800 Subject: [PATCH 116/176] xo-interpreter2 stack: support op!= + trial numeric refactor --- include/xo/object2/DRuntimeError.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xo/object2/DRuntimeError.hpp b/include/xo/object2/DRuntimeError.hpp index c59de59d..8a0ae33b 100644 --- a/include/xo/object2/DRuntimeError.hpp +++ b/include/xo/object2/DRuntimeError.hpp @@ -42,7 +42,7 @@ namespace xo { /** @defgroup scm-runtimeerror-printable-facet printable facet **/ ///@{ - + bool pretty(const ppindentinfo & ppii) const; ///@} From cbc6570e40451d53301385b8990a69cbae015968 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Feb 2026 13:04:46 +1100 Subject: [PATCH 117/176] nix-build: + xo-object2 builds --- src/object2/ISequence_Any.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/object2/ISequence_Any.cpp b/src/object2/ISequence_Any.cpp index 372571f7..77da7d31 100644 --- a/src/object2/ISequence_Any.cpp +++ b/src/object2/ISequence_Any.cpp @@ -3,6 +3,7 @@ **/ #include "sequence/ISequence_Any.hpp" +#include #include namespace xo { From 25af19a5f994c1c76e3caae8d52b0d8d0bf2ef2e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Feb 2026 19:38:53 +1100 Subject: [PATCH 118/176] xo-cmake: setup to make share target available via cmake install --- cmake/xo_object2Config.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/xo_object2Config.cmake.in b/cmake/xo_object2Config.cmake.in index 6773adb7..22772095 100644 --- a/cmake/xo_object2Config.cmake.in +++ b/cmake/xo_object2Config.cmake.in @@ -7,4 +7,5 @@ find_dependency(xo_printable2) find_dependency(subsys) find_dependency(indentlog) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Share.cmake") check_required_components("@PROJECT_NAME@") From df68f3f69fcd9dfd1907b2a6c9ba021a89922c2a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Feb 2026 19:42:06 +1100 Subject: [PATCH 119/176] build: + install target for idl .json5 files --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b0962de..af08b267 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,6 +193,10 @@ xo_add_genfacet_all(xo-object2-genfacet-all) add_subdirectory(src/object2) add_subdirectory(utest) +install(DIRECTORY idl/ + DESTINATION share/${PROJECT_NAME}/idl + FILES_MATCHING PATTERN "*.json5") + xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) # ---------------------------------------------------------------- From 5f3000693ea37f10fdd1d9af08473972f7ce7678 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 2 Mar 2026 23:21:10 +1100 Subject: [PATCH 120/176] xo-interpreter2 stack: parse literal lists (w/ implicit types) --- include/xo/object2/DList.hpp | 3 +++ include/xo/object2/List.hpp | 13 +++++++++++++ include/xo/object2/ListOps.hpp | 3 +-- src/object2/DList.cpp | 8 ++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 include/xo/object2/List.hpp diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 611fb664..39e0b584 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -49,6 +49,9 @@ namespace xo { /** return element at 0-based index @p ix **/ obj at(size_type ix) const; + /** assign rest-pointer **/ + void assign_rest(DList * r); + /** pretty-printing driver; combine layout+printing **/ bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/object2/List.hpp b/include/xo/object2/List.hpp new file mode 100644 index 00000000..872956ce --- /dev/null +++ b/include/xo/object2/List.hpp @@ -0,0 +1,13 @@ +/** @file List.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "DList.hpp" +#include "list/IGCObject_DList.hpp" +#include "list/IPrintable_DList.hpp" +#include "list/ISequence_DList.hpp" + +/* end List.hpp */ diff --git a/include/xo/object2/ListOps.hpp b/include/xo/object2/ListOps.hpp index 98161116..25ddf77f 100644 --- a/include/xo/object2/ListOps.hpp +++ b/include/xo/object2/ListOps.hpp @@ -5,8 +5,7 @@ #pragma once -#include "list/IGCObject_DList.hpp" -#include "DList.hpp" +#include "List.hpp" namespace xo { namespace scm { diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 35cb7223..01d01d61 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -105,6 +105,14 @@ namespace xo { return l->head_; } + void + DList::assign_rest(DList * r) + { + scope log(XO_DEBUG(true), "need write barrier"); + + this->rest_ = r; + } + bool DList::pretty(const ppindentinfo & ppii) const { From c05b30174251d30cdc6754f7315ef66fc418a55c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Mar 2026 12:12:09 +1100 Subject: [PATCH 121/176] xo-interpreter2 stack: + literal array parsing --- include/xo/object2/DArray.hpp | 7 +++++++ src/object2/DArray.cpp | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 8d7248e5..282e0e5c 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -112,6 +112,13 @@ namespace xo { **/ bool resize(size_type new_size) noexcept; + /** reduce array capacity to current array size + * + * note: with X1Collector, capacity is reduced but memory not recycled + * until next collection + **/ + void shrink_to_fit() noexcept; + ///@} /** @defgroup darray-conversion-operators conversion operators **/ ///@{ diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 31ced92e..459b4599 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -68,7 +68,8 @@ namespace xo { } bool - DArray::push_back(obj elt) noexcept { + DArray::push_back(obj elt) noexcept + { if (size_ >= capacity_) { return false; } else { @@ -85,7 +86,8 @@ namespace xo { } bool - DArray::resize(size_type new_z) noexcept { + DArray::resize(size_type new_z) noexcept + { if (new_z >= capacity_) { return false; } else if (new_z > size_) { @@ -97,6 +99,14 @@ namespace xo { return true; } + void + DArray::shrink_to_fit() noexcept + { + if (capacity_ > size_) { + this->capacity_ = size_; + } + } + // printing support bool From 7871c7dbeafe101ae0fabd66cd96b93a12d735dc Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Mar 2026 16:45:54 +1100 Subject: [PATCH 122/176] xo-interpreter2 stack: + dict.make() + Dictionary impl --- CMakeLists.txt | 20 ++ idl/IGCObject_DDictionary.json5 | 18 ++ idl/IPrintable_DDictionary.json5 | 16 ++ include/xo/object2/DArray.hpp | 8 + include/xo/object2/DDictionary.hpp | 217 ++++++++++++++++++ include/xo/object2/DStruct.hpp | 183 +++++++++++++++ include/xo/object2/Dictionary.hpp | 12 + .../dictionary/IGCObject_DDictionary.hpp | 67 ++++++ .../dictionary/IPrintable_DDictionary.hpp | 62 +++++ src/object2/CMakeLists.txt | 4 + src/object2/DArray.cpp | 13 ++ src/object2/DDictionary.cpp | 208 +++++++++++++++++ src/object2/IGCObject_DDictionary.cpp | 39 ++++ src/object2/IPrintable_DDictionary.cpp | 28 +++ src/object2/object2_register_facets.cpp | 24 +- src/object2/object2_register_types.cpp | 8 +- 16 files changed, 904 insertions(+), 23 deletions(-) create mode 100644 idl/IGCObject_DDictionary.json5 create mode 100644 idl/IPrintable_DDictionary.json5 create mode 100644 include/xo/object2/DDictionary.hpp create mode 100644 include/xo/object2/DStruct.hpp create mode 100644 include/xo/object2/Dictionary.hpp create mode 100644 include/xo/object2/dictionary/IGCObject_DDictionary.hpp create mode 100644 include/xo/object2/dictionary/IPrintable_DDictionary.hpp create mode 100644 src/object2/DDictionary.cpp create mode 100644 src/object2/IGCObject_DDictionary.cpp create mode 100644 src/object2/IPrintable_DDictionary.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index af08b267..4b27b70e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,6 +165,26 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-dictionary + FACET_PKG xo_printable2 + FACET Printable + REPR Dictionary + INPUT idl/IPrintable_DDictionary.json5 + ) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-gcobject-dictionary + FACET_PKG xo_gc + FACET GCObject + REPR Dictionary + INPUT idl/IGCObject_DDictionary.json5 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-runtimeerror diff --git a/idl/IGCObject_DDictionary.json5 b/idl/IGCObject_DDictionary.json5 new file mode 100644 index 00000000..636413be --- /dev/null +++ b/idl/IGCObject_DDictionary.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "dictionary", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DDictionary", + using_doxygen: true, + repr: "DDictionary", + doc: [ "implement AGCObject for DDictionary" ], +} diff --git a/idl/IPrintable_DDictionary.json5 b/idl/IPrintable_DDictionary.json5 new file mode 100644 index 00000000..ad1fda52 --- /dev/null +++ b/idl/IPrintable_DDictionary.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/object2", + output_hpp_dir: "include/xo/object2", + output_impl_subdir: "dictionary", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DDictionary", + using_doxygen: true, + repr: "DDictionary", + doc: [ "implement APrintable for DDictionary" ], +} diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 282e0e5c..879bb76c 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -90,6 +90,7 @@ namespace xo { obj at(size_type index) const; const obj & operator[](size_type index) const noexcept { return elts_[index]; } + // TODO: nuke this or provide LValue shim. need write barrier! obj & operator[](size_type index) noexcept { return elts_[index]; } ///@} @@ -99,10 +100,17 @@ namespace xo { ///@} /** @defgroup darray-assign assignment **/ ///@{ + + /** store @p elt at position @p index. + * true on success, false otherwise + **/ + bool assign_at(size_type index, obj elt) noexcept; + /** append @p elt at the end of array. * true on success, false otherwise **/ bool push_back(obj elt) noexcept; + ///@} /** @defgroup darray-general general methods **/ ///@{ diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp new file mode 100644 index 00000000..1f028434 --- /dev/null +++ b/include/xo/object2/DDictionary.hpp @@ -0,0 +1,217 @@ +/** @file DDictionary.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "DArray.hpp" +#include "DString.hpp" +#include +#include +#include +#include +#include +#include +#include + +namespace xo { + namespace scm { + /** @class DStruct + * @brief Polymorphic in-memory key-value store with gc hooks + * + * Small dictionary implementation for Schematika. + * O(n) lookup, at least for now. Not typed. Keys are strings, + * so functionally equivalent to python dictionaries. + **/ + class DDictionary { + public: + /** @defgroup ddictionary-types type traits **/ + ///@{ + + /** type for array size **/ + using size_type = std::uint32_t; + /** xo allocator facet **/ + using AAllocator = xo::mm::AAllocator; + /** garbage collector facet **/ + using ACollector = xo::mm::ACollector; + /** gc-aware object facet **/ + using AGCObject = xo::mm::AGCObject; + /** pretty-printer state for APrintable **/ + using ppindentinfo = xo::print::ppindentinfo; + /** canonical type representing a key-value pair **/ + using pair_type = std::pair>; + + /** shim to represent result of expression like @c dict[key] + **/ + template + class LValue { + public: + LValue(DictPtr d, const DString * key) : dict_{d}, key_{key} {} + + bool is_sentinel() const noexcept { return dict_ == nullptr; } + bool is_valid() const noexcept { return dict_ != nullptr; } + + obj & operator=(obj & rvalue) { + return dict_->upsert(key_, rvalue); + } + + operator std::optional>() const noexcept { + return dict_->lookup(key_); + } + + private: + /** sentinel LValue represented by null ptr here **/ + DictPtr dict_ = nullptr; + /** sentinel LValue has null ptr here **/ + const DString * key_ = nullptr; + }; + + ///@} + /** @defgroup ddictionary-ctors constructors **/ + ///@{ + + /** default ctor. zero capacity sentinel **/ + DDictionary(DArray * keys, DArray * values); + + /** create empty array with space for @p cap elements + * using memory from allocator @p mm. + * Nullptr if space exhausted + **/ + static DDictionary * empty(obj mm, + size_type cap); + + /** create copy of @p src using memory from @p mm + * with capacity for @p new_cap elements + **/ + static DDictionary * copy(obj mm, + DDictionary * src, + size_type new_cap); + + /** create dictionary containing elements @p kv_pairs, using memory from @p mm. + * Nullptr if space exhausted. + * + * Use: + * auto kv1 = std::make_pair>(...); + * auto kv2 = std::make_pair>(...); + * Ddictionary * v = DDictionary::make(mm, kv1, kv2, ..); + **/ + template + requires (std::same_as>> && ...) + static DDictionary * make(obj mm, Args... args); + + ///@} + /** @defgroup ddictionary-access acecss methods **/ + ///@{ + /** true iff array is empty **/ + bool is_empty() const noexcept { return keys_->size() == 0; } + /** array capacity **/ + size_type capacity() const noexcept { return keys_->capacity(); } + /** current dictionary size (number of key-value pairs) **/ + size_type size() const noexcept { return keys_->size(); } + + /** return element @p key-value pair at position @p index (0-based) **/ + std::pair> at_index(size_type index) const; + /** return @p i'th key. O(1) **/ + const DString * key_at_index(size_type i) const; + /** return @p i'th value. O(1) **/ + obj value_at_index(size_type i) const; + + auto operator[](const DString * key) const noexcept { return LValue(this, key); } + auto operator[](const DString * key) noexcept { return LValue(this, key); } + + ///@} + /** @defgroup ddictionary-iterators iterators **/ + ///@{ + + ///@} + /** @defgroup ddictionary-assign assignment **/ + ///@{ + + /** update key-value pair @p kvpair in-place, + * provide key is already present. + * + * @return true if key-value pair updated; false if key not found + **/ + bool try_update(const pair_type & kvpair); + + /** upsert key-value pair @p kvpair into dictionary. + * If key kvpair.first not already present, add it. + * In either case replace/establish associated value with kvpair.second. + * + * False if dictionary already at capacity + **/ + bool try_upsert(const pair_type & kvpair); + + /** upsert key-value pair @p kvpair into dictionary. + * If at capacity, expand capacity, getting new memory from @p mm. + * + * False iff upsert failed because allocator memory exhausted + **/ + bool upsert(obj mm, const pair_type & kvpair); + + ///@} + /** @defgroup ddictionary-general general methods **/ + ///@{ + + /** reduce array capacity to current array size + * + * note: with X1Collector, capacity is reduced but memory not recycled + * until next collection + **/ + void shrink_to_fit() noexcept; + + ///@} + /** @defgroup ddictionary-conversion-operators conversion operators **/ + ///@{ + + ///@} + /** @defgroup ddictionary-sequence-methods **/ + ///@{ + + ///@} + /** @defgroup ddictionary-printable-methods **/ + ///@{ + + /** pretty-printing support **/ + bool pretty(const ppindentinfo & ppii) const; + + ///@} + /** @defgroup ddictionary-gcobject-methods **/ + ///@{ + /** shallow memory consumption. Excludes child objects **/ + AAllocator::size_type shallow_size() const noexcept; + /** return shallow copy of this array, using memory from @p mm **/ + DDictionary * shallow_copy(obj mm) const noexcept; + /** forward elements to @p gc to-space; replace originals with forarding pointers **/ + AAllocator::size_type forward_children(obj gc) noexcept; + ///@} + + private: + /** @defgroup ddictionary-instance-variables instance variables **/ + ///@{ + + /** dictionary keys. These will be strings **/ + DArray * keys_; + /** dictionary values. values_[i] associates with keys_[i] **/ + DArray * values_; + + ///@} + }; + + template + requires (std::same_as>> && ...) + DDictionary * + DDictionary::make(obj mm, Args... args) + { + DDictionary * result = empty(mm, sizeof...(args)); + if (result) { + (result->upsert(args), ...); + } + return result; + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DDictionary.hpp */ diff --git a/include/xo/object2/DStruct.hpp b/include/xo/object2/DStruct.hpp new file mode 100644 index 00000000..d7a7d84b --- /dev/null +++ b/include/xo/object2/DStruct.hpp @@ -0,0 +1,183 @@ +/** @file DStruct.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "DArray.hpp" +#include +#include +#include +#include +#include +#include +#include + +namespace xo { + namespace scm { + /** @class DStruct + * @brief Polymorphic in-memory key-value store with gc hooks + * + * Small dictionary implementation for Schematika. + * O(n) lookup, at least for now. Keys are unique strings. + * Intended to have key-space fixed at comptime. + * Relevant since keys are immortal DUniqueStrings. + **/ + class DStruct { + public: + /** @defgroup dstruct-types type traits **/ + ///@{ + + /** type for array size **/ + using size_type = std::uint32_t; + /** xo allocator facet **/ + using AAllocator = xo::mm::AAllocator; + /** garbage collector facet **/ + using ACollector = xo::mm::ACollector; + /** gc-aware object facet **/ + using AGCObject = xo::mm::AGCObject; + /** pretty-printer state for APrintable **/ + using ppindentinfo = xo::print::ppindentinfo; + + ///@} + /** @defgroup dstruct-ctors constructors **/ + ///@{ + + /** default ctor. zero capacity sentinel **/ + DStruct() = default; + + /** not simply copyable because of flexible array. + * Need allocator. See @ref clone + **/ + DStruct(const DStruct &) = delete; + + /** create empty array with space for @p cap elements + * using memory from allocator @p mm. + * Nullptr if space exhausted + **/ + static DStruct * empty(obj mm, + size_type cap); + + /** create copy of @p src using memory from @p mm + * with capacity for @p new_cap elements + **/ + static DStruct * copy(obj mm, + DStruct * src, + size_type new_cap); + + /** create array containing elements @p args, using memory from @p mm. + * Nullptr if space exhausted. + * + * Use: + * Dstruct * v = DStruct::array(mm, e1, e2, e3); + **/ + template + requires (std::same_as> && ...) + static DStruct * array(obj mm, Args... args); + + ///@} + /** @defgroup dstruct-access acecss methods **/ + ///@{ + /** true iff array is empty **/ + bool is_empty() const noexcept { return size_ == 0; } + /** only support finite arrays :-) **/ + bool is_finite() const noexcept { return true; } + /** array capacity **/ + size_type capacity() const noexcept { return capacity_; } + /** current array size (number of elements) **/ + size_type size() const noexcept { return size_; } + /** return element @p index of this array (0-based) **/ + obj at(size_type index) const; + + const obj & operator[](size_type index) const noexcept { return elts_[index]; } + obj & operator[](size_type index) noexcept { return elts_[index]; } + + ///@} + /** @defgroup dstruct-iterators iterators **/ + ///@{ + + ///@} + /** @defgroup dstruct-assign assignment **/ + ///@{ + /** append @p elt at the end of array. + * true on success, false otherwise + **/ + bool push_back(obj elt) noexcept; + + ///@} + /** @defgroup dstruct-general general methods **/ + ///@{ + + /** resize to @p new_size. @p new_size may not be larger than capacity + * Return true if resize was accomplished; false otherwise. + **/ + bool resize(size_type new_size) noexcept; + + /** reduce array capacity to current array size + * + * note: with X1Collector, capacity is reduced but memory not recycled + * until next collection + **/ + void shrink_to_fit() noexcept; + + ///@} + /** @defgroup dstruct-conversion-operators conversion operators **/ + ///@{ + + ///@} + /** @defgroup dstruct-sequence-methods **/ + ///@{ + + ///@} + /** @defgroup dstruct-printable-methods **/ + ///@{ + + /** pretty-printing support **/ + bool pretty(const ppindentinfo & ppii) const; + + ///@} + /** @defgroup dstruct-gcobject-methods **/ + ///@{ + /** shallow memory consumption. Excludes child objects **/ + AAllocator::size_type shallow_size() const noexcept; + /** return shallow copy of this array, using memory from @p mm **/ + DStruct * shallow_copy(obj mm) const noexcept; + /** forward elements to @p gc to-space; replace originals with forarding pointers **/ + AAllocator::size_type forward_children(obj gc) noexcept; + ///@} + + private: + /** @defgroup dstruct-instance-variables instance variables **/ + ///@{ + + /** extent of @ref elts_ array **/ + size_type capacity_ = 0; + /** array size + * Invariant: size_ <= capacity_ + **/ + size_type size_ = 0; + /** struct keys. These will be unique strings **/ + DArray * keys_ = nullptr; + /** struct member values **/ + DArray * values_ = nullptr; + + ///@} + }; + + template + requires (std::same_as> && ...) + DStruct * + DStruct::array(obj mm, Args... args) + { + DStruct * result = empty(mm, sizeof...(args)); + if (result) { + (result->push_back(args), ...); + } + return result; + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DStruct.hpp */ diff --git a/include/xo/object2/Dictionary.hpp b/include/xo/object2/Dictionary.hpp new file mode 100644 index 00000000..6eaf7c24 --- /dev/null +++ b/include/xo/object2/Dictionary.hpp @@ -0,0 +1,12 @@ +/** @file Dictionary.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "DDictionary.hpp" +#include "dictionary/IGCObject_DDictionary.hpp" +#include "dictionary/IPrintable_DDictionary.hpp" + +/* end Dictionary.hpp */ diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp new file mode 100644 index 00000000..7f2e0ad9 --- /dev/null +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DDictionary.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DDictionary.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DDictionary.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DDictionary.hpp" + +namespace xo { namespace scm { class IGCObject_DDictionary; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DDictionary + **/ + class IGCObject_DDictionary { + public: + /** @defgroup scm-gcobject-ddictionary-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-ddictionary-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DDictionary & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DDictionary & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DDictionary & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/object2/dictionary/IPrintable_DDictionary.hpp b/include/xo/object2/dictionary/IPrintable_DDictionary.hpp new file mode 100644 index 00000000..abd79d7b --- /dev/null +++ b/include/xo/object2/dictionary/IPrintable_DDictionary.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DDictionary.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DDictionary.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DDictionary.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DDictionary.hpp" + +namespace xo { namespace scm { class IPrintable_DDictionary; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DDictionary + **/ + class IPrintable_DDictionary { + public: + /** @defgroup scm-printable-ddictionary-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-ddictionary-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DDictionary & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index a5595246..e9ae687a 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -37,6 +37,10 @@ set(SELF_SRCS IGCObject_DString.cpp IPrintable_DString.cpp + DDictionary.cpp + IGCObject_DDictionary.cpp + IPrintable_DDictionary.cpp + DRuntimeError.cpp IGCObject_DRuntimeError.cpp IPrintable_DRuntimeError.cpp diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 459b4599..f26c5238 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -67,6 +67,19 @@ namespace xo { } } + bool + DArray::assign_at(size_type ix, obj x) noexcept + { + if (ix >= size_) + return false; + + scope log(XO_DEBUG(true), "need write barrier"); + + this->elts_[ix] = x; + + return true; + } + bool DArray::push_back(obj elt) noexcept { diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp new file mode 100644 index 00000000..b939eaac --- /dev/null +++ b/src/object2/DDictionary.cpp @@ -0,0 +1,208 @@ +/** @file DDictionary.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "DDictionary.hpp" +#include "Array.hpp" +#include "String.hpp" +#include +#include + +namespace xo { + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::mm::AGCObject; + + namespace scm { + + DDictionary::DDictionary(DArray * keys, + DArray * values) + : keys_{keys}, values_{values} + {} + + DDictionary * + DDictionary::empty(obj mm, size_type cap) + { + void * mem = mm.alloc_for(); + + if (cap <= 0) + cap = 1; + + DArray * keys = DArray::empty(mm, cap); + DArray * values = DArray::empty(mm, cap); + + return new (mem) DDictionary(keys, values); + } + + std::pair> + DDictionary::at_index(size_type ix) const + { + if (ix < keys_->size()) { + auto key_str = obj::from((*keys_)[ix]); + + assert(key_str); + + return pair_type(this->key_at_index(ix), (*values_)[ix]); + } + + return pair_type(); + } + + const DString * + DDictionary::key_at_index(size_type ix) const + { + auto key_str = obj::from((*keys_)[ix]); + + assert(key_str); + + return key_str.data(); + } + + obj + DDictionary::value_at_index(size_type ix) const + { + if (ix < keys_->size()) { + assert(ix < values_->size()); + + return (*values_)[ix]; + } + + return obj(); + } + + bool + DDictionary::try_update(const pair_type & kv_pair) + { + for (size_type i = 0, n = keys_->size(); i < n; ++i) { + auto key_i = obj::from((*keys_)[i]); + + assert(key_i); + + if (*(key_i.data()) == *(kv_pair.first)) { + values_->assign_at(i, kv_pair.second); + return true; + } + } + + return false; + } + + bool + DDictionary::try_upsert(const pair_type & kv_pair) + { + if (this->try_update(kv_pair)) + return true; + + if (keys_->size() == keys_->capacity()) + return false; + + keys_->push_back(obj(const_cast(kv_pair.first))); + values_->push_back(kv_pair.second); + + return true; + } + + bool + DDictionary::upsert(obj mm, const pair_type & kv_pair) + { + if (this->try_update(kv_pair)) + return true; + + if (keys_->size() == keys_->capacity()) { + assert(keys_->capacity() > 0); + + size_type cap_2x = 2 * keys_->capacity(); + + DArray * keys_2x = DArray::copy(mm, keys_, cap_2x); + DArray * values_2x = DArray::copy(mm, values_, cap_2x); + + if (keys_2x && values_2x) { + this->keys_ = keys_2x; + this->values_ = values_2x; + } else { + return false; + } + } + + keys_->push_back(obj(const_cast(kv_pair.first))); + values_->push_back(kv_pair.second); + + return true; + } + + void + DDictionary::shrink_to_fit() noexcept + { + keys_->shrink_to_fit(); + values_->shrink_to_fit(); + } + + // ----- printable facet ---- + + bool + DDictionary::pretty(const ppindentinfo & ppii) const + { + using xo::print::ppstate; + + ppstate * pps = ppii.pps(); + + if (ppii.upto()) { + pps->write("{"); + + for (size_type i = 0, n = this->size(); i < n; ++i) { + if (i > 0) + pps->write(" "); + + obj key + = FacetRegistry::instance().variant((*keys_)[i]); + obj value + = FacetRegistry::instance().variant((*values_)[i]); + + assert(key.data()); + assert(value.data()); + + if (!pps->print_upto(key)) + return false; + pps->write(": "); + + if (!pps->print_upto(value)) + return false; + } + + pps->write("}"); + return true; + } else { + pps->write("{...}"); + return false; + } + } + + // ----- gcobject facet ----- + + std::size_t + DDictionary::shallow_size() const noexcept + { + return sizeof(DDictionary); + } + + DDictionary * + DDictionary::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DDictionary::forward_children(obj gc) noexcept + { + + gc.forward_inplace(&keys_); + gc.forward_inplace(&values_); + + return this->shallow_size(); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DDictionary.cpp */ diff --git a/src/object2/IGCObject_DDictionary.cpp b/src/object2/IGCObject_DDictionary.cpp new file mode 100644 index 00000000..a6705d98 --- /dev/null +++ b/src/object2/IGCObject_DDictionary.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DDictionary.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DDictionary.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DDictionary.json5] +**/ + +#include "dictionary/IGCObject_DDictionary.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DDictionary::shallow_size(const DDictionary & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DDictionary::shallow_copy(const DDictionary & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DDictionary::forward_children(DDictionary & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DDictionary.cpp */ diff --git a/src/object2/IPrintable_DDictionary.cpp b/src/object2/IPrintable_DDictionary.cpp new file mode 100644 index 00000000..059196ef --- /dev/null +++ b/src/object2/IPrintable_DDictionary.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DDictionary.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DDictionary.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DDictionary.json5] +**/ + +#include "dictionary/IPrintable_DDictionary.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DDictionary::pretty(const DDictionary & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DDictionary.cpp */ diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 01d6ef04..4faf9110 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -6,30 +6,14 @@ #include "object2_register_facets.hpp" #include "RuntimeError.hpp" +#include #include -//#include +#include #include #include #include #include -//#include -#include -//#include -//#include -//#include -//#include - -//#include -#include -//#include -//#include -//#include -//#include - -#include -//#include - #include #include #include @@ -74,6 +58,9 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -85,6 +72,7 @@ namespace xo { log && log(xtag("DInteger.tseq", typeseq::id())); log && log(xtag("DString.tseq", typeseq::id())); log && log(xtag("DArray.tseq", typeseq::id())); + log && log(xtag("DDictionary.tseq", typeseq::id())); log && log(xtag("DRuntimeError.tseq", typeseq::id())); log && log(xtag("AAllocator.tseq", typeseq::id())); diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index 275995f8..3e0d50d1 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -11,10 +11,7 @@ #include "string/IGCObject_DString.hpp" #include "list/IGCObject_DList.hpp" #include "array/IGCObject_DArray.hpp" - -//#include "list/IPrintable_DList.hpp" -//#include "IPrintable_DFloat.hpp" -//#include "number/IPrintable_DInteger.hpp" +#include "dictionary/IGCObject_DDictionary.hpp" #include #include @@ -23,7 +20,6 @@ namespace xo { using xo::mm::ACollector; using xo::mm::AGCObject; using xo::facet::impl_for; - using xo::facet::typeseq; using xo::scope; namespace scm { @@ -46,6 +42,8 @@ namespace xo { ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + return ok; } } From 6347fb6d7297d87ee4bb58805802811611a99e7f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Mar 2026 14:05:31 +1100 Subject: [PATCH 123/176] xo-object2: cosmetic: ordering nit --- src/object2/object2_register_facets.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 4faf9110..0b127179 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -38,10 +38,6 @@ namespace xo { { scope log(XO_DEBUG(true)); - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -54,6 +50,10 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); From c8a76d23bd664ea156119375b6a82a8d3e23ee92 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Mar 2026 22:26:31 +1100 Subject: [PATCH 124/176] xo-gc xo-alloc2: move Collector faceet gc/ -> alloc2/ for levelling --- include/xo/object2/DArray.hpp | 4 +-- include/xo/object2/DBoolean.hpp | 2 +- include/xo/object2/DDictionary.hpp | 4 +-- include/xo/object2/DFloat.hpp | 2 +- include/xo/object2/DInteger.hpp | 2 +- include/xo/object2/DList.hpp | 2 +- include/xo/object2/DString.hpp | 35 +++++++++++++------ include/xo/object2/String.hpp | 2 ++ include/xo/object2/array/IGCObject_DArray.hpp | 4 +-- .../xo/object2/boolean/IGCObject_DBoolean.hpp | 4 +-- .../dictionary/IGCObject_DDictionary.hpp | 4 +-- .../xo/object2/number/IGCObject_DFloat.hpp | 4 +-- .../xo/object2/number/IGCObject_DInteger.hpp | 4 +-- .../xo/object2/object2_register_facets.hpp | 2 +- include/xo/object2/object2_register_types.hpp | 2 +- include/xo/object2/sequence/ASequence.hpp | 2 +- .../xo/object2/sequence/ISequence_Xfer.hpp | 2 +- .../xo/object2/string/IGCObject_DString.hpp | 4 +-- src/object2/DList.cpp | 2 +- src/object2/DString.cpp | 3 +- utest/DString.test.cpp | 1 + utest/Printable.test.cpp | 2 +- utest/X1Collector.test.cpp | 2 +- 23 files changed, 57 insertions(+), 38 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 879bb76c..55d5e068 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -5,8 +5,8 @@ #pragma once -#include -#include +#include +#include #include #include #include diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index 69dd1c16..ee9fe3be 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include #include #include #include diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 1f028434..f5844088 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -7,8 +7,8 @@ #include "DArray.hpp" #include "DString.hpp" -#include -#include +#include +#include #include #include #include diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index a46a990d..4e4be861 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index b03693be..3fd13672 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include #include #include #include diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 39e0b584..50ab8dd7 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include #include #include diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index a6cedb00..bb57e3da 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include #include @@ -15,6 +15,8 @@ //#include namespace xo { + namespace mm { class ACollector; } + namespace scm { /** @class DString * @brief String implementation with gc hooks @@ -111,14 +113,7 @@ namespace xo { static DString * printf(obj mm, size_type cap, const char * fmt, - Args&&... args) - { - DString * result = DString::empty(mm, cap); - if (result) { - result->sprintf(fmt, std::forward(args)...); - } - return result; - } + Args&&... args); ///@} /** @defgroup dstring-access access methods **/ @@ -252,8 +247,10 @@ namespace xo { /** clone string, using memory from allocator @p mm **/ DString * shallow_copy(obj mm) const noexcept; - /** fixup child pointers (trivial for DString, no children) **/ size_type forward_children(obj gc) noexcept; + /** fixup child pointers (trivial for DString, no children) + * note: cref so we can use forward decl + **/ ///@} @@ -285,6 +282,24 @@ namespace xo { ///@} }; + /** create string using printf-style formatting. + * Use memory from allocator @p mm with capacity @p cap. + * Truncates if result exceeds capacity. + * @return pointer to newly created DString + **/ + template + DString * DString::printf(obj mm, + size_type cap, + const char * fmt, + Args&&... args) + { + DString * result = DString::empty(mm, cap); + if (result) { + result->sprintf(fmt, std::forward(args)...); + } + return result; + } + inline std::ostream & operator<<(std::ostream & os, const DString * x) { if (x) { os << std::string_view(*x); diff --git a/include/xo/object2/String.hpp b/include/xo/object2/String.hpp index 111b04fb..f3d0527b 100644 --- a/include/xo/object2/String.hpp +++ b/include/xo/object2/String.hpp @@ -9,4 +9,6 @@ #include "string/IGCObject_DString.hpp" #include "string/IPrintable_DString.hpp" +#include + /* end String.hpp */ diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 9af6d3c7..08f78aa8 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DArray.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 1d90b60e..358aad18 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DBoolean.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 7f2e0ad9..7fe1bc55 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DDictionary.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index 9a1dcbdc..b8e15b73 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -15,7 +15,7 @@ #include "GCObject.hpp" #include -#include +#include #include #include "DFloat.hpp" @@ -65,4 +65,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 1136b577..fd2ea642 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DInteger.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/object2_register_facets.hpp b/include/xo/object2/object2_register_facets.hpp index e419b794..7f42d5a0 100644 --- a/include/xo/object2/object2_register_facets.hpp +++ b/include/xo/object2/object2_register_facets.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include namespace xo { namespace scm { diff --git a/include/xo/object2/object2_register_types.hpp b/include/xo/object2/object2_register_types.hpp index 5c61692d..5663b086 100644 --- a/include/xo/object2/object2_register_types.hpp +++ b/include/xo/object2/object2_register_types.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include namespace xo { namespace scm { diff --git a/include/xo/object2/sequence/ASequence.hpp b/include/xo/object2/sequence/ASequence.hpp index 53d112e7..44f1d1cb 100644 --- a/include/xo/object2/sequence/ASequence.hpp +++ b/include/xo/object2/sequence/ASequence.hpp @@ -14,7 +14,7 @@ #pragma once // includes (via {facet_includes}) -#include +#include #include #include #include diff --git a/include/xo/object2/sequence/ISequence_Xfer.hpp b/include/xo/object2/sequence/ISequence_Xfer.hpp index 42d6cb1b..e0511e41 100644 --- a/include/xo/object2/sequence/ISequence_Xfer.hpp +++ b/include/xo/object2/sequence/ISequence_Xfer.hpp @@ -13,7 +13,7 @@ #pragma once -#include +#include namespace xo { namespace scm { diff --git a/include/xo/object2/string/IGCObject_DString.hpp b/include/xo/object2/string/IGCObject_DString.hpp index 159b9e49..2a907f37 100644 --- a/include/xo/object2/string/IGCObject_DString.hpp +++ b/include/xo/object2/string/IGCObject_DString.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DString.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 01d01d61..25770d01 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -6,7 +6,7 @@ #include "DList.hpp" #include "list/IPrintable_DList.hpp" #include "list/IGCObject_DList.hpp" -#include +#include #include #include #include diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index 69baa5d6..230fa4a4 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -4,12 +4,13 @@ **/ #include "DString.hpp" +#include #include #include #include namespace xo { - using xo::facet::typeseq; + using xo::reflect::typeseq; using xo::print::ppdetail_atomic; namespace scm { diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index 39dffef5..53db8e7f 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -5,6 +5,7 @@ #include "init_object2.hpp" #include "StringOps.hpp" +#include #include #include #include diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index 64736d22..2ca792fa 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 90122c25..a2a2dec5 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -16,7 +16,7 @@ #include "list/IGCObject_DList.hpp" #include -#include +#include #include #include From 00a22e81c0e6c8a71ed990c1f93e7e96301c2873 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Mar 2026 00:50:58 +1100 Subject: [PATCH 125/176] refactor: + xo-stringtable2 w/ DString impl --- cmake/xo_object2Config.cmake.in | 1 + idl/IGCObject_DString.json5 | 18 - idl/IPrintable_DString.json5 | 16 - include/xo/object2/DString.hpp | 348 -------------- include/xo/object2/String.hpp | 14 - include/xo/object2/StringOps.hpp | 80 ---- .../xo/object2/object2_register_facets.hpp | 2 - .../xo/object2/string/IGCObject_DString.hpp | 67 --- .../xo/object2/string/IPrintable_DString.hpp | 62 --- src/object2/CMakeLists.txt | 5 +- src/object2/DString.cpp | 187 -------- src/object2/IGCObject_DString.cpp | 39 -- src/object2/IPrintable_DString.cpp | 28 -- src/object2/init_object2.cpp | 4 +- src/object2/object2_register_facets.cpp | 3 +- src/object2/object2_register_types.cpp | 2 - utest/CMakeLists.txt | 4 +- utest/DString.test.cpp | 428 ------------------ utest/Printable.test.cpp | 6 +- utest/StringOps.test.cpp | 102 ----- utest/X1Collector.test.cpp | 2 +- 21 files changed, 12 insertions(+), 1406 deletions(-) delete mode 100644 idl/IGCObject_DString.json5 delete mode 100644 idl/IPrintable_DString.json5 delete mode 100644 include/xo/object2/DString.hpp delete mode 100644 include/xo/object2/String.hpp delete mode 100644 include/xo/object2/StringOps.hpp delete mode 100644 include/xo/object2/string/IGCObject_DString.hpp delete mode 100644 include/xo/object2/string/IPrintable_DString.hpp delete mode 100644 src/object2/DString.cpp delete mode 100644 src/object2/IGCObject_DString.cpp delete mode 100644 src/object2/IPrintable_DString.cpp delete mode 100644 utest/DString.test.cpp delete mode 100644 utest/StringOps.test.cpp diff --git a/cmake/xo_object2Config.cmake.in b/cmake/xo_object2Config.cmake.in index 22772095..78ee9e0f 100644 --- a/cmake/xo_object2Config.cmake.in +++ b/cmake/xo_object2Config.cmake.in @@ -3,6 +3,7 @@ include(CMakeFindDependencyMacro) find_dependency(reflect) find_dependency(xo_gc) +find_dependency(xo_stringtable2) find_dependency(xo_printable2) find_dependency(subsys) find_dependency(indentlog) diff --git a/idl/IGCObject_DString.json5 b/idl/IGCObject_DString.json5 deleted file mode 100644 index caf33fae..00000000 --- a/idl/IGCObject_DString.json5 +++ /dev/null @@ -1,18 +0,0 @@ -{ - mode: "implementation", - output_cpp_dir: "src/object2", - output_hpp_dir: "include/xo/object2", - output_impl_subdir: "string", - includes: [ - "", - "" - ], - local_types: [ ], - namespace1: "xo", - namespace2: "scm", - facet_idl: "idl/GCObject.json5", - brief: "provide AGCObject interface for DString", - using_doxygen: true, - repr: "DString", - doc: [ "implement AGCObject for DString" ], -} diff --git a/idl/IPrintable_DString.json5 b/idl/IPrintable_DString.json5 deleted file mode 100644 index 8510938b..00000000 --- a/idl/IPrintable_DString.json5 +++ /dev/null @@ -1,16 +0,0 @@ -{ - mode: "implementation", - output_cpp_dir: "src/object2", - output_hpp_dir: "include/xo/object2", - output_impl_subdir: "string", - includes: [ "", - "" ], - local_types: [ ], - namespace1: "xo", - namespace2: "scm", - facet_idl: "idl/Printable.json5", - brief: "provide APrintable interface for DString", - using_doxygen: true, - repr: "DString", - doc: [ "implement APrintable for DString" ], -} diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp deleted file mode 100644 index bb57e3da..00000000 --- a/include/xo/object2/DString.hpp +++ /dev/null @@ -1,348 +0,0 @@ -/** @file DString.hpp -* - * @author Roland Conybeare, Jan 2026 - **/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -//#include - -namespace xo { - namespace mm { class ACollector; } - - namespace scm { - /** @class DString - * @brief String implementation with gc hooks - * - * String implementation for Schematika. - * Size-prefixed and null-terminated. - * Note however that string length != size for utf-8. - * - * Uses flexible array for chars, - * with string contents in memory immediately - * following the DString itself - **/ - struct DString { - public: - /** @defgroup dstring-types type traits **/ - ///@{ - /** character traits for this DString **/ - using traits_type = std::char_traits; - /** type of each character in this DString **/ - using value_type = char; - /** type for string index / size **/ - using size_type = std::uint32_t; - /** representation for a read/write iterator **/ - using iterator = char *; - /** representation for a readonly iterator **/ - using const_iterator = const char *; - /** xo allocator **/ - using AAllocator = xo::mm::AAllocator; - /** garbage collector **/ - using ACollector = xo::mm::ACollector; - /** ppindentinfo for APrintable **/ - using ppindentinfo = xo::print::ppindentinfo; - ///@} - /** @defgroup dstring-ctors constructors **/ - ///@{ - - /** default ctor **/ - DString() = default; - - /** not simply copyable, because of flexible array. - * Need allocator - **/ - DString(const DString &) = delete; - - /** create empty string with space for @p cap chars - * (including null terminator). - * Use memory from allocator @p mm - **/ - static DString * empty(obj mm, - size_type cap); - - /** create string containing a copy of null-terminated @p cstr. - * Use memory from allocator @p mm - **/ - static DString * from_cstr(obj mm, - const char * cstr); - - /** create string containing a copy of @p sv. - * Use memory from allocator @p mm. - **/ - static DString * from_view(obj mm, - std::string_view sv); - - /** create string containing a copy @p str. - * Use memory from allocator @p mm. - **/ - static DString * from_str(obj mm, - const std::string & str); - - /** create string containing a copy of @p sv. - * Use memory from allocator @p mm via sub_alloc. - * (load-bearing for StringTable) - **/ - static DString * from_view_suballoc(obj mm, - std::string_view sv); - - /** clone existing string **/ - static DString * clone(obj mm, - const DString * src); - -#ifdef NOT_YET - /** **/ - static DString * concat(obj mm, - DString * s1, - DString * s2); -#endif - - /** create string using printf-style formatting. - * Use memory from allocator @p mm with capacity @p cap. - * Truncates if result exceeds capacity. - * @return pointer to newly created DString - **/ - template - static DString * printf(obj mm, - size_type cap, - const char * fmt, - Args&&... args); - - ///@} - /** @defgroup dstring-access access methods **/ - ///@{ - - /** get writeable access to string representation. - * Caller responsible for calling fixup() if string length modified - **/ - char * data() noexcept { return chars_; } - - /** return char at position @p pos in this string, counting from zero. - * Does not check bounds. Undefined behavior if @p pos = @ref capacity_ - **/ - char & operator[](size_type pos) noexcept { return chars_[pos]; } - const char & operator[](size_type pos) const noexcept { return chars_[pos]; } - - size_type capacity() const noexcept { return capacity_; } - size_type size() const noexcept { return size_; } - const char * chars() const noexcept { return chars_; } - - ///@} - /** @defgroup dstring-iterators iterators **/ - ///@{ - iterator begin() noexcept { return &chars_[0]; } - iterator end() noexcept { return &chars_[size_]; } - - const_iterator cbegin() const noexcept { return &chars_[0]; } - const_iterator cend() const noexcept { return &chars_[size_]; } - const_iterator begin() const noexcept { return cbegin(); } - const_iterator end() const noexcept { return cend(); } - - ///@} - /** @defgroup dstring-assign assignment **/ - ///@{ - - /** put string into empty state **/ - void clear() noexcept { size_ = 0; chars_[0] = '\0'; } - - /** replace contents with @p other, or prefix of up to @p capacity - 1 chars **/ - DString & assign(const DString & other); - ///@} - /** @defgroup dstring-general general methods **/ - ///@{ - - /** format string into this DString using printf-style formatting. - * Truncates if result exceeds capacity. - * @return number of characters written (excluding null terminator) - **/ - template - size_type sprintf(const char * fmt, Args&&... args) { - int n; - if constexpr (sizeof...(Args) == 0) { - n = std::snprintf(chars_, capacity_, "%s", fmt); - } else { - n = std::snprintf(chars_, capacity_, fmt, std::forward(args)...); - } - if (n < 0) { - size_ = 0; - chars_[0] = '\0'; - } else { - size_ = (n < static_cast(capacity_)) ? n : capacity_ - 1; - } - return size_; - } - - /** lexicographically compare two strings. - * @return <0 if lhs < rhs, 0 if equal, >0 if lhs > rhs - **/ - static int compare(const DString & lhs, const DString & rhs) noexcept; - - /** compute hash of string contents **/ - std::size_t hash() const noexcept { - return std::hash{}(std::string_view(chars_, size_)); - } - - // TODO - behave like std::string, to the extent feasible - // insert - // insert_range - // erase - // push_back - // append - // append_range - // operator+= - // replace - // replace_with_range - // copy - // find - // rfind - // find_first_of - // find_first_not_of - // find_last_of - // find_last_not_of - // starts_with - // end_with - // contains - // substr - - /** recalculate string size if string contents modified without - * through side effects - **/ - size_type fixup_size() noexcept; - - ///@} - /** @defgroup dstring-conversion-operators conversion operators **/ - ///@{ - - operator std::string_view() const noexcept { return std::string_view(chars_); } - - /** @brief conversion oeprator to C-style string. - * - * Example - * @code - * DString s = ...; - * ::strcmp(s, "obey..."); - * @endcode - **/ - operator const char * () const noexcept { return &(chars_[0]); } - - ///@} - /** @defgroup dstring-printable-methods printable facet methods **/ - ///@{ - - bool pretty(const ppindentinfo & ppii) const; - - ///@} - /** @defgroup dstring-gcobject-methods gcobject facet methods **/ - ///@{ - - size_type shallow_size() const noexcept; - - /** clone string, using memory from allocator @p mm **/ - DString * shallow_copy(obj mm) const noexcept; - - size_type forward_children(obj gc) noexcept; - /** fixup child pointers (trivial for DString, no children) - * note: cref so we can use forward decl - **/ - - ///@} - - private: - /** @defgroup dstring-impl-methods implementation methods **/ - ///@{ - - /** create instance from view @p sv, using memory from @p mm. - * @p suballoc_flag chooses whether to use alloc() or suballoc(). - * Load-bearing for StringTable - **/ - static DString * _from_view_aux(obj mm, - std::string_view sv, - bool suballoc_flag); - - ///@} - - private: - /** @defgroup dstring-instance-variables instance variables **/ - ///@{ - - /** extent of @ref chars_ array **/ - size_type capacity_ = 0; - /** null terminator at @c chars_[size_] **/ - size_type size_ = 0; - /** string contents **/ - char chars_[]; - - ///@} - }; - - /** create string using printf-style formatting. - * Use memory from allocator @p mm with capacity @p cap. - * Truncates if result exceeds capacity. - * @return pointer to newly created DString - **/ - template - DString * DString::printf(obj mm, - size_type cap, - const char * fmt, - Args&&... args) - { - DString * result = DString::empty(mm, cap); - if (result) { - result->sprintf(fmt, std::forward(args)...); - } - return result; - } - - inline std::ostream & operator<<(std::ostream & os, const DString * x) { - if (x) { - os << std::string_view(*x); - } else { - os << "nullptr"; - } - return os; - } - - inline bool operator==(const DString & lhs, const DString & rhs) { - return DString::compare(lhs, rhs) == 0; - } - - inline bool operator!=(const DString & lhs, const DString & rhs) { - return DString::compare(lhs, rhs) != 0; - } - - inline bool operator<(const DString & lhs, const DString & rhs) { - return DString::compare(lhs, rhs) < 0; - } - - inline bool operator<=(const DString & lhs, const DString & rhs) { - return DString::compare(lhs, rhs) <= 0; - } - - inline bool operator>(const DString & lhs, const DString & rhs) { - return DString::compare(lhs, rhs) > 0; - } - - inline bool operator>=(const DString & lhs, const DString & rhs) { - return DString::compare(lhs, rhs) >= 0; - } - - } /*namespace scm*/ -} /*namespace xo*/ - -namespace std { - template <> - struct hash { - std::size_t operator()(const xo::scm::DString & x) const noexcept { - return x.hash(); - } - }; -} /*namespace std*/ - -/* end DString.hpp */ diff --git a/include/xo/object2/String.hpp b/include/xo/object2/String.hpp deleted file mode 100644 index f3d0527b..00000000 --- a/include/xo/object2/String.hpp +++ /dev/null @@ -1,14 +0,0 @@ -/** @file String.hpp - * - * @author Roland Conybeare, Feb 2026 - **/ - -#pragma once - -#include "DString.hpp" -#include "string/IGCObject_DString.hpp" -#include "string/IPrintable_DString.hpp" - -#include - -/* end String.hpp */ diff --git a/include/xo/object2/StringOps.hpp b/include/xo/object2/StringOps.hpp deleted file mode 100644 index 70441b4b..00000000 --- a/include/xo/object2/StringOps.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/** @file StringOps.hpp -* - * @author Roland Conybeare, Jan 2026 - **/ - -#pragma once - -#include "string/IGCObject_DString.hpp" -#include "DString.hpp" - -namespace xo { - namespace scm { - /** @brief string functions - * - * note: separate from DString - **/ - struct StringOps { - using AGCObject = xo::mm::AGCObject; - using AAllocator = xo::mm::AAllocator; - using size_type = DString::size_type; - - /** wrapper for DString.empty() **/ - template - static obj empty(obj mm, - size_type cap); - - /** wrapper for DString.from_cstr() **/ - template - static obj from_cstr(obj mm, - const char * cstr); - - /** wrapper for DString.clone() **/ - template - static obj clone(obj mm, - obj src); - - /** wrapper for DString.printf() **/ - template - static obj printf(obj mm, - size_type cap, - const char * fmt, - Args&&... args); - }; - - template - obj - StringOps::empty(obj mm, size_type cap) - { - return obj(DString::empty(mm, cap)); - } - - template - obj - StringOps::from_cstr(obj mm, const char * cstr) - { - return obj(DString::from_cstr(mm, cstr)); - } - - template - obj - StringOps::clone(obj mm, obj src) - { - return obj(DString::clone(mm, src.data())); - } - - template - obj - StringOps::printf(obj mm, - size_type cap, - const char * fmt, - Args&&... args) - { - return obj(DString::printf(mm, cap, fmt, - std::forward(args)...)); - } - } -} - -/* end StringOps.hpp */ diff --git a/include/xo/object2/object2_register_facets.hpp b/include/xo/object2/object2_register_facets.hpp index 7f42d5a0..7fb75cc7 100644 --- a/include/xo/object2/object2_register_facets.hpp +++ b/include/xo/object2/object2_register_facets.hpp @@ -5,8 +5,6 @@ #pragma once -#include - namespace xo { namespace scm { /** Register object2 (facet,impl) combinations with FacetRegistry **/ diff --git a/include/xo/object2/string/IGCObject_DString.hpp b/include/xo/object2/string/IGCObject_DString.hpp deleted file mode 100644 index 2a907f37..00000000 --- a/include/xo/object2/string/IGCObject_DString.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/** @file IGCObject_DString.hpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IGCObject_DString.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_repr.hpp.j2] - * 3. idl for facet methods - * [idl/IGCObject_DString.json5] - **/ - -#pragma once - -#include "GCObject.hpp" -#include -#include -#include "DString.hpp" - -namespace xo { namespace scm { class IGCObject_DString; } } - -namespace xo { - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::mm::IGCObject_Xfer - ; - }; - } -} - -namespace xo { - namespace scm { - /** @class IGCObject_DString - **/ - class IGCObject_DString { - public: - /** @defgroup scm-gcobject-dstring-type-traits **/ - ///@{ - using size_type = xo::mm::AGCObject::size_type; - using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; - using Copaque = xo::mm::AGCObject::Copaque; - using Opaque = xo::mm::AGCObject::Opaque; - ///@} - /** @defgroup scm-gcobject-dstring-methods **/ - ///@{ - // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DString & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DString & self, obj mm) noexcept; - - // non-const methods - /** during GC: forward immdiate children **/ - static size_type forward_children(DString & self, obj gc) noexcept; - ///@} - }; - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end */ diff --git a/include/xo/object2/string/IPrintable_DString.hpp b/include/xo/object2/string/IPrintable_DString.hpp deleted file mode 100644 index f898a17c..00000000 --- a/include/xo/object2/string/IPrintable_DString.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/** @file IPrintable_DString.hpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IPrintable_DString.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_repr.hpp.j2] - * 3. idl for facet methods - * [idl/IPrintable_DString.json5] - **/ - -#pragma once - -#include "Printable.hpp" -#include -#include -#include "DString.hpp" - -namespace xo { namespace scm { class IPrintable_DString; } } - -namespace xo { - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::print::IPrintable_Xfer - ; - }; - } -} - -namespace xo { - namespace scm { - /** @class IPrintable_DString - **/ - class IPrintable_DString { - public: - /** @defgroup scm-printable-dstring-type-traits **/ - ///@{ - using ppindentinfo = xo::print::APrintable::ppindentinfo; - using Copaque = xo::print::APrintable::Copaque; - using Opaque = xo::print::APrintable::Opaque; - ///@} - /** @defgroup scm-printable-dstring-methods **/ - ///@{ - // const methods - /** Pretty-printing support for this object. -See [xo-indentlog/xo/indentlog/pretty.hpp] **/ - static bool pretty(const DString & self, const ppindentinfo & ppii); - - // non-const methods - ///@} - }; - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index e9ae687a..f0aaefb7 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -33,10 +33,6 @@ set(SELF_SRCS IGCObject_DBoolean.cpp IPrintable_DBoolean.cpp - DString.cpp - IGCObject_DString.cpp - IPrintable_DString.cpp - DDictionary.cpp IGCObject_DDictionary.cpp IPrintable_DDictionary.cpp @@ -50,6 +46,7 @@ xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 $ # note: deps here must also appear in cmake/xo_object2Config.cmake.in xo_dependency(${SELF_LIB} reflect) xo_dependency(${SELF_LIB} xo_gc) +xo_dependency(${SELF_LIB} xo_stringtable2) xo_dependency(${SELF_LIB} xo_printable2) xo_dependency(${SELF_LIB} subsys) xo_dependency(${SELF_LIB} indentlog) diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp deleted file mode 100644 index 230fa4a4..00000000 --- a/src/object2/DString.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/** @file DString.cpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#include "DString.hpp" -#include -#include -#include -#include - -namespace xo { - using xo::reflect::typeseq; - using xo::print::ppdetail_atomic; - - namespace scm { - DString * - DString::empty(obj mm, - size_type cap) - { - assert(cap > 0); - - DString * result = nullptr; - - if (cap > 0) { - void * mem = mm.alloc(typeseq::id(), - sizeof(DString) + cap); - - result = new (mem) DString(); - - assert(result); - - result->capacity_ = cap; - result->size_ = 0; - if (cap > 0) { - result->chars_[0] = '\0'; - } - } - - return result; - } - - DString * - DString::from_cstr(obj mm, - const char * cstr) - { - size_type len = std::strlen(cstr); - size_type cap = len + 1; - - void * mem = mm.alloc(typeseq::id(), - sizeof(DString) + cap); - - DString * result = new (mem) DString(); - result->capacity_ = cap; - result->size_ = len; - std::memcpy(result->chars_, cstr, cap); - - return result; - } - - DString * - DString::_from_view_aux(obj mm, - std::string_view sv, - bool suballoc_flag) - { - size_type len = sv.size(); - size_type cap = len + 1; - - auto tseq = typeseq::id(); - void * mem = nullptr; - size_type mem_z = sizeof(DString) + cap; - - if (suballoc_flag) - mem = mm.sub_alloc(mem_z, false /*!complete_flag*/); - else - mem = mm.alloc(tseq, mem_z); - - DString * result = new (mem) DString(); - - result->capacity_ = cap; - result->size_ = len; - std::memcpy(result->chars_, sv.data(), len); - result->chars_[len] = '\0'; - - return result; - } - - DString * - DString::from_view(obj mm, - std::string_view sv) - { - return _from_view_aux(mm, sv, false /*!suballoc_flag*/); - } - - DString * - DString::from_str(obj mm, - const std::string & str) - { - return _from_view_aux(mm, - std::string_view(str), - false /*!suballoc_flag*/); - } - - DString * - DString::from_view_suballoc(obj mm, - std::string_view sv) - { - return _from_view_aux(mm, sv, true /*suballoc_flag*/); - } - - DString * - DString::clone(obj mm, const DString * src) - { - size_type cap = src->capacity_; - - void * mem = mm.alloc(typeseq::id(), - sizeof(DString) + cap); - - DString * result = new (mem) DString(); - result->capacity_ = cap; - result->size_ = src->size_; - std::memcpy(result->chars_, src->chars_, cap); - - return result; - } - - DString & - DString::assign(const DString & other) - { - size_type n = std::min(other.size_, capacity_ - 1); - std::memcpy(chars_, other.chars_, n); - chars_[n] = '\0'; - size_ = n; - - return *this; - } - - int - DString::compare(const DString & lhs, const DString & rhs) noexcept - { - return ::strcmp(lhs.chars_, rhs.chars_); - } - - auto - DString::fixup_size() noexcept -> size_type - { - this->chars_[capacity_ - 1] = '\0'; - this->size_ = ::strlen(chars_); - return this->size_; - } - - auto - DString::shallow_size() const noexcept -> size_type - { - return sizeof(DString) + capacity_; - } - - DString * - DString::shallow_copy(obj mm) const noexcept - { - DString * copy = (DString *)mm.alloc_copy((std::byte *)this); - - if (copy) { - copy->capacity_ = capacity_; - copy->size_ = size_; - ::memcpy(copy->chars_, chars_, capacity_); - } - - return copy; - } - - auto - DString::forward_children(obj) noexcept -> size_type - { - return shallow_size(); - } - - bool - DString::pretty(const ppindentinfo & ppii) const - { - return ppdetail_atomic::print_pretty(ppii, &(chars_[0])); - } - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end DString.cpp */ diff --git a/src/object2/IGCObject_DString.cpp b/src/object2/IGCObject_DString.cpp deleted file mode 100644 index d34f0eaf..00000000 --- a/src/object2/IGCObject_DString.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/** @file IGCObject_DString.cpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IGCObject_DString.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] - * 3. idl for facet methods - * [idl/IGCObject_DString.json5] -**/ - -#include "string/IGCObject_DString.hpp" - -namespace xo { - namespace scm { - auto - IGCObject_DString::shallow_size(const DString & self) noexcept -> size_type - { - return self.shallow_size(); - } - - auto - IGCObject_DString::shallow_copy(const DString & self, obj mm) noexcept -> Opaque - { - return self.shallow_copy(mm); - } - - auto - IGCObject_DString::forward_children(DString & self, obj gc) noexcept -> size_type - { - return self.forward_children(gc); - } - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IGCObject_DString.cpp */ diff --git a/src/object2/IPrintable_DString.cpp b/src/object2/IPrintable_DString.cpp deleted file mode 100644 index f5ec4967..00000000 --- a/src/object2/IPrintable_DString.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/** @file IPrintable_DString.cpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IPrintable_DString.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] - * 3. idl for facet methods - * [idl/IPrintable_DString.json5] -**/ - -#include "string/IPrintable_DString.hpp" - -namespace xo { - namespace scm { - auto - IPrintable_DString::pretty(const DString & self, const ppindentinfo & ppii) -> bool - { - return self.pretty(ppii); - } - - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IPrintable_DString.cpp */ diff --git a/src/object2/init_object2.cpp b/src/object2/init_object2.cpp index bcf7608c..7e4f6e4d 100644 --- a/src/object2/init_object2.cpp +++ b/src/object2/init_object2.cpp @@ -6,7 +6,8 @@ #include "init_object2.hpp" #include "object2_register_facets.hpp" #include "object2_register_types.hpp" -#include +#include +#include #include namespace xo { @@ -29,6 +30,7 @@ namespace xo { /* direct subsystem deps for xo-object2/ */ retval ^= InitSubsys::require(); + retval ^= InitSubsys::require(); /* xo-expression2/'s own initialization code */ retval ^= Subsystem::provide("object2", &init); diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 0b127179..3710b1d7 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -70,7 +70,6 @@ namespace xo { log && log(xtag("DBoolean.tseq", typeseq::id())); log && log(xtag("DFloat.tseq", typeseq::id())); log && log(xtag("DInteger.tseq", typeseq::id())); - log && log(xtag("DString.tseq", typeseq::id())); log && log(xtag("DArray.tseq", typeseq::id())); log && log(xtag("DDictionary.tseq", typeseq::id())); log && log(xtag("DRuntimeError.tseq", typeseq::id())); diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp index 3e0d50d1..20ae3b8e 100644 --- a/src/object2/object2_register_types.cpp +++ b/src/object2/object2_register_types.cpp @@ -36,8 +36,6 @@ namespace xo { ok &= gc.install_type(impl_for()); - ok &= gc.install_type(impl_for()); - ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 573fefd6..7843e0e9 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -4,8 +4,8 @@ set(UTEST_EXE utest.object2) set(UTEST_SRCS object2_utest_main.cpp DArray.test.cpp - DString.test.cpp - StringOps.test.cpp +# DString.test.cpp +# StringOps.test.cpp X1Collector.test.cpp Printable.test.cpp ) diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp deleted file mode 100644 index 53db8e7f..00000000 --- a/utest/DString.test.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/** @file DString.test.cpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#include "init_object2.hpp" -#include "StringOps.hpp" -#include -#include -#include -#include -#include -#include - -namespace xo { - using xo::scm::DString; - using xo::mm::AAllocator; - using xo::mm::DArena; - using xo::mm::ArenaConfig; - using xo::facet::with_facet; - using xo::facet::obj; - - namespace ut { - static InitEvidence s_init = (InitSubsys::require()); - - TEST_CASE("DString-init", "[object2][DString]") - { - // real purpose: ensure s_init survives static linking - REQUIRE(s_init.evidence()); - } - - TEST_CASE("DString-empty", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::empty(alloc, 16); - - REQUIRE(s != nullptr); - REQUIRE(s->capacity() == 16); - REQUIRE(s->size() == 0); - REQUIRE(s->chars()[0] == '\0'); - } - - TEST_CASE("DString-from_cstr", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - const char * cstr = "hello world"; - DString * s = DString::from_cstr(alloc, cstr); - - REQUIRE(s != nullptr); - REQUIRE(s->capacity() == 12); - REQUIRE(s->size() == 11); - REQUIRE(std::strcmp(s->chars(), cstr) == 0); - } - - TEST_CASE("DString-from_view", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - std::string_view sv = "hello world"; - DString * s = DString::from_view(alloc, sv); - - REQUIRE(s != nullptr); - REQUIRE(s->capacity() == 12); - REQUIRE(s->size() == 11); - REQUIRE(std::strcmp(s->chars(), "hello world") == 0); - - // test with substring (not null-terminated) - std::string_view sub = sv.substr(0, 5); - DString * s2 = DString::from_view(alloc, sub); - - REQUIRE(s2 != nullptr); - REQUIRE(s2->capacity() == 6); - REQUIRE(s2->size() == 5); - REQUIRE(std::strcmp(s2->chars(), "hello") == 0); - } - - TEST_CASE("DString-assign", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * src = DString::from_cstr(alloc, "hello"); - DString * dst = DString::empty(alloc, 16); - - dst->assign(*src); - - REQUIRE(dst->size() == 5); - REQUIRE(std::strcmp(dst->chars(), "hello") == 0); - } - - TEST_CASE("DString-assign-truncate", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * src = DString::from_cstr(alloc, "hello world"); - DString * dst = DString::empty(alloc, 6); - - dst->assign(*src); - - REQUIRE(dst->size() == 5); - REQUIRE(std::strcmp(dst->chars(), "hello") == 0); - } - - TEST_CASE("DString-data", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::empty(alloc, 16); - char * p = s->data(); - std::strcpy(p, "test"); - s->fixup_size(); - - REQUIRE(s->size() == 4); - REQUIRE(std::strcmp(s->chars(), "test") == 0); - } - - TEST_CASE("DString-operator-bracket", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::from_cstr(alloc, "hello"); - - REQUIRE((*s)[0] == 'h'); - REQUIRE((*s)[4] == 'o'); - - (*s)[0] = 'H'; - REQUIRE(std::strcmp(s->chars(), "Hello") == 0); - } - - TEST_CASE("DString-clear", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::from_cstr(alloc, "hello"); - REQUIRE(s->size() == 5); - - s->clear(); - - REQUIRE(s->size() == 0); - REQUIRE(s->chars()[0] == '\0'); - REQUIRE(s->capacity() == 6); - } - - TEST_CASE("DString-fixup_size", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::empty(alloc, 16); - char * p = s->data(); - p[0] = 'a'; - p[1] = 'b'; - p[2] = 'c'; - p[3] = '\0'; - - REQUIRE(s->size() == 0); - - auto new_size = s->fixup_size(); - - REQUIRE(new_size == 3); - REQUIRE(s->size() == 3); - } - - TEST_CASE("DString-string_view", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::from_cstr(alloc, "hello"); - std::string_view sv = *s; - - REQUIRE(sv == "hello"); - REQUIRE(sv.size() == 5); - } - - TEST_CASE("DString-cstr-conversion", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::from_cstr(alloc, "hello"); - const char * cstr = *s; - - REQUIRE(std::strcmp(cstr, "hello") == 0); - } - - TEST_CASE("DString-begin-end", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::from_cstr(alloc, "hello"); - - REQUIRE(s->begin() == s->chars()); - REQUIRE(s->end() == s->chars() + 5); - REQUIRE(s->end() - s->begin() == 5); - - *s->begin() = 'H'; - REQUIRE(std::strcmp(s->chars(), "Hello") == 0); - } - - TEST_CASE("DString-cbegin-cend", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::from_cstr(alloc, "hello"); - - REQUIRE(s->cbegin() == s->chars()); - REQUIRE(s->cend() == s->chars() + 5); - REQUIRE(s->cend() - s->cbegin() == 5); - } - - TEST_CASE("DString-range-for", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::from_cstr(alloc, "hello"); - - std::string result; - for (char c : *s) { - result += c; - } - - REQUIRE(result == "hello"); - } - - TEST_CASE("DString-iterator-modify", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::from_cstr(alloc, "hello"); - - for (auto it = s->begin(); it != s->end(); ++it) { - *it = std::toupper(*it); - } - - REQUIRE(std::strcmp(s->chars(), "HELLO") == 0); - } - - TEST_CASE("DString-clone", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * src = DString::from_cstr(alloc, "hello world"); - DString * copy = DString::clone(alloc, src); - - REQUIRE(copy != nullptr); - REQUIRE(copy != src); - REQUIRE(copy->size() == src->size()); - REQUIRE(copy->capacity() == src->capacity()); - REQUIRE(std::strcmp(copy->chars(), src->chars()) == 0); - } - - TEST_CASE("DString-sprintf", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::empty(alloc, 32); - - auto n = s->sprintf("hello %s %d", "world", 42); - - REQUIRE(n == 14); - REQUIRE(s->size() == 14); - REQUIRE(std::strcmp(s->chars(), "hello world 42") == 0); - } - - TEST_CASE("DString-sprintf-truncate", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s = DString::empty(alloc, 8); - - auto n = s->sprintf("hello world"); - - REQUIRE(n == 7); - REQUIRE(s->size() == 7); - REQUIRE(std::strcmp(s->chars(), "hello w") == 0); - } - - TEST_CASE("DString-compare", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s1 = DString::from_cstr(alloc, "apple"); - DString * s2 = DString::from_cstr(alloc, "apple"); - DString * s3 = DString::from_cstr(alloc, "banana"); - DString * s4 = DString::from_cstr(alloc, "aardvark"); - - REQUIRE(DString::compare(*s1, *s2) == 0); - REQUIRE(DString::compare(*s1, *s3) < 0); - REQUIRE(DString::compare(*s3, *s1) > 0); - REQUIRE(DString::compare(*s1, *s4) > 0); - REQUIRE(DString::compare(*s4, *s1) < 0); - } - - TEST_CASE("DString-comparison-operators", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * apple1 = DString::from_cstr(alloc, "apple"); - DString * apple2 = DString::from_cstr(alloc, "apple"); - DString * banana = DString::from_cstr(alloc, "banana"); - - // operator== - REQUIRE(*apple1 == *apple1); - REQUIRE(*apple2 == *apple2); - REQUIRE(*banana == *banana); - REQUIRE(*apple1 == *apple2); - - REQUIRE_FALSE(*apple1 == *banana); - - // operator!= - REQUIRE(*apple1 != *banana); - REQUIRE_FALSE(*apple1 != *apple1); - REQUIRE_FALSE(*apple2 != *apple2); - REQUIRE_FALSE(*apple1 != *apple2); - REQUIRE_FALSE(*banana != *banana); - - // operator< - REQUIRE(*apple1 < *banana); - REQUIRE_FALSE(*banana < *apple1); - REQUIRE_FALSE(*apple1 < *apple2); - - // operator<= - REQUIRE(*apple1 <= *banana); - REQUIRE(*apple1 <= *apple2); - REQUIRE_FALSE(*banana <= *apple1); - - // operator> - REQUIRE(*banana > *apple1); - REQUIRE_FALSE(*apple1 > *banana); - REQUIRE_FALSE(*apple1 > *apple2); - - // operator>= - REQUIRE(*banana >= *apple1); - REQUIRE(*apple1 >= *apple2); - REQUIRE_FALSE(*apple1 >= *banana); - } - - TEST_CASE("DString-hash", "[object2][DString]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - DString * s1 = DString::from_cstr(alloc, "hello"); - DString * s2 = DString::from_cstr(alloc, "hello"); - DString * s3 = DString::from_cstr(alloc, "world"); - DString * empty1 = DString::empty(alloc, 16); - DString * empty2 = DString::empty(alloc, 32); - - // same content produces same hash - REQUIRE(s1->hash() == s2->hash()); - - // empty strings have same hash - REQUIRE(empty1->hash() == empty2->hash()); - - // different content produces different hash (not guaranteed, but highly likely) - REQUIRE(s1->hash() != s3->hash()); - - // std::hash specialization works - std::hash hasher; - REQUIRE(hasher(*s1) == s1->hash()); - REQUIRE(hasher(*s2) == s2->hash()); - REQUIRE(hasher(*s1) == hasher(*s2)); - } - } /*namespace ut*/ -} /*namespace xo*/ - -/* end DString.test.cpp */ diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index 2ca792fa..15de595d 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -12,9 +12,9 @@ #include #include -#include -#include -#include +#include +//#include +//#include #include #include diff --git a/utest/StringOps.test.cpp b/utest/StringOps.test.cpp deleted file mode 100644 index 26464f90..00000000 --- a/utest/StringOps.test.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/** @file StringOps.test.cpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#include -#include -#include -#include - -namespace xo { - using xo::scm::StringOps; - using xo::scm::DString; - using xo::mm::AAllocator; - using xo::mm::AGCObject; - using xo::mm::DArena; - using xo::mm::ArenaConfig; - using xo::facet::with_facet; - using xo::facet::obj; - - namespace ut { - TEST_CASE("StringOps-empty", "[object2][StringOps]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - auto s = StringOps::empty(alloc, 16); - - REQUIRE(s.data() != nullptr); - REQUIRE(s.data()->capacity() == 16); - REQUIRE(s.data()->size() == 0); - REQUIRE(s.data()->chars()[0] == '\0'); - } - - TEST_CASE("StringOps-empty-with-content", "[object2][StringOps]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - auto s = StringOps::empty(alloc, 32); - - s.data()->sprintf("hello %s %d", "world", 42); - - REQUIRE(s.data()->size() == 14); - REQUIRE(std::strcmp(s.data()->chars(), "hello world 42") == 0); - } - - TEST_CASE("StringOps-from_cstr", "[object2][StringOps]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - const char * cstr = "hello world"; - auto s = StringOps::from_cstr(alloc, cstr); - - REQUIRE(s.data() != nullptr); - REQUIRE(s.data()->capacity() == 12); - REQUIRE(s.data()->size() == 11); - REQUIRE(std::strcmp(s.data()->chars(), cstr) == 0); - } - - TEST_CASE("StringOps-clone", "[object2][StringOps]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - auto src = StringOps::from_cstr(alloc, "hello world"); - auto copy = StringOps::clone(alloc, src); - - REQUIRE(copy.data() != nullptr); - REQUIRE(copy.data() != src.data()); - REQUIRE(copy.data()->size() == src.data()->size()); - REQUIRE(copy.data()->capacity() == src.data()->capacity()); - REQUIRE(std::strcmp(copy.data()->chars(), src.data()->chars()) == 0); - } - - TEST_CASE("StringOps-printf", "[object2][StringOps]") - { - ArenaConfig cfg { .name_ = "testarena", - .size_ = 4*1024 }; - DArena arena = DArena::map(cfg); - auto alloc = with_facet::mkobj(&arena); - - auto s = StringOps::printf(alloc, 32, "hello %s %d", "world", 42); - - REQUIRE(s.data() != nullptr); - REQUIRE(s.data()->capacity() == 32); - REQUIRE(s.data()->size() == 14); - REQUIRE(std::strcmp(s.data()->chars(), "hello world 42") == 0); - } - } /*namespace ut*/ -} /*namespace xo*/ - -/* end StringOps.test.cpp */ diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index a2a2dec5..55e0107c 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -15,7 +15,7 @@ #include "number/IGCObject_DInteger.hpp" #include "list/IGCObject_DList.hpp" -#include +#include #include #include From 6178892c1a3aa79c82970f83b443f2cf44161a9e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Mar 2026 13:02:12 +1100 Subject: [PATCH 126/176] xo-interpreter2 stack: refactor: string clases -> xo-stringtable2/ --- CMakeLists.txt | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b27b70e..1735dd5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,26 +116,6 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- -# note: manual target; generated code committed to git -xo_add_genfacetimpl( - TARGET xo-object2-facetimpl-printable-string - FACET_PKG xo_printable2 - FACET Printable - REPR String - INPUT idl/IPrintable_DString.json5 -) - -# note: manual target; generated code committed to git -xo_add_genfacetimpl( - TARGET xo-object2-facetimpl-gcobject-string - FACET_PKG xo_gc - FACET GCObject - REPR String - INPUT idl/IGCObject_DString.json5 -) - -# ---------------------------------------------------------------- - # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-array From e2b239dfb920aba5b72878f69cbd300de4021b41 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Mar 2026 20:11:05 +1100 Subject: [PATCH 127/176] xo-object2 stack: refactor/tidy after GCObject -> alloc2 --- CMakeLists.txt | 14 +++++++------- cmake/xo_object2Config.cmake.in | 2 +- idl/IGCObject_DArray.json5 | 2 +- idl/IGCObject_DBoolean.json5 | 4 ++-- idl/IGCObject_DDictionary.json5 | 2 +- idl/IGCObject_DFloat.json5 | 2 +- idl/IGCObject_DInteger.json5 | 2 +- idl/IGCObject_DList.json5 | 2 +- idl/IGCObject_DRuntimeError.json5 | 2 +- idl/Sequence.json5 | 2 +- include/xo/object2/array/IGCObject_DArray.hpp | 2 +- include/xo/object2/boolean/IGCObject_DBoolean.hpp | 4 +--- .../object2/dictionary/IGCObject_DDictionary.hpp | 2 +- .../object2/number/GCObjectConversion_DFloat.hpp | 2 +- .../object2/number/GCObjectConversion_DInteger.hpp | 2 +- include/xo/object2/number/IGCObject_DFloat.hpp | 2 +- include/xo/object2/number/IGCObject_DInteger.hpp | 2 +- src/object2/CMakeLists.txt | 2 +- src/object2/ISequence_Any.cpp | 2 +- utest/CMakeLists.txt | 1 + utest/Printable.test.cpp | 3 ++- 21 files changed, 29 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1735dd5b..09ebb96e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-list - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR List INPUT idl/IGCObject_DList.json5 @@ -68,7 +68,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-boolean - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR Boolean INPUT idl/IGCObject_DBoolean.json5 @@ -88,7 +88,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-float - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR Float INPUT idl/IGCObject_DFloat.json5 @@ -108,7 +108,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-integer - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR Integer INPUT idl/IGCObject_DInteger.json5 @@ -137,7 +137,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-array - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR Array INPUT idl/IGCObject_DArray.json5 @@ -157,7 +157,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-dictionary - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR Dictionary INPUT idl/IGCObject_DDictionary.json5 @@ -177,7 +177,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-runtimeerror - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR RuntimeError INPUT idl/IGCObject_DRuntimeError.json5 diff --git a/cmake/xo_object2Config.cmake.in b/cmake/xo_object2Config.cmake.in index 78ee9e0f..b34f76ff 100644 --- a/cmake/xo_object2Config.cmake.in +++ b/cmake/xo_object2Config.cmake.in @@ -2,8 +2,8 @@ include(CMakeFindDependencyMacro) find_dependency(reflect) -find_dependency(xo_gc) find_dependency(xo_stringtable2) +find_dependency(xo_alloc2) find_dependency(xo_printable2) find_dependency(subsys) find_dependency(indentlog) diff --git a/idl/IGCObject_DArray.json5 b/idl/IGCObject_DArray.json5 index bef5bd62..96507a75 100644 --- a/idl/IGCObject_DArray.json5 +++ b/idl/IGCObject_DArray.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/object2", output_impl_subdir: "array", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DBoolean.json5 b/idl/IGCObject_DBoolean.json5 index c9aaf26b..c739ccda 100644 --- a/idl/IGCObject_DBoolean.json5 +++ b/idl/IGCObject_DBoolean.json5 @@ -4,8 +4,8 @@ output_hpp_dir: "include/xo/object2", output_impl_subdir: "boolean", includes: [ - "", - "" +// "", +// "" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IGCObject_DDictionary.json5 b/idl/IGCObject_DDictionary.json5 index 636413be..ebf8fd8b 100644 --- a/idl/IGCObject_DDictionary.json5 +++ b/idl/IGCObject_DDictionary.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/object2", output_impl_subdir: "dictionary", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DFloat.json5 b/idl/IGCObject_DFloat.json5 index eec1e3e3..2255f414 100644 --- a/idl/IGCObject_DFloat.json5 +++ b/idl/IGCObject_DFloat.json5 @@ -5,7 +5,7 @@ output_impl_subdir: "number", includes: [ "", - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DInteger.json5 b/idl/IGCObject_DInteger.json5 index 37d603e5..18093306 100644 --- a/idl/IGCObject_DInteger.json5 +++ b/idl/IGCObject_DInteger.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/object2", output_impl_subdir: "number", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DList.json5 b/idl/IGCObject_DList.json5 index 28fb3352..ecb48980 100644 --- a/idl/IGCObject_DList.json5 +++ b/idl/IGCObject_DList.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/object2", output_impl_subdir: "list", includes: [ -// "", +// "", // "" ], local_types: [ ], diff --git a/idl/IGCObject_DRuntimeError.json5 b/idl/IGCObject_DRuntimeError.json5 index cfcbe9f6..a0e15042 100644 --- a/idl/IGCObject_DRuntimeError.json5 +++ b/idl/IGCObject_DRuntimeError.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/object2", output_impl_subdir: "error", includes: [ -// "", +// "", // "" ], local_types: [ ], diff --git a/idl/Sequence.json5 b/idl/Sequence.json5 index 20271697..0b022f0b 100644 --- a/idl/Sequence.json5 +++ b/idl/Sequence.json5 @@ -3,7 +3,7 @@ output_cpp_dir: "src/object2", output_hpp_dir: "include/xo/object2", output_impl_subdir: "sequence", - includes: [""], + includes: [""], // extra includes in Sequence.hpp, if any user_hpp_includes: [], namespace1: "xo", diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 08f78aa8..6eb571e5 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 358aad18..9afd9646 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -14,8 +14,6 @@ #pragma once #include "GCObject.hpp" -#include -#include #include "DBoolean.hpp" namespace xo { namespace scm { class IGCObject_DBoolean; } } @@ -64,4 +62,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 7fe1bc55..2d69f990 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/object2/number/GCObjectConversion_DFloat.hpp b/include/xo/object2/number/GCObjectConversion_DFloat.hpp index 959eeca0..4cc47517 100644 --- a/include/xo/object2/number/GCObjectConversion_DFloat.hpp +++ b/include/xo/object2/number/GCObjectConversion_DFloat.hpp @@ -7,7 +7,7 @@ #include "DFloat.hpp" #include "number/IGCObject_DFloat.hpp" -#include +#include namespace xo { namespace scm { diff --git a/include/xo/object2/number/GCObjectConversion_DInteger.hpp b/include/xo/object2/number/GCObjectConversion_DInteger.hpp index 458312c9..5b01e571 100644 --- a/include/xo/object2/number/GCObjectConversion_DInteger.hpp +++ b/include/xo/object2/number/GCObjectConversion_DInteger.hpp @@ -7,7 +7,7 @@ #include "DInteger.hpp" #include "number/IGCObject_DInteger.hpp" -#include +#include namespace xo { namespace scm { diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index b8e15b73..ee2eecfd 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -65,4 +65,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index fd2ea642..799372ad 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index f0aaefb7..b2370cf4 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -45,8 +45,8 @@ set(SELF_SRCS xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) # note: deps here must also appear in cmake/xo_object2Config.cmake.in xo_dependency(${SELF_LIB} reflect) -xo_dependency(${SELF_LIB} xo_gc) xo_dependency(${SELF_LIB} xo_stringtable2) +xo_dependency(${SELF_LIB} xo_alloc2) xo_dependency(${SELF_LIB} xo_printable2) xo_dependency(${SELF_LIB} subsys) xo_dependency(${SELF_LIB} indentlog) diff --git a/src/object2/ISequence_Any.cpp b/src/object2/ISequence_Any.cpp index 77da7d31..5e0583f0 100644 --- a/src/object2/ISequence_Any.cpp +++ b/src/object2/ISequence_Any.cpp @@ -3,8 +3,8 @@ **/ #include "sequence/ISequence_Any.hpp" -#include #include +#include namespace xo { namespace scm { diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 7843e0e9..e4532c26 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -12,5 +12,6 @@ set(UTEST_SRCS xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) xo_self_dependency(${UTEST_EXE} xo_object2) +xo_dependency(${UTEST_EXE} xo_gc) #xo_dependency(${UTEST_EXE} randomgen) xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2) diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index 15de595d..edf230a4 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -20,7 +20,8 @@ #include #include -#include + +#include #include #include From 2b528f4159d73822efda0e80021584f1f977eb74 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Mar 2026 20:25:32 +1100 Subject: [PATCH 128/176] nix-build: + xo.procedure2 --- src/object2/DDictionary.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index b939eaac..d39e669b 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -39,9 +39,10 @@ namespace xo { DDictionary::at_index(size_type ix) const { if (ix < keys_->size()) { +#ifndef NDEBUG auto key_str = obj::from((*keys_)[ix]); - assert(key_str); +#endif return pair_type(this->key_at_index(ix), (*values_)[ix]); } From 5e4e85efefd262c5c6d7f5828e06eca90d65ed79 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 6 Mar 2026 13:04:31 +1100 Subject: [PATCH 129/176] xo-type: + DAtomicType [WIP] --- idl/IGCObject_DList.json5 | 2 -- 1 file changed, 2 deletions(-) diff --git a/idl/IGCObject_DList.json5 b/idl/IGCObject_DList.json5 index ecb48980..83d1838b 100644 --- a/idl/IGCObject_DList.json5 +++ b/idl/IGCObject_DList.json5 @@ -4,8 +4,6 @@ output_hpp_dir: "include/xo/object2", output_impl_subdir: "list", includes: [ -// "", -// "" ], local_types: [ ], namespace1: "xo", From c58d52244e74b5e624f1de7b429e8a9d30b85a22 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 7 Mar 2026 00:27:24 +1100 Subject: [PATCH 130/176] xo-object2: doxygen nit --- include/xo/object2/DList.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 50ab8dd7..01ef3eb6 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -57,9 +57,12 @@ namespace xo { // GCObject facet + /** @defgroup xo-scm-list-gcobject-facet gcobject facet **/ + ///@{ size_type shallow_size() const noexcept; DList * shallow_copy(obj mm) const noexcept; size_type forward_children(obj gc) noexcept; + ///@} /** first member of list **/ obj head_; From c77ca9ff38e0b5abff5f29596d894fc4d9b071e9 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 7 Mar 2026 00:31:52 +1100 Subject: [PATCH 131/176] xo-object2: idl build nits --- idl/IGCObject_DArray.json5 | 4 ++-- idl/IGCObject_DDictionary.json5 | 4 ++-- idl/IGCObject_DFloat.json5 | 4 ++-- idl/IGCObject_DInteger.json5 | 4 ++-- include/xo/object2/array/IGCObject_DArray.hpp | 2 -- include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 2 -- include/xo/object2/number/IGCObject_DFloat.hpp | 2 -- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/idl/IGCObject_DArray.json5 b/idl/IGCObject_DArray.json5 index 96507a75..4d7187b9 100644 --- a/idl/IGCObject_DArray.json5 +++ b/idl/IGCObject_DArray.json5 @@ -4,8 +4,8 @@ output_hpp_dir: "include/xo/object2", output_impl_subdir: "array", includes: [ - "", - "" +// "", +// "" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IGCObject_DDictionary.json5 b/idl/IGCObject_DDictionary.json5 index ebf8fd8b..07a171c5 100644 --- a/idl/IGCObject_DDictionary.json5 +++ b/idl/IGCObject_DDictionary.json5 @@ -4,8 +4,8 @@ output_hpp_dir: "include/xo/object2", output_impl_subdir: "dictionary", includes: [ - "", - "" +// "", +// "" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IGCObject_DFloat.json5 b/idl/IGCObject_DFloat.json5 index 2255f414..c1f12815 100644 --- a/idl/IGCObject_DFloat.json5 +++ b/idl/IGCObject_DFloat.json5 @@ -5,8 +5,8 @@ output_impl_subdir: "number", includes: [ "", - "", - "" +// "", +// "" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IGCObject_DInteger.json5 b/idl/IGCObject_DInteger.json5 index 18093306..cb318ee1 100644 --- a/idl/IGCObject_DInteger.json5 +++ b/idl/IGCObject_DInteger.json5 @@ -4,8 +4,8 @@ output_hpp_dir: "include/xo/object2", output_impl_subdir: "number", includes: [ - "", - "" +// "", +// "" ], local_types: [ ], namespace1: "xo", diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 6eb571e5..d2b4f340 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -14,8 +14,6 @@ #pragma once #include "GCObject.hpp" -#include -#include #include "DArray.hpp" namespace xo { namespace scm { class IGCObject_DArray; } } diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 2d69f990..3682f095 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -14,8 +14,6 @@ #pragma once #include "GCObject.hpp" -#include -#include #include "DDictionary.hpp" namespace xo { namespace scm { class IGCObject_DDictionary; } } diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index ee2eecfd..e62d14d3 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -15,8 +15,6 @@ #include "GCObject.hpp" #include -#include -#include #include "DFloat.hpp" namespace xo { namespace scm { class IGCObject_DFloat; } } From 381d9602fb07d374a77a2b199627cb5bf32f82e6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 08:41:57 -0500 Subject: [PATCH 132/176] build: retiring REPR argument to xo_add_genfacetimpl() --- CMakeLists.txt | 32 +++++++++---------- .../xo/object2/number/IGCObject_DInteger.hpp | 2 -- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09ebb96e..151d3ed8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-list FACET_PKG xo_object2 FACET Sequence - REPR List +# REPR List INPUT idl/ISequence_DList.json5 ) @@ -41,7 +41,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-list FACET_PKG xo_printable2 FACET Printable - REPR List +# REPR List INPUT idl/IPrintable_DList.json5 ) @@ -50,7 +50,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-list FACET_PKG xo_alloc2 FACET GCObject - REPR List +# REPR List INPUT idl/IGCObject_DList.json5 ) @@ -61,7 +61,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-boolean FACET_PKG xo_printable2 FACET Printable - REPR Boolean +# REPR Boolean INPUT idl/IPrintable_DBoolean.json5 ) @@ -70,7 +70,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-boolean FACET_PKG xo_alloc2 FACET GCObject - REPR Boolean +# REPR Boolean INPUT idl/IGCObject_DBoolean.json5 ) @@ -81,7 +81,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-float FACET_PKG xo_printable2 FACET Printable - REPR Float +# REPR Float INPUT idl/IPrintable_DFloat.json5 ) @@ -90,7 +90,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-float FACET_PKG xo_alloc2 FACET GCObject - REPR Float +# REPR Float INPUT idl/IGCObject_DFloat.json5 ) @@ -101,7 +101,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-integer FACET_PKG xo_printable2 FACET Printable - REPR Integer +# REPR Integer INPUT idl/IPrintable_DInteger.json5 ) @@ -110,7 +110,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-integer FACET_PKG xo_alloc2 FACET GCObject - REPR Integer +# REPR Integer INPUT idl/IGCObject_DInteger.json5 ) @@ -121,7 +121,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-array FACET_PKG xo_object2 FACET Sequence - REPR Array +# REPR Array INPUT idl/ISequence_DArray.json5 ) @@ -130,7 +130,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-array FACET_PKG xo_printable2 FACET Printable - REPR Array +# REPR Array INPUT idl/IPrintable_DArray.json5 ) @@ -139,7 +139,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-array FACET_PKG xo_alloc2 FACET GCObject - REPR Array +# REPR Array INPUT idl/IGCObject_DArray.json5 ) @@ -150,7 +150,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-dictionary FACET_PKG xo_printable2 FACET Printable - REPR Dictionary +# REPR Dictionary INPUT idl/IPrintable_DDictionary.json5 ) @@ -159,7 +159,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-dictionary FACET_PKG xo_alloc2 FACET GCObject - REPR Dictionary +# REPR Dictionary INPUT idl/IGCObject_DDictionary.json5 ) @@ -170,7 +170,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-runtimeerror FACET_PKG xo_printable2 FACET Printable - REPR RuntimeError +# REPR RuntimeError INPUT idl/IPrintable_DRuntimeError.json5 ) @@ -179,7 +179,7 @@ xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-runtimeerror FACET_PKG xo_alloc2 FACET GCObject - REPR RuntimeError +# REPR RuntimeError INPUT idl/IGCObject_DRuntimeError.json5 ) diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 799372ad..f2737071 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -14,8 +14,6 @@ #pragma once #include "GCObject.hpp" -#include -#include #include "DInteger.hpp" namespace xo { namespace scm { class IGCObject_DInteger; } } From 84ddc0338b5ea4e17cccb588b5786f79dd767b7b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 10:03:46 -0500 Subject: [PATCH 133/176] build: retire FACET argument to genfacetimpl --- CMakeLists.txt | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 151d3ed8..23cbf6b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ xo_add_genfacet( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-list FACET_PKG xo_object2 - FACET Sequence # REPR List INPUT idl/ISequence_DList.json5 ) @@ -40,7 +39,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-list FACET_PKG xo_printable2 - FACET Printable # REPR List INPUT idl/IPrintable_DList.json5 ) @@ -49,7 +47,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-list FACET_PKG xo_alloc2 - FACET GCObject # REPR List INPUT idl/IGCObject_DList.json5 ) @@ -60,7 +57,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-boolean FACET_PKG xo_printable2 - FACET Printable # REPR Boolean INPUT idl/IPrintable_DBoolean.json5 ) @@ -69,7 +65,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-boolean FACET_PKG xo_alloc2 - FACET GCObject # REPR Boolean INPUT idl/IGCObject_DBoolean.json5 ) @@ -80,7 +75,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-float FACET_PKG xo_printable2 - FACET Printable # REPR Float INPUT idl/IPrintable_DFloat.json5 ) @@ -89,7 +83,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-float FACET_PKG xo_alloc2 - FACET GCObject # REPR Float INPUT idl/IGCObject_DFloat.json5 ) @@ -100,7 +93,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-integer FACET_PKG xo_printable2 - FACET Printable # REPR Integer INPUT idl/IPrintable_DInteger.json5 ) @@ -109,7 +101,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-integer FACET_PKG xo_alloc2 - FACET GCObject # REPR Integer INPUT idl/IGCObject_DInteger.json5 ) @@ -120,7 +111,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-array FACET_PKG xo_object2 - FACET Sequence # REPR Array INPUT idl/ISequence_DArray.json5 ) @@ -129,7 +119,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-array FACET_PKG xo_printable2 - FACET Printable # REPR Array INPUT idl/IPrintable_DArray.json5 ) @@ -138,7 +127,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-array FACET_PKG xo_alloc2 - FACET GCObject # REPR Array INPUT idl/IGCObject_DArray.json5 ) @@ -149,7 +137,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-dictionary FACET_PKG xo_printable2 - FACET Printable # REPR Dictionary INPUT idl/IPrintable_DDictionary.json5 ) @@ -158,7 +145,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-dictionary FACET_PKG xo_alloc2 - FACET GCObject # REPR Dictionary INPUT idl/IGCObject_DDictionary.json5 ) @@ -169,7 +155,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-runtimeerror FACET_PKG xo_printable2 - FACET Printable # REPR RuntimeError INPUT idl/IPrintable_DRuntimeError.json5 ) @@ -178,7 +163,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-runtimeerror FACET_PKG xo_alloc2 - FACET GCObject # REPR RuntimeError INPUT idl/IGCObject_DRuntimeError.json5 ) From 87f08a4e4da8bc3e2ef12bb500347bc7f7436d53 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 16:19:40 -0500 Subject: [PATCH 134/176] xo-interpreter2: + nil + cons --- include/xo/object2/DList.hpp | 10 +++++++++- src/object2/DList.cpp | 18 +++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 01ef3eb6..8009f7b5 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -26,11 +26,14 @@ namespace xo { DList(xo::obj h, DList * r) : head_{h}, rest_{r} {} - /** sentinel for null list. + /** sentinel for null list. Idempotent. * Application code may prefer ListOps::nil() **/ static DList * _nil(); + /** like _nil(), but retrn fop wrapper **/ + static obj nil(); + /** list with first element @p car, * followed by contents of list @p cdr. * Shares structure with @p cdr @@ -40,6 +43,11 @@ namespace xo { obj car, DList * cdr); + /** like @c _cons(mm,car,cdr), but return fop wrapper **/ + static obj cons(obj mm, + obj car, + DList * cdr); + /** DList length is at least 1 **/ bool is_empty() const noexcept; /** DList models a finite sequence **/ diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 25770d01..7ef06f36 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -17,7 +17,7 @@ namespace xo { using xo::print::APrintable; using xo::mm::AGCObject; using xo::facet::FacetRegistry; - using xo::facet::typeseq; + //using xo::facet::typeseq; namespace scm { static DList s_null(obj(), nullptr); @@ -28,6 +28,12 @@ namespace xo { return &s_null; } + obj + DList::nil() + { + return obj(_nil()); + } + DList * DList::_cons(obj mm, obj car, @@ -38,6 +44,14 @@ namespace xo { return new (mem) DList(car, cdr); } + obj + DList::cons(obj mm, + obj car, + DList * cdr) + { + return obj(_cons(mm, car, cdr)); + } + #ifdef OBSOLETE DList * DList::list(obj mm, @@ -137,8 +151,6 @@ namespace xo { obj elt = FacetRegistry::instance().variant(l->head_); - - assert(elt.data()); if (!pps->print_upto(elt)) From bd811111a1194696f9ebee69f4afb1acd13272eb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 00:57:17 -0500 Subject: [PATCH 135/176] x-procedure2: + dict_lookup() primitive --- include/xo/object2/DDictionary.hpp | 4 ++++ src/object2/DDictionary.cpp | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index f5844088..28f9651f 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -110,6 +110,9 @@ namespace xo { /** current dictionary size (number of key-value pairs) **/ size_type size() const noexcept { return keys_->size(); } + /** return value associated with @p key, if key is present **/ + std::optional> lookup(const DString * key) const noexcept; + /** return element @p key-value pair at position @p index (0-based) **/ std::pair> at_index(size_type index) const; /** return @p i'th key. O(1) **/ @@ -117,6 +120,7 @@ namespace xo { /** return @p i'th value. O(1) **/ obj value_at_index(size_type i) const; + auto operator[](const DString * key) const noexcept { return LValue(this, key); } auto operator[](const DString * key) noexcept { return LValue(this, key); } diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index d39e669b..40c85c08 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -35,6 +35,21 @@ namespace xo { return new (mem) DDictionary(keys, values); } + std::optional> + DDictionary::lookup(const DString * key) const noexcept + { + for (DArray::size_type i = 0, z = keys_->size(); i < z; ++i) { + auto i_key = obj::from(keys_->at(i)); + + assert(i_key); + + if (DString::compare(*key, *i_key.data()) == 0) + return values_->at(i); + } + + return {}; + } + std::pair> DDictionary::at_index(size_type ix) const { From a136642a2024e3ec57674907bf2d867aa70ec31f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 09:03:24 -0500 Subject: [PATCH 136/176] xo-interpreter2 stack: + dict type + pop more pm types --- include/xo/object2/DArray.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 55d5e068..332d126a 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -72,7 +72,7 @@ namespace xo { * Darray * v = DArray::array(mm, e1, e2, e3); **/ template - requires (std::same_as> && ...) + requires (std::convertible_to> && ...) static DArray * array(obj mm, Args... args); ///@} @@ -170,7 +170,7 @@ namespace xo { }; template - requires (std::same_as> && ...) + requires (std::convertible_to> && ...) DArray * DArray::array(obj mm, Args... args) { From 441044dd0106c1c6d2e1e4f64463ebf4de89e956 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 14:57:23 -0500 Subject: [PATCH 137/176] xo-object2: streamline setup --- include/xo/object2/SetupObject2.hpp | 23 +++++++++ .../xo/object2/object2_register_facets.hpp | 15 ------ include/xo/object2/object2_register_types.hpp | 17 ------- src/object2/CMakeLists.txt | 3 +- ...2_register_facets.cpp => SetupObject2.cpp} | 27 ++++++++-- src/object2/init_object2.cpp | 10 ++-- src/object2/object2_register_types.cpp | 50 ------------------- utest/Printable.test.cpp | 12 ++--- utest/X1Collector.test.cpp | 2 - 9 files changed, 55 insertions(+), 104 deletions(-) create mode 100644 include/xo/object2/SetupObject2.hpp delete mode 100644 include/xo/object2/object2_register_facets.hpp delete mode 100644 include/xo/object2/object2_register_types.hpp rename src/object2/{object2_register_facets.cpp => SetupObject2.cpp} (79%) delete mode 100644 src/object2/object2_register_types.cpp diff --git a/include/xo/object2/SetupObject2.hpp b/include/xo/object2/SetupObject2.hpp new file mode 100644 index 00000000..7e6e3453 --- /dev/null +++ b/include/xo/object2/SetupObject2.hpp @@ -0,0 +1,23 @@ +/** @file SetupObject2.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + struct SetupObject2 { + public: + using ACollector = xo::mm::ACollector; + + public: + static bool register_facets(); + static bool register_types(obj gc); + }; + } +} + +/* end object2_register_facets.hpp */ diff --git a/include/xo/object2/object2_register_facets.hpp b/include/xo/object2/object2_register_facets.hpp deleted file mode 100644 index 7fb75cc7..00000000 --- a/include/xo/object2/object2_register_facets.hpp +++ /dev/null @@ -1,15 +0,0 @@ -/** @file object2_register_facets.hpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#pragma once - -namespace xo { - namespace scm { - /** Register object2 (facet,impl) combinations with FacetRegistry **/ - bool object2_register_facets(); - } -} - -/* end object2_register_facets.hpp */ diff --git a/include/xo/object2/object2_register_types.hpp b/include/xo/object2/object2_register_types.hpp deleted file mode 100644 index 5663b086..00000000 --- a/include/xo/object2/object2_register_types.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/** @file object2_register_types.hpp - * - * @author Roland Conybeare, Dec 2025 - **/ - -#pragma once - -#include - -namespace xo { - namespace scm { - /** Register object2 (facet,impl) combinations with FacetRegistry **/ - bool object2_register_types(obj gc); - } -} - -/* end object2_register_types.hpp */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index b2370cf4..77816186 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -3,8 +3,7 @@ set(SELF_LIB xo_object2) set(SELF_SRCS init_object2.cpp - object2_register_types.cpp - object2_register_facets.cpp + SetupObject2.cpp GCObjectConversion_DFloat.cpp GCObjectConversion_DInteger.cpp diff --git a/src/object2/object2_register_facets.cpp b/src/object2/SetupObject2.cpp similarity index 79% rename from src/object2/object2_register_facets.cpp rename to src/object2/SetupObject2.cpp index 3710b1d7..e2d8c2ee 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/SetupObject2.cpp @@ -1,9 +1,9 @@ -/** @file object2_register_facets.cpp +/** @file SetupObject2.cpp * * @author Roland Conybeare, Jan 2026 **/ -#include "object2_register_facets.hpp" +#include "SetupObject2.hpp" #include "RuntimeError.hpp" #include @@ -21,6 +21,7 @@ namespace xo { using xo::print::APrintable; + using xo::mm::ACollector; using xo::mm::AAllocator; using xo::mm::AGCObject; using xo::scm::DList; @@ -30,11 +31,12 @@ namespace xo { using xo::scm::DArray; using xo::facet::DVariantPlaceholder; using xo::facet::FacetRegistry; + using xo::facet::impl_for; using xo::facet::typeseq; namespace scm { bool - object2_register_facets() + SetupObject2::register_facets() { scope log(XO_DEBUG(true)); @@ -81,7 +83,24 @@ namespace xo { return true; } + + bool + SetupObject2::register_types(obj gc) + { + scope log(XO_DEBUG(true)); + + bool ok = true; + + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + + return ok; + } } /*namespace scm*/ } /*namespace xo*/ -/* end object2_register_facets.cpp */ +/* end SetupObject2.cpp */ diff --git a/src/object2/init_object2.cpp b/src/object2/init_object2.cpp index 7e4f6e4d..1a2ed770 100644 --- a/src/object2/init_object2.cpp +++ b/src/object2/init_object2.cpp @@ -4,23 +4,21 @@ **/ #include "init_object2.hpp" -#include "object2_register_facets.hpp" -#include "object2_register_types.hpp" +#include "SetupObject2.hpp" #include #include #include namespace xo { - using xo::scm::object2_register_facets; - using xo::scm::object2_register_types; + using xo::scm::SetupObject2; using xo::mm::CollectorTypeRegistry; void InitSubsys::init() { - object2_register_facets(); + SetupObject2::register_facets(); - CollectorTypeRegistry::instance().register_types(&object2_register_types); + CollectorTypeRegistry::instance().register_types(&SetupObject2::register_types); } InitEvidence diff --git a/src/object2/object2_register_types.cpp b/src/object2/object2_register_types.cpp deleted file mode 100644 index 20ae3b8e..00000000 --- a/src/object2/object2_register_types.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/** @file object2_register_types.cpp - * - * @author Roland Conybeare, Dec 2025 - **/ - -#include "object2_register_types.hpp" - -#include "boolean/IGCObject_DBoolean.hpp" -#include "number/IGCObject_DFloat.hpp" -#include "number/IGCObject_DInteger.hpp" -#include "string/IGCObject_DString.hpp" -#include "list/IGCObject_DList.hpp" -#include "array/IGCObject_DArray.hpp" -#include "dictionary/IGCObject_DDictionary.hpp" - -#include -#include - -namespace xo { - using xo::mm::ACollector; - using xo::mm::AGCObject; - using xo::facet::impl_for; - using xo::scope; - - namespace scm { - bool - object2_register_types(obj gc) - { - scope log(XO_DEBUG(true)); - - bool ok = true; - - ok &= gc.install_type(impl_for()); - - ok &= gc.install_type(impl_for()); - - ok &= gc.install_type(impl_for()); - - ok &= gc.install_type(impl_for()); - - ok &= gc.install_type(impl_for()); - - ok &= gc.install_type(impl_for()); - - return ok; - } - } -} /*namespace xo*/ - -/* end object2_register_types.cpp */ diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index edf230a4..d31f8456 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -5,16 +5,13 @@ #include "ListOps.hpp" #include "DList.hpp" -#include "object2_register_types.hpp" -#include "object2_register_facets.hpp" +#include "SetupObject2.hpp" #include #include #include #include -//#include -//#include #include #include @@ -35,8 +32,7 @@ #include namespace ut { - using xo::scm::object2_register_types; - using xo::scm::object2_register_facets; + using xo::scm::SetupObject2; using xo::scm::ListOps; using xo::scm::DList; using xo::scm::DInteger; @@ -89,7 +85,7 @@ namespace ut { constexpr bool c_debug_flag = true; scope log(XO_DEBUG(c_debug_flag)); - bool ok = object2_register_facets(); + bool ok = SetupObject2::register_facets(); REQUIRE(ok); FacetRegistry::instance().dump(&std::cerr); @@ -114,7 +110,7 @@ namespace ut { auto gc_o = with_facet::mkobj(&gc); auto c_o = with_facet::mkobj(&gc); - bool ok = object2_register_types(c_o); + bool ok = SetupObject2::register_types(c_o); REQUIRE(ok); auto l0_o = ListOps::nil(); diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 55e0107c..882bb758 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -9,7 +9,6 @@ #include "DInteger.hpp" #include "DList.hpp" #include "DArray.hpp" -#include "object2_register_types.hpp" #include "number/IGCObject_DFloat.hpp" #include "number/IGCObject_DInteger.hpp" @@ -34,7 +33,6 @@ namespace ut { using xo::S_object2_tag; - using xo::scm::object2_register_types; using xo::scm::ListOps; using xo::scm::DList; using xo::scm::DArray; From daf86b151da8fa5f59dfe8d10de5b22e2d0828f6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Mar 2026 21:02:27 -0400 Subject: [PATCH 138/176] cosmetic --- include/xo/object2/DDictionary.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 28f9651f..f05eb56a 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -1,5 +1,5 @@ /** @file DDictionary.hpp -* + * * @author Roland Conybeare, Jan 2026 **/ From 78145b1105a01aa443634ed9d6da59c3a874628a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Mar 2026 21:03:39 -0400 Subject: [PATCH 139/176] xo-object2: nit: dictionary printing --- src/object2/DDictionary.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 40c85c08..f92cbbb3 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -184,6 +184,7 @@ namespace xo { if (!pps->print_upto(value)) return false; + pps->write(";"); } pps->write("}"); From bca732a132169b5d65f690562e8446f56bd33de0 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 17:49:23 -0400 Subject: [PATCH 140/176] xo-object2: minor: default AGCObject for DBoolean.make() --- include/xo/object2/DBoolean.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index ee9fe3be..72f5fad7 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -16,13 +16,14 @@ namespace xo { struct DBoolean { using AAllocator = xo::mm::AAllocator; using ACollector = xo::mm::ACollector; + using AGCObject = xo::mm::AGCObject; using ppindentinfo = xo::print::ppindentinfo; using value_type = long; explicit DBoolean(bool x) : value_{x} {} /** will likely want this to default to ANumeric, once we have it **/ - template + template static obj box(obj mm, bool x); /** allocate boxed value @p x using memory from @p mm **/ From 2bfc43bfe5eb215a0d931f78eb31acc34e765f0f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 22:09:04 -0400 Subject: [PATCH 141/176] xo-object2: X1Collector utest follows RootSet intro --- utest/X1Collector.test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 882bb758..956c519d 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -131,11 +131,11 @@ namespace ut { REQUIRE(otypes->reserved() >= cfg.object_types_z_); REQUIRE(otypes->reserved() < cfg.object_types_z_ + otypes->page_z_); - const DArena * roots = gc.get_roots(); + const DX1Collector::RootSet * roots = gc.get_root_set(); REQUIRE(roots != nullptr); - REQUIRE(roots->reserved() >= cfg.object_roots_z_); - REQUIRE(roots->reserved() < cfg.object_roots_z_ + roots->page_z_); + REQUIRE(roots->store()->reserved() >= cfg.object_roots_z_); + REQUIRE(roots->store()->reserved() < cfg.object_roots_z_ + roots->store()->page_z_); const DArena * from_0 = gc.get_space(role::from_space(), generation{0}); From 74f84f6c8b9ebdf8b70b5544cd142aa091716e5b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 22:12:38 -0400 Subject: [PATCH 142/176] xo-interpreter2: + xo-gc dep for primitives --- utest/X1Collector.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 956c519d..517e04bf 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -172,7 +172,7 @@ namespace ut { REQUIRE(to_2 == nullptr); REQUIRE(gc.reserved_total() - == otypes->reserved() + roots->reserved() + 4 * from_0->reserved()); + == otypes->reserved() + roots->store()->reserved() + 4 * from_0->reserved()); log && log(xtag("from_0", from_0->lo_), xtag("to_0", to_0->lo_)); } From 27564ec4a7ed72e02549f926f6edbbda2989c50e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 22:17:41 -0400 Subject: [PATCH 143/176] xo-procedure2: + assign_head + set-car pm impl [WIP] Not actuall installed in global env --- include/xo/object2/DList.hpp | 2 ++ src/object2/DList.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 8009f7b5..ddc54f3f 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -57,6 +57,8 @@ namespace xo { /** return element at 0-based index @p ix **/ obj at(size_type ix) const; + /** assign head **/ + void assign_head(obj gc, obj h); /** assign rest-pointer **/ void assign_rest(DList * r); diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 7ef06f36..b9ac0583 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -119,6 +119,14 @@ namespace xo { return l->head_; } + void + DList::assign_head(obj gc, obj rhs) + { + scope log(XO_DEBUG(true), xtag("gc.data", gc.data_)); + + mm_do_assign(gc, this, &head_, rhs); + } + void DList::assign_rest(DList * r) { From 0b405cd01739d26b10501d79086be5809b4a42a3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 25 Mar 2026 19:31:59 -0400 Subject: [PATCH 144/176] xo-interpreter2 stack: VSM as AGCObject for virtual root --- src/object2/DArray.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index f26c5238..707a7296 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -185,7 +185,11 @@ namespace xo { std::size_t DArray::forward_children(obj gc) noexcept { + scope log(XO_DEBUG(true)); + for (size_type i = 0; i < size_; ++i) { + log && log("DArray::forward_children (loop)", xtag("i", i), xtag("z", size_)); + obj & elt = elts_[i]; gc.forward_inplace(&elt); From 69dde32c238e30f1bbf06cc2203f62a335aa65aa Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 26 Mar 2026 11:30:16 -0400 Subject: [PATCH 145/176] xo-gc: generation -> Generation + bugfix idle test --- utest/X1Collector.test.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 517e04bf..085764f6 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -48,7 +48,7 @@ namespace ut { using xo::mm::DArena; using xo::mm::X1CollectorConfig; using xo::mm::ArenaConfig; - using xo::mm::generation; + using xo::mm::Generation; using xo::mm::role; using xo::mm::padding; using xo::facet::with_facet; @@ -137,7 +137,7 @@ namespace ut { REQUIRE(roots->store()->reserved() >= cfg.object_roots_z_); REQUIRE(roots->store()->reserved() < cfg.object_roots_z_ + roots->store()->page_z_); - const DArena * from_0 = gc.get_space(role::from_space(), generation{0}); + const DArena * from_0 = gc.get_space(role::from_space(), Generation{0}); REQUIRE(from_0 != nullptr); REQUIRE(from_0->reserved() >= tc.tenured_z_); @@ -145,29 +145,29 @@ namespace ut { REQUIRE(from_0->reserved() % from_0->page_z_ == 0); REQUIRE(from_0->allocated() == 0); - const DArena * from_1 = gc.get_space(role::from_space(), generation{1}); + const DArena * from_1 = gc.get_space(role::from_space(), Generation{1}); REQUIRE(from_1 != nullptr); REQUIRE(from_1->reserved() == from_0->reserved()); REQUIRE(from_1->allocated() == 0); - to_0 = gc.get_space(role::to_space(), generation{0}); + to_0 = gc.get_space(role::to_space(), Generation{0}); REQUIRE(to_0 != nullptr); REQUIRE(to_0->reserved() == from_0->reserved()); REQUIRE(to_0->allocated() == 0); - const DArena * to_1 = gc.get_space(role::to_space(), generation{1}); + const DArena * to_1 = gc.get_space(role::to_space(), Generation{1}); REQUIRE(to_1 != nullptr); REQUIRE(to_1->reserved() == to_0->reserved()); REQUIRE(to_1->allocated() == 0); - const DArena * from_2 = gc.get_space(role::from_space(), generation{2}); + const DArena * from_2 = gc.get_space(role::from_space(), Generation{2}); REQUIRE(from_2 == nullptr); - const DArena * to_2 = gc.get_space(role::to_space(), generation{2}); + const DArena * to_2 = gc.get_space(role::to_space(), Generation{2}); REQUIRE(to_2 == nullptr); @@ -257,7 +257,7 @@ namespace ut { } /* no GC roots, so GC is trivial */ - c_o.request_gc(generation{1}); + c_o.request_gc(Generation{1}); log && log(xtag("l0_o.data()", l0_o.data())); log && log(xtag("l0_o.data()->head_.data()", l0_o.data()->head_.data())); From faafd5c1fa2195dddee97f80afd5b0ed3df9f257 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Mar 2026 22:40:19 -0400 Subject: [PATCH 146/176] xo-object2: drop DArray debug --- src/object2/DArray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 707a7296..8ec73691 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -185,7 +185,7 @@ namespace xo { std::size_t DArray::forward_children(obj gc) noexcept { - scope log(XO_DEBUG(true)); + scope log(XO_DEBUG(false)); for (size_type i = 0; i < size_; ++i) { log && log("DArray::forward_children (loop)", xtag("i", i), xtag("z", size_)); From 375f8c1ec426924fd6eebaeb7d9e8daa68a56e05 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 29 Mar 2026 13:44:19 -0400 Subject: [PATCH 147/176] xo-gc stack: + request-gc-statistics() primitive 1. xo-gc now depends on xo-object2. 2. use genfacet for ICollector_DX1Collector 3. moves xo-gc utest previously in xo-object2 to more natural location in xo-gc/ --- CMakeLists.txt | 1 - include/xo/object2/DDictionary.hpp | 12 ++- include/xo/object2/DInteger.hpp | 3 +- src/object2/DDictionary.cpp | 40 +++++++++- utest/CMakeLists.txt | 6 +- utest/Printable.test.cpp | 124 +---------------------------- utest/X1Collector.test.cpp | 13 ++- 7 files changed, 64 insertions(+), 135 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23cbf6b1..b4ef253f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ xo_add_genfacet( xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-list FACET_PKG xo_object2 -# REPR List INPUT idl/ISequence_DList.json5 ) diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index f05eb56a..af66f3e6 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -139,6 +139,16 @@ namespace xo { **/ bool try_update(const pair_type & kvpair); + /** convenience method: + * try_upsert pair (k, @p value), after boxing c-style string @p key with @p mm to get k + **/ + bool try_upsert_cstr(obj mm, const char * key, obj value); + + /** convenience method: + * upsert pair (k, @p value), after boxing c-style string @p key with @p mm to get k + **/ + bool upsert_cstr(obj mm, const char * key, obj value); + /** upsert key-value pair @p kvpair into dictionary. * If key kvpair.first not already present, add it. * In either case replace/establish associated value with kvpair.second. @@ -210,7 +220,7 @@ namespace xo { { DDictionary * result = empty(mm, sizeof...(args)); if (result) { - (result->upsert(args), ...); + (result->upsert(mm, args), ...); } return result; } diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index 3fd13672..f1fa16aa 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -16,13 +16,14 @@ namespace xo { struct DInteger { using AAllocator = xo::mm::AAllocator; using ACollector = xo::mm::ACollector; + using AGCObject = xo::mm::AGCObject; using ppindentinfo = xo::print::ppindentinfo; using value_type = long; explicit DInteger(long x) : value_{x} {} /** will likely want this to default to ANumeric, once we have it **/ - template + template static obj box(obj mm, long x); /** allocate boxed value @p x using memory from @p mm **/ diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index f92cbbb3..faa44589 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -104,6 +104,22 @@ namespace xo { return false; } + bool + DDictionary::try_upsert_cstr(obj mm, const char * key_cstr, obj value) + { + const DString * k1 = DString::from_cstr(mm, key_cstr); + + return this->try_upsert(std::make_pair(k1, value)); + } + + bool + DDictionary::upsert_cstr(obj mm, const char * key_cstr, obj value) + { + const DString * k1 = DString::from_cstr(mm, key_cstr); + + return this->upsert(mm, std::make_pair(k1, value)); + } + bool DDictionary::try_upsert(const pair_type & kv_pair) { @@ -190,7 +206,29 @@ namespace xo { pps->write("}"); return true; } else { - pps->write("{...}"); + pps->write("{"); + + for (size_type i = 0, n = this->size(); i < n; ++i) { + if (i == 0) { + /* indent, but credit initial {. using same line for first (key,value) */ + ppii.pps()->indent(std::max(ppii.pps()->indent_width(), 1u) - 1); + } else { + /* indent after newline */ + ppii.pps()->newline_indent(ppii.ci1()); + } + + obj key + = FacetRegistry::instance().variant((*keys_)[i]); + obj value + = FacetRegistry::instance().variant((*values_)[i]); + + pps->pretty(key); + pps->write(": "); + pps->pretty(value); + pps->write(";"); + } + + pps->write(" }"); return false; } } diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index e4532c26..34046715 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -6,12 +6,12 @@ set(UTEST_SRCS DArray.test.cpp # DString.test.cpp # StringOps.test.cpp - X1Collector.test.cpp - Printable.test.cpp +# X1Collector.test.cpp # moved to xo-gc/ +# Printable.test.cpp # moved to xo-gc/ ) xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) xo_self_dependency(${UTEST_EXE} xo_object2) -xo_dependency(${UTEST_EXE} xo_gc) +#xo_dependency(${UTEST_EXE} xo_gc) #xo_dependency(${UTEST_EXE} randomgen) xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2) diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index d31f8456..289029e8 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -18,9 +18,9 @@ #include -#include -#include -#include +//#include +//#include +//#include #include @@ -31,123 +31,5 @@ #include -namespace ut { - using xo::scm::SetupObject2; - using xo::scm::ListOps; - using xo::scm::DList; - using xo::scm::DInteger; - using xo::scm::DString; - using xo::mm::AAllocator; - using xo::mm::ACollector; - using xo::mm::AGCObject; - using xo::mm::DX1Collector; - using xo::mm::X1CollectorConfig; - using xo::mm::ArenaConfig; - using xo::print::APrintable; - using xo::facet::FacetRegistry; - using xo::facet::with_facet; - using xo::facet::obj; - using xo::facet::typeseq; - using xo::print::ppstate_standalone; - using xo::print::ppconfig; - using xo::scope; - using xo::xtag; - using std::string; - - namespace { - struct testcase_pp { - explicit testcase_pp(size_t gc_z, size_t gc_threshold, int z, const std::string & expected) - : gc_gen_size_{gc_z}, gc_trigger_threshold_{gc_threshold}, expected_{expected} { - for (int i = 0; i < z; ++i) { - list_.push_back(1000 + 197 * i); - } - } - - size_t gc_gen_size_ = 0; - size_t gc_trigger_threshold_ = 0; - std::vector list_; - std::string expected_; - }; - - std::vector - s_testcase_v = { - testcase_pp(16384, 8192, 0, "()"), - testcase_pp(16384, 8192, 1, "(01000)"), - testcase_pp(16384, 8192, 2, "(01000 1197)"), - testcase_pp(16384, 8192, 5, "(01000 1197 01394 1591 01788)"), - testcase_pp(16384, 8192, 10, "(01000 1197 01394 1591 01788 1985 02182 2379 02576 2773)"), - testcase_pp(16384, 8192, 20, "(...)"), - }; - } - - TEST_CASE("printable1", "[pp][x1][list]") - { - constexpr bool c_debug_flag = true; - scope log(XO_DEBUG(c_debug_flag)); - - bool ok = SetupObject2::register_facets(); - REQUIRE(ok); - - FacetRegistry::instance().dump(&std::cerr); - - for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) { - log && log("printable1 test:", xtag("i_tc", i_tc)); - - try { - const testcase_pp & tc = s_testcase_v[i_tc]; - - X1CollectorConfig cfg{ .name_ = "pp_test", - .arena_config_ = ArenaConfig{ - .size_ = tc.gc_gen_size_, - .store_header_flag_ = true}, - .object_types_z_ = 16384, - .gc_trigger_v_{{tc.gc_trigger_threshold_, - tc.gc_trigger_threshold_}}, - .debug_flag_ = c_debug_flag - }; - - DX1Collector gc(cfg); - auto gc_o = with_facet::mkobj(&gc); - auto c_o = with_facet::mkobj(&gc); - - bool ok = SetupObject2::register_types(c_o); - REQUIRE(ok); - - auto l0_o = ListOps::nil(); - - c_o.add_gc_root(&l0_o); - - for(int ip1 = tc.list_.size(); ip1 > 0; --ip1) { - obj elt; - - //elt = DInteger::box(gc_o, tc.list_[ip1 - 1]); - - if (ip1 % 2 == 0) { - elt = DInteger::box(gc_o, tc.list_[ip1 - 1]); - } else { - elt = obj(DString::printf(gc_o, 80, "%05d", tc.list_[ip1 - 1])); - } - - l0_o = ListOps::cons(gc_o, elt, l0_o); - } - - // TODO: log_streambuf using DArena - std::stringstream ss; - ppconfig ppc; - ppstate_standalone pps(&ss, 0, &ppc); - - obj l0_po(static_cast(l0_o.data())); - REQUIRE(l0_po._typeseq() == typeseq::id()); - - pps.pretty(l0_po); - - CHECK(ss.str() == string(tc.expected_)); - } catch (std::exception & ex) { - std::cerr << "caught exception: " << ex.what() << std::endl; - REQUIRE(false); - } - } - } /* TEST_CASE(printable1) */ -} /* end Printable.test.cpp */ diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 085764f6..59565c1f 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -16,10 +16,9 @@ #include #include -#include - -#include -#include +//#include +//#include +//#include #include #include @@ -44,9 +43,9 @@ namespace ut { using xo::mm::AllocHeader; using xo::mm::AllocInfo; using xo::mm::AGCObject; - using xo::mm::DX1Collector; +// using xo::mm::DX1Collector; using xo::mm::DArena; - using xo::mm::X1CollectorConfig; +// using xo::mm::X1CollectorConfig; using xo::mm::ArenaConfig; using xo::mm::Generation; using xo::mm::role; @@ -171,7 +170,7 @@ namespace ut { REQUIRE(to_2 == nullptr); - REQUIRE(gc.reserved_total() + REQUIRE(gc.reserved() == otypes->reserved() + roots->store()->reserved() + 4 * from_0->reserved()); log && log(xtag("from_0", from_0->lo_), xtag("to_0", to_0->lo_)); From 1cbae893b912b77ced00230296e8677252a1b259 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 29 Mar 2026 15:17:31 -0400 Subject: [PATCH 148/176] xo-gc: use DArenaVector for DX1Collector.object_types_ Original implementation predated DArenaVector, using it is more natural --- src/object2/SetupObject2.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/object2/SetupObject2.cpp b/src/object2/SetupObject2.cpp index e2d8c2ee..ff22a800 100644 --- a/src/object2/SetupObject2.cpp +++ b/src/object2/SetupObject2.cpp @@ -97,6 +97,7 @@ namespace xo { ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); return ok; } From 28cd1523faaf053e520fff822bd89cb5aa7a8e62 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 29 Mar 2026 17:19:23 -0400 Subject: [PATCH 149/176] xo-gc stack: + gc-report-object-types() primitive --- include/xo/object2/DDictionary.hpp | 7 +++++ include/xo/object2/DInteger.hpp | 2 ++ src/object2/DArray.cpp | 22 ++++++++++++++-- src/object2/DDictionary.cpp | 42 ++++++++++++++++++++++++++---- 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index af66f3e6..63a7eba1 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -112,6 +112,8 @@ namespace xo { /** return value associated with @p key, if key is present **/ std::optional> lookup(const DString * key) const noexcept; + /** return value associated with @p key, if key is present **/ + std::optional> lookup_cstr(const char * key) const noexcept; /** return element @p key-value pair at position @p index (0-based) **/ std::pair> at_index(size_type index) const; @@ -139,6 +141,11 @@ namespace xo { **/ bool try_update(const pair_type & kvpair); + /** update key-value pair for existing @p key to map to @p value. + * false if @p key not already present. + **/ + bool try_update_cstr(const char * key, obj value); + /** convenience method: * try_upsert pair (k, @p value), after boxing c-style string @p key with @p mm to get k **/ diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index f1fa16aa..a67e18d3 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -35,6 +35,8 @@ namespace xo { operator long() const noexcept { return value_; } + void assign_value(long x) noexcept { this->value_ = x; } + // GCObject facet std::size_t shallow_size() const noexcept; diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 8ec73691..a55fbf97 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -101,7 +101,7 @@ namespace xo { bool DArray::resize(size_type new_z) noexcept { - if (new_z >= capacity_) { + if (new_z > capacity_) { return false; } else if (new_z > size_) { // ensure new size is zeroed (we/re not zeroing if/when we shrink) @@ -149,7 +149,25 @@ namespace xo { pps->write("]"); return true; } else { - pps->write("[...]"); + pps->write("["); + + for (size_type i = 0, n = this->size(); i < n; ++i) { + if (i == 0) { + /* indent, but credit initial [ */ + pps->indent(std::max(pps->indent_width(), 1u) - 1); + } else { + /* indent after newline */ + pps->newline_indent(ppii.ci1()); + } + + obj elt = this->at(i).to_facet(); + + assert(elt.data()); + + pps->pretty(elt); + } + + pps->write("]"); return false; } } diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index faa44589..d585ded4 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -50,6 +50,21 @@ namespace xo { return {}; } + std::optional> + DDictionary::lookup_cstr(const char * key) const noexcept + { + for (DArray::size_type i = 0, z = keys_->size(); i < z; ++i) { + auto i_key = obj::from(keys_->at(i)); + + assert(i_key); + + if (strcmp(key, i_key->data()) == 0) + return values_->at(i); + } + + return {}; + } + std::pair> DDictionary::at_index(size_type ix) const { @@ -104,6 +119,24 @@ namespace xo { return false; } + bool + DDictionary::try_update_cstr(const char * key, obj value) + { + for (size_type i = 0, n = keys_->size(); i < n; ++i) { + auto key_i = obj::from((*keys_)[i]); + + assert(key_i); + + if (strcmp(key, key_i->data()) == 0) { + values_->assign_at(i, value); + + return true; + } + } + + return false; + } + bool DDictionary::try_upsert_cstr(obj mm, const char * key_cstr, obj value) { @@ -183,8 +216,7 @@ namespace xo { pps->write("{"); for (size_type i = 0, n = this->size(); i < n; ++i) { - if (i > 0) - pps->write(" "); + pps->write(" "); obj key = FacetRegistry::instance().variant((*keys_)[i]); @@ -203,7 +235,7 @@ namespace xo { pps->write(";"); } - pps->write("}"); + pps->write(" }"); return true; } else { pps->write("{"); @@ -211,10 +243,10 @@ namespace xo { for (size_type i = 0, n = this->size(); i < n; ++i) { if (i == 0) { /* indent, but credit initial {. using same line for first (key,value) */ - ppii.pps()->indent(std::max(ppii.pps()->indent_width(), 1u) - 1); + pps->indent(std::max(pps->indent_width(), 1u) - 1); } else { /* indent after newline */ - ppii.pps()->newline_indent(ppii.ci1()); + pps->newline_indent(ppii.ci1()); } obj key From 24f857588c70b4e633c39c22a9ac35e5720149e3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 14:38:14 -0400 Subject: [PATCH 150/176] refactor: make AGCObject.shallow_copy() non-const prep for moving to ACollector interface --- include/xo/object2/DDictionary.hpp | 2 +- include/xo/object2/DList.hpp | 2 +- include/xo/object2/array/IGCObject_DArray.hpp | 4 ++-- include/xo/object2/boolean/IGCObject_DBoolean.hpp | 4 ++-- include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 4 ++-- include/xo/object2/error/IGCObject_DRuntimeError.hpp | 4 ++-- include/xo/object2/list/IGCObject_DList.hpp | 4 ++-- include/xo/object2/number/IGCObject_DFloat.hpp | 4 ++-- include/xo/object2/number/IGCObject_DInteger.hpp | 4 ++-- include/xo/object2/sequence/ASequence.hpp | 5 +++++ src/object2/DDictionary.cpp | 2 +- src/object2/DList.cpp | 2 +- src/object2/IGCObject_DArray.cpp | 3 +-- src/object2/IGCObject_DBoolean.cpp | 3 +-- src/object2/IGCObject_DDictionary.cpp | 3 +-- src/object2/IGCObject_DFloat.cpp | 3 +-- src/object2/IGCObject_DInteger.cpp | 3 +-- src/object2/IGCObject_DList.cpp | 3 +-- src/object2/IGCObject_DRuntimeError.cpp | 3 +-- 19 files changed, 30 insertions(+), 32 deletions(-) diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 63a7eba1..1c77d2cf 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -203,7 +203,7 @@ namespace xo { /** shallow memory consumption. Excludes child objects **/ AAllocator::size_type shallow_size() const noexcept; /** return shallow copy of this array, using memory from @p mm **/ - DDictionary * shallow_copy(obj mm) const noexcept; + DDictionary * shallow_copy(obj mm) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ AAllocator::size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index ddc54f3f..f6ea9d8b 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -70,7 +70,7 @@ namespace xo { /** @defgroup xo-scm-list-gcobject-facet gcobject facet **/ ///@{ size_type shallow_size() const noexcept; - DList * shallow_copy(obj mm) const noexcept; + DList * shallow_copy(obj mm) noexcept; size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index d2b4f340..4854eff4 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DArray & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DArray & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DArray & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DArray & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 9afd9646..c437f0bc 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DBoolean & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DBoolean & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DBoolean & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DBoolean & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 3682f095..323afd6e 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DDictionary & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DDictionary & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DDictionary & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DDictionary & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index 3bb4d3d8..f09be05a 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DRuntimeError & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DRuntimeError & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DRuntimeError & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DRuntimeError & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index 7e1f1428..e601ce0b 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DList & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DList & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DList & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DList & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index e62d14d3..f9040b1b 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -51,10 +51,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DFloat & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DFloat & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DFloat & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DFloat & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index f2737071..b6532128 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DInteger & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DInteger & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DInteger & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DInteger & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/sequence/ASequence.hpp b/include/xo/object2/sequence/ASequence.hpp index 44f1d1cb..fcb272bc 100644 --- a/include/xo/object2/sequence/ASequence.hpp +++ b/include/xo/object2/sequence/ASequence.hpp @@ -49,6 +49,11 @@ public: /** @defgroup scm-sequence-methods **/ ///@{ // const methods + /** An uninitialized ASequence instance will have zero vtable pointer (per {linux,osx} abi). + * Use case for this is narrow. We go to some lengths to avoid null vtable pointers. For example + * obj will have non-null vtable (via IFacet_Any) with all methods terminating. + **/ + bool _has_null_vptr() const noexcept { return *reinterpret_cast(this) == nullptr; } /** RTTI: unique id# for actual runtime data representation **/ virtual typeseq _typeseq() const noexcept = 0; /** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/ diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index d585ded4..263ea97d 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -274,7 +274,7 @@ namespace xo { } DDictionary * - DDictionary::shallow_copy(obj mm) const noexcept + DDictionary::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index b9ac0583..6f93147e 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -185,7 +185,7 @@ namespace xo { } DList * - DList::shallow_copy(obj mm) const noexcept + DList::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index 1063bd45..9b28a3de 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DArray::shallow_copy(const DArray & self, obj mm) noexcept -> Opaque + IGCObject_DArray::shallow_copy(DArray & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DArray::forward_children(DArray & self, obj gc) noexcept -> size_type { diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp index 3ef60aea..e6bd6000 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DBoolean::shallow_copy(const DBoolean & self, obj mm) noexcept -> Opaque + IGCObject_DBoolean::shallow_copy(DBoolean & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DBoolean::forward_children(DBoolean & self, obj gc) noexcept -> size_type { diff --git a/src/object2/IGCObject_DDictionary.cpp b/src/object2/IGCObject_DDictionary.cpp index a6705d98..0466edd5 100644 --- a/src/object2/IGCObject_DDictionary.cpp +++ b/src/object2/IGCObject_DDictionary.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DDictionary::shallow_copy(const DDictionary & self, obj mm) noexcept -> Opaque + IGCObject_DDictionary::shallow_copy(DDictionary & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DDictionary::forward_children(DDictionary & self, obj gc) noexcept -> size_type { diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index 9e31cf68..4b1ab562 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DFloat::shallow_copy(const DFloat & self, obj mm) noexcept -> Opaque + IGCObject_DFloat::shallow_copy(DFloat & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DFloat::forward_children(DFloat & self, obj gc) noexcept -> size_type { diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 55e1fae7..fbb31908 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DInteger::shallow_copy(const DInteger & self, obj mm) noexcept -> Opaque + IGCObject_DInteger::shallow_copy(DInteger & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DInteger::forward_children(DInteger & self, obj gc) noexcept -> size_type { diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index f4e9472b..80cd7cd1 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DList::shallow_copy(const DList & self, obj mm) noexcept -> Opaque + IGCObject_DList::shallow_copy(DList & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DList::forward_children(DList & self, obj gc) noexcept -> size_type { diff --git a/src/object2/IGCObject_DRuntimeError.cpp b/src/object2/IGCObject_DRuntimeError.cpp index d44c4359..6d167819 100644 --- a/src/object2/IGCObject_DRuntimeError.cpp +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DRuntimeError::shallow_copy(const DRuntimeError & self, obj mm) noexcept -> Opaque + IGCObject_DRuntimeError::shallow_copy(DRuntimeError & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj gc) noexcept -> size_type { From 0cb20c3789d15cc908085c815400f00b3109b93f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 15:00:53 -0400 Subject: [PATCH 151/176] refactor: rename GCObject.shallow_copy -> shallow_move resolve conflict since relying on move constructor in std_copy_for --- include/xo/object2/DArray.hpp | 2 +- include/xo/object2/DBoolean.hpp | 2 +- include/xo/object2/DDictionary.hpp | 2 +- include/xo/object2/DFloat.hpp | 2 +- include/xo/object2/DInteger.hpp | 2 +- include/xo/object2/DList.hpp | 2 +- include/xo/object2/DRuntimeError.hpp | 2 +- include/xo/object2/array/IGCObject_DArray.hpp | 4 ++-- include/xo/object2/boolean/IGCObject_DBoolean.hpp | 4 ++-- include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 4 ++-- include/xo/object2/error/IGCObject_DRuntimeError.hpp | 4 ++-- include/xo/object2/list/IGCObject_DList.hpp | 4 ++-- include/xo/object2/number/IGCObject_DFloat.hpp | 4 ++-- include/xo/object2/number/IGCObject_DInteger.hpp | 4 ++-- src/object2/DArray.cpp | 2 +- src/object2/DBoolean.cpp | 2 +- src/object2/DDictionary.cpp | 2 +- src/object2/DFloat.cpp | 2 +- src/object2/DInteger.cpp | 2 +- src/object2/DList.cpp | 2 +- src/object2/DRuntimeError.cpp | 2 +- src/object2/IGCObject_DArray.cpp | 4 ++-- src/object2/IGCObject_DBoolean.cpp | 4 ++-- src/object2/IGCObject_DDictionary.cpp | 4 ++-- src/object2/IGCObject_DFloat.cpp | 4 ++-- src/object2/IGCObject_DInteger.cpp | 4 ++-- src/object2/IGCObject_DList.cpp | 4 ++-- src/object2/IGCObject_DRuntimeError.cpp | 4 ++-- 28 files changed, 42 insertions(+), 42 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 332d126a..99d1b3d7 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -148,7 +148,7 @@ namespace xo { /** shallow memory consumption. Excludes child objects **/ AAllocator::size_type shallow_size() const noexcept; /** return shallow copy of this array, using memory from @p mm **/ - DArray * shallow_copy(obj mm) const noexcept; + DArray * shallow_move(obj mm) const noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ AAllocator::size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index 72f5fad7..34ffda16 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -38,7 +38,7 @@ namespace xo { // GCObject facet std::size_t shallow_size() const noexcept; - DBoolean * shallow_copy(obj mm) const noexcept; + DBoolean * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 1c77d2cf..5e6ecaec 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -203,7 +203,7 @@ namespace xo { /** shallow memory consumption. Excludes child objects **/ AAllocator::size_type shallow_size() const noexcept; /** return shallow copy of this array, using memory from @p mm **/ - DDictionary * shallow_copy(obj mm) noexcept; + DDictionary * shallow_move(obj mm) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ AAllocator::size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index 4e4be861..b7d56e9c 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -35,7 +35,7 @@ namespace xo { // GCObject facet std::size_t shallow_size() const noexcept; - DFloat * shallow_copy(obj mm) const noexcept; + DFloat * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index a67e18d3..6a6194bf 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -40,7 +40,7 @@ namespace xo { // GCObject facet std::size_t shallow_size() const noexcept; - DInteger * shallow_copy(obj mm) const noexcept; + DInteger * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index f6ea9d8b..8fff47d5 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -70,7 +70,7 @@ namespace xo { /** @defgroup xo-scm-list-gcobject-facet gcobject facet **/ ///@{ size_type shallow_size() const noexcept; - DList * shallow_copy(obj mm) noexcept; + DList * shallow_move(obj mm) noexcept; size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DRuntimeError.hpp b/include/xo/object2/DRuntimeError.hpp index 8a0ae33b..957c8481 100644 --- a/include/xo/object2/DRuntimeError.hpp +++ b/include/xo/object2/DRuntimeError.hpp @@ -50,7 +50,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DRuntimeError * shallow_copy(obj mm) const noexcept; + DRuntimeError * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 4854eff4..ab8a85f1 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DArray & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DArray & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DArray & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DArray & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index c437f0bc..5bc6e0c0 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DBoolean & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DBoolean & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DBoolean & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DBoolean & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 323afd6e..16fef8cb 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DDictionary & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DDictionary & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DDictionary & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DDictionary & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index f09be05a..62cc6109 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DRuntimeError & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DRuntimeError & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DRuntimeError & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DRuntimeError & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index e601ce0b..780ebda5 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DList & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DList & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DList & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DList & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index f9040b1b..b25e4626 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -53,8 +53,8 @@ namespace xo { static size_type shallow_size(const DFloat & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DFloat & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DFloat & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DFloat & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index b6532128..a87f253a 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DInteger & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DInteger & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DInteger & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DInteger & self, obj gc) noexcept; ///@} diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index a55fbf97..2ae4ddc6 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -181,7 +181,7 @@ namespace xo { } DArray * - DArray::shallow_copy(obj mm) const noexcept + DArray::shallow_move(obj mm) const noexcept { DArray * copy = (DArray *)mm.alloc_copy((std::byte *)this); diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp index ff5fa38a..cb25f9e0 100644 --- a/src/object2/DBoolean.cpp +++ b/src/object2/DBoolean.cpp @@ -36,7 +36,7 @@ namespace xo { } DBoolean * - DBoolean::shallow_copy(obj mm) const noexcept + DBoolean::shallow_move(obj mm) const noexcept { DBoolean * copy = (DBoolean *)mm.alloc_copy((std::byte *)this); diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 263ea97d..739fcedc 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -274,7 +274,7 @@ namespace xo { } DDictionary * - DDictionary::shallow_copy(obj mm) noexcept + DDictionary::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index 7fc0bfbf..f7f8ff3e 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -34,7 +34,7 @@ namespace xo { } DFloat * - DFloat::shallow_copy(obj mm) const noexcept + DFloat::shallow_move(obj mm) const noexcept { DFloat * copy = (DFloat *)mm.alloc_copy((std::byte *)this); diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 284806d1..7cbcedf0 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -34,7 +34,7 @@ namespace xo { } DInteger * - DInteger::shallow_copy(obj mm) const noexcept + DInteger::shallow_move(obj mm) const noexcept { DInteger * copy = (DInteger *)mm.alloc_copy((std::byte *)this); diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 6f93147e..be869073 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -185,7 +185,7 @@ namespace xo { } DList * - DList::shallow_copy(obj mm) noexcept + DList::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/object2/DRuntimeError.cpp b/src/object2/DRuntimeError.cpp index b683716e..1f34596b 100644 --- a/src/object2/DRuntimeError.cpp +++ b/src/object2/DRuntimeError.cpp @@ -59,7 +59,7 @@ namespace xo { } DRuntimeError * - DRuntimeError::shallow_copy(obj mm) const noexcept + DRuntimeError::shallow_move(obj mm) const noexcept { DRuntimeError * copy = (DRuntimeError *)mm.alloc_copy((std::byte *)this); diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index 9b28a3de..7cde63e1 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DArray::shallow_copy(DArray & self, obj mm) noexcept -> Opaque + IGCObject_DArray::shallow_move(DArray & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DArray::forward_children(DArray & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp index e6bd6000..ef503af9 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DBoolean::shallow_copy(DBoolean & self, obj mm) noexcept -> Opaque + IGCObject_DBoolean::shallow_move(DBoolean & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DBoolean::forward_children(DBoolean & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DDictionary.cpp b/src/object2/IGCObject_DDictionary.cpp index 0466edd5..9d4bae65 100644 --- a/src/object2/IGCObject_DDictionary.cpp +++ b/src/object2/IGCObject_DDictionary.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DDictionary::shallow_copy(DDictionary & self, obj mm) noexcept -> Opaque + IGCObject_DDictionary::shallow_move(DDictionary & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DDictionary::forward_children(DDictionary & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index 4b1ab562..a22a1b2f 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DFloat::shallow_copy(DFloat & self, obj mm) noexcept -> Opaque + IGCObject_DFloat::shallow_move(DFloat & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DFloat::forward_children(DFloat & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index fbb31908..4f74e5fe 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DInteger::shallow_copy(DInteger & self, obj mm) noexcept -> Opaque + IGCObject_DInteger::shallow_move(DInteger & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DInteger::forward_children(DInteger & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 80cd7cd1..2512cc32 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DList::shallow_copy(DList & self, obj mm) noexcept -> Opaque + IGCObject_DList::shallow_move(DList & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DList::forward_children(DList & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DRuntimeError.cpp b/src/object2/IGCObject_DRuntimeError.cpp index 6d167819..cc755821 100644 --- a/src/object2/IGCObject_DRuntimeError.cpp +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DRuntimeError::shallow_copy(DRuntimeError & self, obj mm) noexcept -> Opaque + IGCObject_DRuntimeError::shallow_move(DRuntimeError & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj gc) noexcept -> size_type From 8ac5ba9bbb806cee3695486df1f259bd41ea6770 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:33:35 -0400 Subject: [PATCH 152/176] refactor: rename shallow_copy -> shallow_move + streamline Use RCollector.std_copy_for where appropriate --- include/xo/object2/DArray.hpp | 2 +- include/xo/object2/DBoolean.hpp | 2 +- include/xo/object2/DDictionary.hpp | 2 +- include/xo/object2/DFloat.hpp | 2 +- include/xo/object2/DInteger.hpp | 2 +- include/xo/object2/DList.hpp | 2 +- include/xo/object2/DRuntimeError.hpp | 2 +- include/xo/object2/array/IGCObject_DArray.hpp | 2 +- include/xo/object2/boolean/IGCObject_DBoolean.hpp | 2 +- include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 2 +- include/xo/object2/error/IGCObject_DRuntimeError.hpp | 2 +- include/xo/object2/list/IGCObject_DList.hpp | 2 +- include/xo/object2/number/IGCObject_DFloat.hpp | 2 +- include/xo/object2/number/IGCObject_DInteger.hpp | 2 +- src/object2/DArray.cpp | 7 +++++-- src/object2/DBoolean.cpp | 9 ++------- src/object2/DDictionary.cpp | 4 ++-- src/object2/DFloat.cpp | 9 ++------- src/object2/DInteger.cpp | 9 ++------- src/object2/DList.cpp | 4 ++-- src/object2/DRuntimeError.cpp | 9 ++------- src/object2/IGCObject_DArray.cpp | 4 ++-- src/object2/IGCObject_DBoolean.cpp | 4 ++-- src/object2/IGCObject_DDictionary.cpp | 4 ++-- src/object2/IGCObject_DFloat.cpp | 4 ++-- src/object2/IGCObject_DInteger.cpp | 4 ++-- src/object2/IGCObject_DList.cpp | 4 ++-- src/object2/IGCObject_DRuntimeError.cpp | 4 ++-- 28 files changed, 45 insertions(+), 62 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 99d1b3d7..a455046d 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -148,7 +148,7 @@ namespace xo { /** shallow memory consumption. Excludes child objects **/ AAllocator::size_type shallow_size() const noexcept; /** return shallow copy of this array, using memory from @p mm **/ - DArray * shallow_move(obj mm) const noexcept; + DArray * shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ AAllocator::size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index 34ffda16..31bf41b7 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -38,7 +38,7 @@ namespace xo { // GCObject facet std::size_t shallow_size() const noexcept; - DBoolean * shallow_move(obj mm) const noexcept; + DBoolean * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 5e6ecaec..219e7838 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -203,7 +203,7 @@ namespace xo { /** shallow memory consumption. Excludes child objects **/ AAllocator::size_type shallow_size() const noexcept; /** return shallow copy of this array, using memory from @p mm **/ - DDictionary * shallow_move(obj mm) noexcept; + DDictionary * shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ AAllocator::size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index b7d56e9c..949883ab 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -35,7 +35,7 @@ namespace xo { // GCObject facet std::size_t shallow_size() const noexcept; - DFloat * shallow_move(obj mm) const noexcept; + DFloat * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index 6a6194bf..d3969b75 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -40,7 +40,7 @@ namespace xo { // GCObject facet std::size_t shallow_size() const noexcept; - DInteger * shallow_move(obj mm) const noexcept; + DInteger * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 8fff47d5..199ec6e5 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -70,7 +70,7 @@ namespace xo { /** @defgroup xo-scm-list-gcobject-facet gcobject facet **/ ///@{ size_type shallow_size() const noexcept; - DList * shallow_move(obj mm) noexcept; + DList * shallow_move(obj gc) noexcept; size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DRuntimeError.hpp b/include/xo/object2/DRuntimeError.hpp index 957c8481..2ee93061 100644 --- a/include/xo/object2/DRuntimeError.hpp +++ b/include/xo/object2/DRuntimeError.hpp @@ -50,7 +50,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DRuntimeError * shallow_move(obj mm) const noexcept; + DRuntimeError * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index ab8a85f1..58c202d7 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DArray & self, obj mm) noexcept; + static Opaque shallow_move(DArray & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DArray & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 5bc6e0c0..3ca03921 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DBoolean & self, obj mm) noexcept; + static Opaque shallow_move(DBoolean & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DBoolean & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 16fef8cb..b6da10c0 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DDictionary & self, obj mm) noexcept; + static Opaque shallow_move(DDictionary & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DDictionary & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index 62cc6109..42e273ec 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DRuntimeError & self, obj mm) noexcept; + static Opaque shallow_move(DRuntimeError & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DRuntimeError & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index 780ebda5..7218556a 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DList & self, obj mm) noexcept; + static Opaque shallow_move(DList & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DList & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index b25e4626..88d4d563 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -54,7 +54,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DFloat & self, obj mm) noexcept; + static Opaque shallow_move(DFloat & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DFloat & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index a87f253a..822ec168 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DInteger & self, obj mm) noexcept; + static Opaque shallow_move(DInteger & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DInteger & self, obj gc) noexcept; ///@} diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 2ae4ddc6..a70213f1 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -181,9 +181,12 @@ namespace xo { } DArray * - DArray::shallow_move(obj mm) const noexcept + DArray::shallow_move(obj gc) noexcept { - DArray * copy = (DArray *)mm.alloc_copy((std::byte *)this); + // note: not using gc.std_copy_for() here. + // flexible array -> compiler doesn't know actual DArray allocation size + + DArray * copy = (DArray *)gc.alloc_copy((std::byte *)this); if (copy) { copy->capacity_ = capacity_; diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp index cb25f9e0..a8d5e85f 100644 --- a/src/object2/DBoolean.cpp +++ b/src/object2/DBoolean.cpp @@ -36,14 +36,9 @@ namespace xo { } DBoolean * - DBoolean::shallow_move(obj mm) const noexcept + DBoolean::shallow_move(obj gc) noexcept { - DBoolean * copy = (DBoolean *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } size_t diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 739fcedc..2f25f1b7 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -274,9 +274,9 @@ namespace xo { } DDictionary * - DDictionary::shallow_move(obj mm) noexcept + DDictionary::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index f7f8ff3e..4a9041c0 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -34,14 +34,9 @@ namespace xo { } DFloat * - DFloat::shallow_move(obj mm) const noexcept + DFloat::shallow_move(obj gc) noexcept { - DFloat * copy = (DFloat *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } size_t diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 7cbcedf0..600f48ec 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -34,14 +34,9 @@ namespace xo { } DInteger * - DInteger::shallow_move(obj mm) const noexcept + DInteger::shallow_move(obj gc) noexcept { - DInteger * copy = (DInteger *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } size_t diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index be869073..f17a53f4 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -185,9 +185,9 @@ namespace xo { } DList * - DList::shallow_move(obj mm) noexcept + DList::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } auto diff --git a/src/object2/DRuntimeError.cpp b/src/object2/DRuntimeError.cpp index 1f34596b..a52e1df9 100644 --- a/src/object2/DRuntimeError.cpp +++ b/src/object2/DRuntimeError.cpp @@ -59,14 +59,9 @@ namespace xo { } DRuntimeError * - DRuntimeError::shallow_move(obj mm) const noexcept + DRuntimeError::shallow_move(obj gc) noexcept { - DRuntimeError * copy = (DRuntimeError *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } std::size_t diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index 7cde63e1..e4fa31c7 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DArray::shallow_move(DArray & self, obj mm) noexcept -> Opaque + IGCObject_DArray::shallow_move(DArray & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DArray::forward_children(DArray & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp index ef503af9..2aed50e3 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DBoolean::shallow_move(DBoolean & self, obj mm) noexcept -> Opaque + IGCObject_DBoolean::shallow_move(DBoolean & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DBoolean::forward_children(DBoolean & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DDictionary.cpp b/src/object2/IGCObject_DDictionary.cpp index 9d4bae65..e8f291aa 100644 --- a/src/object2/IGCObject_DDictionary.cpp +++ b/src/object2/IGCObject_DDictionary.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DDictionary::shallow_move(DDictionary & self, obj mm) noexcept -> Opaque + IGCObject_DDictionary::shallow_move(DDictionary & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DDictionary::forward_children(DDictionary & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index a22a1b2f..7625cacb 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DFloat::shallow_move(DFloat & self, obj mm) noexcept -> Opaque + IGCObject_DFloat::shallow_move(DFloat & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DFloat::forward_children(DFloat & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 4f74e5fe..9bb9bbf3 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DInteger::shallow_move(DInteger & self, obj mm) noexcept -> Opaque + IGCObject_DInteger::shallow_move(DInteger & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DInteger::forward_children(DInteger & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 2512cc32..cbe8b71e 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DList::shallow_move(DList & self, obj mm) noexcept -> Opaque + IGCObject_DList::shallow_move(DList & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DList::forward_children(DList & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DRuntimeError.cpp b/src/object2/IGCObject_DRuntimeError.cpp index cc755821..6917af76 100644 --- a/src/object2/IGCObject_DRuntimeError.cpp +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DRuntimeError::shallow_move(DRuntimeError & self, obj mm) noexcept -> Opaque + IGCObject_DRuntimeError::shallow_move(DRuntimeError & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj gc) noexcept -> size_type From 0ec1008fa3782c9c365604cf20fcd4ef02e7e947 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:37:17 -0400 Subject: [PATCH 153/176] refactor: rename RCollector.std_copy_for -> std_move_for --- src/object2/DArray.cpp | 2 +- src/object2/DBoolean.cpp | 2 +- src/object2/DDictionary.cpp | 2 +- src/object2/DFloat.cpp | 2 +- src/object2/DInteger.cpp | 2 +- src/object2/DList.cpp | 2 +- src/object2/DRuntimeError.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index a70213f1..a9ed9288 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -183,7 +183,7 @@ namespace xo { DArray * DArray::shallow_move(obj gc) noexcept { - // note: not using gc.std_copy_for() here. + // note: not using gc.std_move_for() here. // flexible array -> compiler doesn't know actual DArray allocation size DArray * copy = (DArray *)gc.alloc_copy((std::byte *)this); diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp index a8d5e85f..f24429e3 100644 --- a/src/object2/DBoolean.cpp +++ b/src/object2/DBoolean.cpp @@ -38,7 +38,7 @@ namespace xo { DBoolean * DBoolean::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } size_t diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 2f25f1b7..48b0c97e 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -276,7 +276,7 @@ namespace xo { DDictionary * DDictionary::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index 4a9041c0..c00286cc 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -36,7 +36,7 @@ namespace xo { DFloat * DFloat::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } size_t diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 600f48ec..53625fd2 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -36,7 +36,7 @@ namespace xo { DInteger * DInteger::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } size_t diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index f17a53f4..d9e53174 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -187,7 +187,7 @@ namespace xo { DList * DList::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } auto diff --git a/src/object2/DRuntimeError.cpp b/src/object2/DRuntimeError.cpp index a52e1df9..469479c1 100644 --- a/src/object2/DRuntimeError.cpp +++ b/src/object2/DRuntimeError.cpp @@ -61,7 +61,7 @@ namespace xo { DRuntimeError * DRuntimeError::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t From d4e951fdedb3730c9e4f08d2d4d303d82a6cf938 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:54:46 -0400 Subject: [PATCH 154/176] refactor: void return type for Collector.forward_children() --- include/xo/object2/array/IGCObject_DArray.hpp | 2 +- include/xo/object2/boolean/IGCObject_DBoolean.hpp | 2 +- include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 2 +- include/xo/object2/error/IGCObject_DRuntimeError.hpp | 2 +- include/xo/object2/list/IGCObject_DList.hpp | 2 +- include/xo/object2/number/IGCObject_DFloat.hpp | 2 +- include/xo/object2/number/IGCObject_DInteger.hpp | 2 +- src/object2/IGCObject_DArray.cpp | 4 ++-- src/object2/IGCObject_DBoolean.cpp | 4 ++-- src/object2/IGCObject_DDictionary.cpp | 4 ++-- src/object2/IGCObject_DFloat.cpp | 4 ++-- src/object2/IGCObject_DInteger.cpp | 4 ++-- src/object2/IGCObject_DList.cpp | 4 ++-- src/object2/IGCObject_DRuntimeError.cpp | 4 ++-- 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 58c202d7..5540d32a 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DArray & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DArray & self, obj gc) noexcept; + static void forward_children(DArray & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 3ca03921..2711b1ee 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DBoolean & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DBoolean & self, obj gc) noexcept; + static void forward_children(DBoolean & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index b6da10c0..375c4a69 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DDictionary & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DDictionary & self, obj gc) noexcept; + static void forward_children(DDictionary & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index 42e273ec..2726b697 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DRuntimeError & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DRuntimeError & self, obj gc) noexcept; + static void forward_children(DRuntimeError & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index 7218556a..78836d00 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DList & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DList & self, obj gc) noexcept; + static void forward_children(DList & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index 88d4d563..8f78a0b9 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -56,7 +56,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DFloat & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DFloat & self, obj gc) noexcept; + static void forward_children(DFloat & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 822ec168..5e135edd 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DInteger & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DInteger & self, obj gc) noexcept; + static void forward_children(DInteger & self, obj gc) noexcept; ///@} }; diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index e4fa31c7..79273db5 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DArray::forward_children(DArray & self, obj gc) noexcept -> size_type + IGCObject_DArray::forward_children(DArray & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp index 2aed50e3..10e97b27 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DBoolean::forward_children(DBoolean & self, obj gc) noexcept -> size_type + IGCObject_DBoolean::forward_children(DBoolean & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DDictionary.cpp b/src/object2/IGCObject_DDictionary.cpp index e8f291aa..bcdef5b8 100644 --- a/src/object2/IGCObject_DDictionary.cpp +++ b/src/object2/IGCObject_DDictionary.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DDictionary::forward_children(DDictionary & self, obj gc) noexcept -> size_type + IGCObject_DDictionary::forward_children(DDictionary & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index 7625cacb..f2a1aa3d 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DFloat::forward_children(DFloat & self, obj gc) noexcept -> size_type + IGCObject_DFloat::forward_children(DFloat & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 9bb9bbf3..b0233bf5 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DInteger::forward_children(DInteger & self, obj gc) noexcept -> size_type + IGCObject_DInteger::forward_children(DInteger & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index cbe8b71e..813db3da 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DList::forward_children(DList & self, obj gc) noexcept -> size_type + IGCObject_DList::forward_children(DList & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DRuntimeError.cpp b/src/object2/IGCObject_DRuntimeError.cpp index 6917af76..b8e5dbd9 100644 --- a/src/object2/IGCObject_DRuntimeError.cpp +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj gc) noexcept -> size_type + IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ From 210f568f7b1b198ddb81fa5f28c0d49a715c58a3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 17:30:03 -0400 Subject: [PATCH 155/176] refactor: retire GCObject.shallow_size() Not needed. Rely on size stored in gc-owned object header --- include/xo/object2/array/IGCObject_DArray.hpp | 2 -- include/xo/object2/boolean/IGCObject_DBoolean.hpp | 2 -- include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 2 -- include/xo/object2/error/IGCObject_DRuntimeError.hpp | 2 -- include/xo/object2/list/IGCObject_DList.hpp | 2 -- include/xo/object2/number/IGCObject_DFloat.hpp | 2 -- include/xo/object2/number/IGCObject_DInteger.hpp | 2 -- src/object2/IGCObject_DArray.cpp | 6 ------ src/object2/IGCObject_DBoolean.cpp | 6 ------ src/object2/IGCObject_DDictionary.cpp | 6 ------ src/object2/IGCObject_DFloat.cpp | 6 ------ src/object2/IGCObject_DInteger.cpp | 6 ------ src/object2/IGCObject_DList.cpp | 6 ------ src/object2/IGCObject_DRuntimeError.cpp | 6 ------ 14 files changed, 56 deletions(-) diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 5540d32a..04669db9 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-darray-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DArray & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 2711b1ee..15ba4f75 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-dboolean-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DBoolean & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 375c4a69..173f7a44 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-ddictionary-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DDictionary & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index 2726b697..25e6e241 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-druntimeerror-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DRuntimeError & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index 78836d00..6132041f 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-dlist-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DList & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index 8f78a0b9..accf1ea7 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -49,8 +49,6 @@ namespace xo { /** @defgroup scm-gcobject-dfloat-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DFloat & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 5e135edd..8b418e12 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-dinteger-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DInteger & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index 79273db5..84c4768a 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DArray::shallow_size(const DArray & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DArray::shallow_move(DArray & self, obj gc) noexcept -> Opaque { diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp index 10e97b27..0c1f3a8c 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DBoolean::shallow_size(const DBoolean & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DBoolean::shallow_move(DBoolean & self, obj gc) noexcept -> Opaque { diff --git a/src/object2/IGCObject_DDictionary.cpp b/src/object2/IGCObject_DDictionary.cpp index bcdef5b8..e8c890a1 100644 --- a/src/object2/IGCObject_DDictionary.cpp +++ b/src/object2/IGCObject_DDictionary.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DDictionary::shallow_size(const DDictionary & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DDictionary::shallow_move(DDictionary & self, obj gc) noexcept -> Opaque { diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index f2a1aa3d..4908db82 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DFloat::shallow_size(const DFloat & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DFloat::shallow_move(DFloat & self, obj gc) noexcept -> Opaque { diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index b0233bf5..99944479 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DInteger::shallow_size(const DInteger & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DInteger::shallow_move(DInteger & self, obj gc) noexcept -> Opaque { diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 813db3da..138f707f 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DList::shallow_size(const DList & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DList::shallow_move(DList & self, obj gc) noexcept -> Opaque { diff --git a/src/object2/IGCObject_DRuntimeError.cpp b/src/object2/IGCObject_DRuntimeError.cpp index b8e5dbd9..fad46841 100644 --- a/src/object2/IGCObject_DRuntimeError.cpp +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DRuntimeError::shallow_size(const DRuntimeError & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DRuntimeError::shallow_move(DRuntimeError & self, obj gc) noexcept -> Opaque { From 5676a69dd38ba689345b89f9abe1f8a8e05f15cc Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 18:01:25 -0400 Subject: [PATCH 156/176] refactor: retire GCObject.shallow_copy() Collector gets this info from gc-owned object header --- include/xo/object2/DArray.hpp | 6 ++---- include/xo/object2/DBoolean.hpp | 3 +-- include/xo/object2/DDictionary.hpp | 6 ++---- include/xo/object2/DFloat.hpp | 3 +-- include/xo/object2/DInteger.hpp | 3 +-- include/xo/object2/DList.hpp | 3 +-- include/xo/object2/DStruct.hpp | 2 -- src/object2/DArray.cpp | 10 +--------- src/object2/DBoolean.cpp | 10 ++-------- src/object2/DDictionary.cpp | 10 +--------- src/object2/DFloat.cpp | 10 ++-------- src/object2/DInteger.cpp | 11 ++--------- src/object2/DList.cpp | 16 ++-------------- 13 files changed, 18 insertions(+), 75 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index a455046d..ac44c328 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -145,12 +145,10 @@ namespace xo { ///@} /** @defgroup darray-gcobject-methods **/ ///@{ - /** shallow memory consumption. Excludes child objects **/ - AAllocator::size_type shallow_size() const noexcept; - /** return shallow copy of this array, using memory from @p mm **/ + /** move to new address, mandated by @p gc **/ DArray * shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ - AAllocator::size_type forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; ///@} private: diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index 31bf41b7..f6374e3e 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -37,9 +37,8 @@ namespace xo { // GCObject facet - std::size_t shallow_size() const noexcept; DBoolean * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; private: /** boxed boolean value **/ diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 219e7838..8183a671 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -200,12 +200,10 @@ namespace xo { ///@} /** @defgroup ddictionary-gcobject-methods **/ ///@{ - /** shallow memory consumption. Excludes child objects **/ - AAllocator::size_type shallow_size() const noexcept; /** return shallow copy of this array, using memory from @p mm **/ DDictionary * shallow_move(obj gc) noexcept; - /** forward elements to @p gc to-space; replace originals with forarding pointers **/ - AAllocator::size_type forward_children(obj gc) noexcept; + /** forward elements to @p gc to-space; replace originals with forwarding pointers **/ + void forward_children(obj gc) noexcept; ///@} private: diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index 949883ab..50b0828c 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -34,9 +34,8 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const; // GCObject facet - std::size_t shallow_size() const noexcept; DFloat * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index d3969b75..4105d92d 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -39,9 +39,8 @@ namespace xo { // GCObject facet - std::size_t shallow_size() const noexcept; DInteger * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; private: /** boxed integer value **/ diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 199ec6e5..4c37045b 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -69,9 +69,8 @@ namespace xo { /** @defgroup xo-scm-list-gcobject-facet gcobject facet **/ ///@{ - size_type shallow_size() const noexcept; DList * shallow_move(obj gc) noexcept; - size_type forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; ///@} /** first member of list **/ diff --git a/include/xo/object2/DStruct.hpp b/include/xo/object2/DStruct.hpp index d7a7d84b..3776e376 100644 --- a/include/xo/object2/DStruct.hpp +++ b/include/xo/object2/DStruct.hpp @@ -141,8 +141,6 @@ namespace xo { ///@{ /** shallow memory consumption. Excludes child objects **/ AAllocator::size_type shallow_size() const noexcept; - /** return shallow copy of this array, using memory from @p mm **/ - DStruct * shallow_copy(obj mm) const noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ AAllocator::size_type forward_children(obj gc) noexcept; ///@} diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index a9ed9288..4be2ff64 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -174,12 +174,6 @@ namespace xo { // gc hooks for IGCObject_DArray - std::size_t - DArray::shallow_size() const noexcept - { - return sizeof(DArray) + (capacity_ * sizeof(obj)); - } - DArray * DArray::shallow_move(obj gc) noexcept { @@ -203,7 +197,7 @@ namespace xo { return copy; } - std::size_t + void DArray::forward_children(obj gc) noexcept { scope log(XO_DEBUG(false)); @@ -215,8 +209,6 @@ namespace xo { gc.forward_inplace(&elt); } - - return shallow_size(); } } /*namespace scm*/ diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp index f24429e3..2a196d55 100644 --- a/src/object2/DBoolean.cpp +++ b/src/object2/DBoolean.cpp @@ -29,22 +29,16 @@ namespace xo { (value_ ? "true" : "false")); } - size_t - DBoolean::shallow_size() const noexcept - { - return sizeof(DBoolean); - } - DBoolean * DBoolean::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - size_t + void DBoolean::forward_children(obj) noexcept { - return shallow_size(); + // no-op } diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 48b0c97e..bd9ad11f 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -267,26 +267,18 @@ namespace xo { // ----- gcobject facet ----- - std::size_t - DDictionary::shallow_size() const noexcept - { - return sizeof(DDictionary); - } - DDictionary * DDictionary::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t + void DDictionary::forward_children(obj gc) noexcept { gc.forward_inplace(&keys_); gc.forward_inplace(&values_); - - return this->shallow_size(); } } /*namespace scm*/ diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index c00286cc..32f3438b 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -27,22 +27,16 @@ namespace xo { return ppdetail_atomic::print_pretty(ppii, value_); } - size_t - DFloat::shallow_size() const noexcept - { - return sizeof(DFloat); - } - DFloat * DFloat::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - size_t + void DFloat::forward_children(obj) noexcept { - return shallow_size(); + // noop } } /*namespace scm*/ diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 53625fd2..2b0a4c0c 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -27,25 +27,18 @@ namespace xo { return ppdetail_atomic::print_pretty(ppii, value_); } - size_t - DInteger::shallow_size() const noexcept - { - return sizeof(DInteger); - } - DInteger * DInteger::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - size_t + void DInteger::forward_children(obj) noexcept { - return shallow_size(); + // no-op } - } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index d9e53174..fbba2e3c 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -178,31 +178,19 @@ namespace xo { // ----- GCObject facet ------ - auto - DList::shallow_size() const noexcept -> size_type - { - return sizeof(DList); - } - DList * DList::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - auto - DList::forward_children(obj gc) noexcept -> size_type + void + DList::forward_children(obj gc) noexcept { //scope log(XO_DEBUG(true)); gc.forward_inplace(&head_); - //gc.forward_inplace(head_.iface(), (void **)&(head_.data_)); - gc.forward_inplace(&rest_); - //auto iface = xo::facet::impl_for(); - //gc.forward_inplace(&iface, (void **)(&rest_)); - - return this->shallow_size(); } } /*namespace scm*/ } /*namespace xo*/ From 39ae54167f1364979d75ce105d66bf7276750658 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 5 Apr 2026 23:53:02 -0400 Subject: [PATCH 157/176] refactor: + narrower interface for gc pointer forwarding add AGCObjectVisitor, instead of requiring ACollector. --- include/xo/object2/DArray.hpp | 4 +++- include/xo/object2/DBoolean.hpp | 4 +++- include/xo/object2/DDictionary.hpp | 5 +++- include/xo/object2/DFloat.hpp | 4 +++- include/xo/object2/DInteger.hpp | 4 +++- include/xo/object2/DList.hpp | 3 ++- include/xo/object2/DRuntimeError.hpp | 4 ++-- include/xo/object2/array/IGCObject_DArray.hpp | 7 ++++-- .../xo/object2/boolean/IGCObject_DBoolean.hpp | 7 ++++-- .../dictionary/IGCObject_DDictionary.hpp | 7 ++++-- .../object2/error/IGCObject_DRuntimeError.hpp | 7 ++++-- include/xo/object2/list/IGCObject_DList.hpp | 7 ++++-- .../xo/object2/number/IGCObject_DFloat.hpp | 7 ++++-- .../xo/object2/number/IGCObject_DInteger.hpp | 7 ++++-- src/object2/DArray.cpp | 6 ++--- src/object2/DBoolean.cpp | 4 ++-- src/object2/DDictionary.cpp | 7 +++--- src/object2/DFloat.cpp | 4 ++-- src/object2/DInteger.cpp | 4 ++-- src/object2/DList.cpp | 6 ++--- src/object2/DRuntimeError.cpp | 24 ++++++++----------- src/object2/IGCObject_DArray.cpp | 4 ++-- src/object2/IGCObject_DBoolean.cpp | 4 ++-- src/object2/IGCObject_DDictionary.cpp | 4 ++-- src/object2/IGCObject_DFloat.cpp | 4 ++-- src/object2/IGCObject_DInteger.cpp | 4 ++-- src/object2/IGCObject_DList.cpp | 4 ++-- src/object2/IGCObject_DRuntimeError.cpp | 4 ++-- 28 files changed, 94 insertions(+), 66 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index ac44c328..71c7f444 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -36,6 +36,8 @@ namespace xo { using ACollector = xo::mm::ACollector; /** gc-aware object facet **/ using AGCObject = xo::mm::AGCObject; + /** gc-centric object visitor **/ + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; /** pretty-printer state for APrintable **/ using ppindentinfo = xo::print::ppindentinfo; @@ -148,7 +150,7 @@ namespace xo { /** move to new address, mandated by @p gc **/ DArray * shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ - void forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} private: diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index f6374e3e..1637bc74 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -16,6 +17,7 @@ namespace xo { struct DBoolean { using AAllocator = xo::mm::AAllocator; using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; using ppindentinfo = xo::print::ppindentinfo; using value_type = long; @@ -38,7 +40,7 @@ namespace xo { // GCObject facet DBoolean * shallow_move(obj gc) noexcept; - void forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; private: /** boxed boolean value **/ diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 8183a671..9ab75be0 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -8,6 +8,7 @@ #include "DArray.hpp" #include "DString.hpp" #include +#include #include #include #include @@ -35,6 +36,8 @@ namespace xo { using AAllocator = xo::mm::AAllocator; /** garbage collector facet **/ using ACollector = xo::mm::ACollector; + /** gc-centric object visitor **/ + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; /** gc-aware object facet **/ using AGCObject = xo::mm::AGCObject; /** pretty-printer state for APrintable **/ @@ -203,7 +206,7 @@ namespace xo { /** return shallow copy of this array, using memory from @p mm **/ DDictionary * shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forwarding pointers **/ - void forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} private: diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index 50b0828c..95322042 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -15,6 +16,7 @@ namespace xo { struct DFloat { using AAllocator = xo::mm::AAllocator; using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using ppindentinfo = xo::print::ppindentinfo; using value_type = double; @@ -35,7 +37,7 @@ namespace xo { // GCObject facet DFloat * shallow_move(obj gc) noexcept; - void forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index 4105d92d..4b0552ba 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -6,6 +6,7 @@ #pragma once #include +#include #include #include #include @@ -16,6 +17,7 @@ namespace xo { struct DInteger { using AAllocator = xo::mm::AAllocator; using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; using ppindentinfo = xo::print::ppindentinfo; using value_type = long; @@ -40,7 +42,7 @@ namespace xo { // GCObject facet DInteger * shallow_move(obj gc) noexcept; - void forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; private: /** boxed integer value **/ diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 4c37045b..e694acb9 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -20,6 +20,7 @@ namespace xo { using AGCObject = xo::mm::AGCObject; using AAllocator = xo::mm::AAllocator; using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using ppindentinfo = xo::print::ppindentinfo; public: @@ -70,7 +71,7 @@ namespace xo { /** @defgroup xo-scm-list-gcobject-facet gcobject facet **/ ///@{ DList * shallow_move(obj gc) noexcept; - void forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** first member of list **/ diff --git a/include/xo/object2/DRuntimeError.hpp b/include/xo/object2/DRuntimeError.hpp index 2ee93061..782185b3 100644 --- a/include/xo/object2/DRuntimeError.hpp +++ b/include/xo/object2/DRuntimeError.hpp @@ -18,6 +18,7 @@ namespace xo { public: using AGCObject = xo::mm::AGCObject; using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; @@ -49,9 +50,8 @@ namespace xo { /** @defgroup scm-runtimeerror-gcobject-facet gcobject facet **/ ///@{ - std::size_t shallow_size() const noexcept; DRuntimeError * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 04669db9..5b3db885 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -42,6 +42,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -52,8 +53,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DArray & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DArray & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DArray & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 15ba4f75..e13bb51a 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -42,6 +42,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -52,8 +53,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DBoolean & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DBoolean & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DBoolean & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 173f7a44..79197a8f 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -42,6 +42,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -52,8 +53,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DDictionary & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DDictionary & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DDictionary & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index 25e6e241..fe447123 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -42,6 +42,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -52,8 +53,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DRuntimeError & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DRuntimeError & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DRuntimeError & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index 6132041f..8ef9e1ca 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -42,6 +42,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -52,8 +53,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DList & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DList & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DList & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index accf1ea7..384a8de3 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -43,6 +43,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -53,8 +54,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DFloat & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DFloat & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DFloat & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 8b418e12..92ddf1ec 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -42,6 +42,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -52,8 +53,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DInteger & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DInteger & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DInteger & self, obj fn) noexcept; ///@} }; diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 4be2ff64..a3658101 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -198,16 +198,16 @@ namespace xo { } void - DArray::forward_children(obj gc) noexcept + DArray::visit_gco_children(obj gc) noexcept { scope log(XO_DEBUG(false)); for (size_type i = 0; i < size_; ++i) { - log && log("DArray::forward_children (loop)", xtag("i", i), xtag("z", size_)); + log && log("DArray::visit_gco_children (loop)", xtag("i", i), xtag("z", size_)); obj & elt = elts_[i]; - gc.forward_inplace(&elt); + gc.visit_child(&elt); } } diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp index 2a196d55..d2c2b7c8 100644 --- a/src/object2/DBoolean.cpp +++ b/src/object2/DBoolean.cpp @@ -36,9 +36,9 @@ namespace xo { } void - DBoolean::forward_children(obj) noexcept + DBoolean::visit_gco_children(obj) noexcept { - // no-op + // no-op. childless } diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index bd9ad11f..63e0e9e8 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -274,11 +274,10 @@ namespace xo { } void - DDictionary::forward_children(obj gc) noexcept + DDictionary::visit_gco_children(obj gc) noexcept { - - gc.forward_inplace(&keys_); - gc.forward_inplace(&values_); + gc.visit_child(&keys_); + gc.visit_child(&values_); } } /*namespace scm*/ diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index 32f3438b..3515dcfa 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -34,9 +34,9 @@ namespace xo { } void - DFloat::forward_children(obj) noexcept + DFloat::visit_gco_children(obj) noexcept { - // noop + // noop -- childless! } } /*namespace scm*/ diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 2b0a4c0c..b73391cc 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -34,9 +34,9 @@ namespace xo { } void - DInteger::forward_children(obj) noexcept + DInteger::visit_gco_children(obj) noexcept { - // no-op + // no-op. childless } } /*namespace scm*/ diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index fbba2e3c..56701180 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -185,12 +185,12 @@ namespace xo { } void - DList::forward_children(obj gc) noexcept + DList::visit_gco_children(obj gc) noexcept { //scope log(XO_DEBUG(true)); - gc.forward_inplace(&head_); - gc.forward_inplace(&rest_); + gc.visit_child(&head_); + gc.visit_child(&rest_); } } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/DRuntimeError.cpp b/src/object2/DRuntimeError.cpp index 469479c1..d46dcb20 100644 --- a/src/object2/DRuntimeError.cpp +++ b/src/object2/DRuntimeError.cpp @@ -52,32 +52,28 @@ namespace xo { // ----- GCObject facet ----- - std::size_t - DRuntimeError::shallow_size() const noexcept - { - return sizeof(DRuntimeError); - } - DRuntimeError * DRuntimeError::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DRuntimeError::forward_children(obj gc) noexcept + void + DRuntimeError::visit_gco_children(obj gc) noexcept { { - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&src_function_)); + gc.visit_child(&src_function_); + + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)(&src_function_)); } { - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&error_descr_)); - } + gc.visit_child(&error_descr_); - return this->shallow_size(); + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)(&error_descr_)); + } } // ----- Printable facet ----- diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index 84c4768a..38a31972 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DArray::forward_children(DArray & self, obj gc) noexcept -> void + IGCObject_DArray::visit_gco_children(DArray & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp index 0c1f3a8c..d76460df 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DBoolean::forward_children(DBoolean & self, obj gc) noexcept -> void + IGCObject_DBoolean::visit_gco_children(DBoolean & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DDictionary.cpp b/src/object2/IGCObject_DDictionary.cpp index e8c890a1..cd011b19 100644 --- a/src/object2/IGCObject_DDictionary.cpp +++ b/src/object2/IGCObject_DDictionary.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DDictionary::forward_children(DDictionary & self, obj gc) noexcept -> void + IGCObject_DDictionary::visit_gco_children(DDictionary & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index 4908db82..ab58f840 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DFloat::forward_children(DFloat & self, obj gc) noexcept -> void + IGCObject_DFloat::visit_gco_children(DFloat & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 99944479..13ea8379 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DInteger::forward_children(DInteger & self, obj gc) noexcept -> void + IGCObject_DInteger::visit_gco_children(DInteger & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 138f707f..680d1aa7 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DList::forward_children(DList & self, obj gc) noexcept -> void + IGCObject_DList::visit_gco_children(DList & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DRuntimeError.cpp b/src/object2/IGCObject_DRuntimeError.cpp index fad46841..7cce9717 100644 --- a/src/object2/IGCObject_DRuntimeError.cpp +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj gc) noexcept -> void + IGCObject_DRuntimeError::visit_gco_children(DRuntimeError & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ From ee521d33370ae8c12513b8cbfe10d86c32c89226 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 6 Apr 2026 00:11:08 -0400 Subject: [PATCH 158/176] refactor: make shallow_move() available from AGCObjectVisitor --- include/xo/object2/array/IGCObject_DArray.hpp | 2 +- include/xo/object2/boolean/IGCObject_DBoolean.hpp | 2 +- include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 2 +- include/xo/object2/error/IGCObject_DRuntimeError.hpp | 2 +- include/xo/object2/list/IGCObject_DList.hpp | 2 +- include/xo/object2/number/IGCObject_DFloat.hpp | 2 +- include/xo/object2/number/IGCObject_DInteger.hpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 5b3db885..bb326f01 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DArray & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index e13bb51a..9ad66430 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DBoolean & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 79197a8f..d389bf67 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DDictionary & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index fe447123..1b2a822e 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DRuntimeError & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index 8ef9e1ca..dcc86383 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DList & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index 384a8de3..3cb453e5 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -52,7 +52,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DFloat & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 92ddf1ec..9e7450f6 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DInteger & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place From 21ce28ee826f07bc6302cb18b3ab025e79546c69 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 6 Apr 2026 15:21:48 -0400 Subject: [PATCH 159/176] refactor: use GCObjectVisitor api w/ gco_shallow_move --- include/xo/object2/DArray.hpp | 6 +++--- include/xo/object2/DBoolean.hpp | 6 +++--- include/xo/object2/DDictionary.hpp | 2 +- include/xo/object2/DFloat.hpp | 6 +++--- include/xo/object2/DInteger.hpp | 6 +++--- include/xo/object2/DList.hpp | 3 ++- include/xo/object2/DRuntimeError.hpp | 4 ++-- include/xo/object2/array/IGCObject_DArray.hpp | 5 +++-- include/xo/object2/boolean/IGCObject_DBoolean.hpp | 5 +++-- include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 5 +++-- include/xo/object2/error/IGCObject_DRuntimeError.hpp | 5 +++-- include/xo/object2/list/IGCObject_DList.hpp | 5 +++-- include/xo/object2/number/IGCObject_DFloat.hpp | 5 +++-- include/xo/object2/number/IGCObject_DInteger.hpp | 5 +++-- src/object2/DArray.cpp | 2 +- src/object2/DBoolean.cpp | 2 +- src/object2/DDictionary.cpp | 2 +- src/object2/DFloat.cpp | 2 +- src/object2/DInteger.cpp | 2 +- src/object2/DList.cpp | 2 +- src/object2/DRuntimeError.cpp | 2 +- src/object2/IGCObject_DArray.cpp | 4 ++-- src/object2/IGCObject_DBoolean.cpp | 4 ++-- src/object2/IGCObject_DDictionary.cpp | 4 ++-- src/object2/IGCObject_DFloat.cpp | 4 ++-- src/object2/IGCObject_DInteger.cpp | 4 ++-- src/object2/IGCObject_DList.cpp | 4 ++-- src/object2/IGCObject_DRuntimeError.cpp | 4 ++-- 28 files changed, 59 insertions(+), 51 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 71c7f444..cd2bab29 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +//#include #include #include #include @@ -33,7 +33,7 @@ namespace xo { /** xo allocator facet **/ using AAllocator = xo::mm::AAllocator; /** garbage collector facet **/ - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; /** gc-aware object facet **/ using AGCObject = xo::mm::AGCObject; /** gc-centric object visitor **/ @@ -148,7 +148,7 @@ namespace xo { /** @defgroup darray-gcobject-methods **/ ///@{ /** move to new address, mandated by @p gc **/ - DArray * shallow_move(obj gc) noexcept; + DArray * gco_shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index 1637bc74..53ee4b88 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -5,7 +5,7 @@ #pragma once -#include +//#include #include #include #include @@ -16,7 +16,7 @@ namespace xo { namespace scm { struct DBoolean { using AAllocator = xo::mm::AAllocator; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; using ppindentinfo = xo::print::ppindentinfo; @@ -39,7 +39,7 @@ namespace xo { // GCObject facet - DBoolean * shallow_move(obj gc) noexcept; + DBoolean * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 9ab75be0..cda1d6f7 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -204,7 +204,7 @@ namespace xo { /** @defgroup ddictionary-gcobject-methods **/ ///@{ /** return shallow copy of this array, using memory from @p mm **/ - DDictionary * shallow_move(obj gc) noexcept; + DDictionary * gco_shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forwarding pointers **/ void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index 95322042..edd4f1ec 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +//#include #include #include #include @@ -15,7 +15,7 @@ namespace xo { namespace scm { struct DFloat { using AAllocator = xo::mm::AAllocator; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using ppindentinfo = xo::print::ppindentinfo; using value_type = double; @@ -36,7 +36,7 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const; // GCObject facet - DFloat * shallow_move(obj gc) noexcept; + DFloat * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index 4b0552ba..d82d9890 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -5,7 +5,7 @@ #pragma once -#include +//#include #include #include #include @@ -16,7 +16,7 @@ namespace xo { namespace scm { struct DInteger { using AAllocator = xo::mm::AAllocator; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; using ppindentinfo = xo::print::ppindentinfo; @@ -41,7 +41,7 @@ namespace xo { // GCObject facet - DInteger * shallow_move(obj gc) noexcept; + DInteger * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index e694acb9..da21ca44 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -5,6 +5,7 @@ #pragma once +#include #include #include #include @@ -70,7 +71,7 @@ namespace xo { /** @defgroup xo-scm-list-gcobject-facet gcobject facet **/ ///@{ - DList * shallow_move(obj gc) noexcept; + DList * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DRuntimeError.hpp b/include/xo/object2/DRuntimeError.hpp index 782185b3..43fe4a03 100644 --- a/include/xo/object2/DRuntimeError.hpp +++ b/include/xo/object2/DRuntimeError.hpp @@ -17,7 +17,7 @@ namespace xo { class DRuntimeError { public: using AGCObject = xo::mm::AGCObject; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; @@ -50,7 +50,7 @@ namespace xo { /** @defgroup scm-runtimeerror-gcobject-facet gcobject facet **/ ///@{ - DRuntimeError * shallow_move(obj gc) noexcept; + DRuntimeError * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index bb326f01..75399cf3 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DArray & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DArray & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 9ad66430..30fc70fe 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DBoolean & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DBoolean & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index d389bf67..5d45179b 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DDictionary & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DDictionary & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index 1b2a822e..a0039ad9 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DRuntimeError & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DRuntimeError & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index dcc86383..4002106e 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DList & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DList & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index 3cb453e5..eb50bb37 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -52,8 +52,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DFloat & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DFloat & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 9e7450f6..fece77f5 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DInteger & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DInteger & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index a3658101..f6c16b79 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -175,7 +175,7 @@ namespace xo { // gc hooks for IGCObject_DArray DArray * - DArray::shallow_move(obj gc) noexcept + DArray::gco_shallow_move(obj gc) noexcept { // note: not using gc.std_move_for() here. // flexible array -> compiler doesn't know actual DArray allocation size diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp index d2c2b7c8..5d2de407 100644 --- a/src/object2/DBoolean.cpp +++ b/src/object2/DBoolean.cpp @@ -30,7 +30,7 @@ namespace xo { } DBoolean * - DBoolean::shallow_move(obj gc) noexcept + DBoolean::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 63e0e9e8..f7806b6a 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -268,7 +268,7 @@ namespace xo { // ----- gcobject facet ----- DDictionary * - DDictionary::shallow_move(obj gc) noexcept + DDictionary::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index 3515dcfa..99d8b23a 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -28,7 +28,7 @@ namespace xo { } DFloat * - DFloat::shallow_move(obj gc) noexcept + DFloat::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index b73391cc..1c17d9cf 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -28,7 +28,7 @@ namespace xo { } DInteger * - DInteger::shallow_move(obj gc) noexcept + DInteger::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 56701180..fc2070ff 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -179,7 +179,7 @@ namespace xo { // ----- GCObject facet ------ DList * - DList::shallow_move(obj gc) noexcept + DList::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/object2/DRuntimeError.cpp b/src/object2/DRuntimeError.cpp index d46dcb20..7edb6227 100644 --- a/src/object2/DRuntimeError.cpp +++ b/src/object2/DRuntimeError.cpp @@ -53,7 +53,7 @@ namespace xo { // ----- GCObject facet ----- DRuntimeError * - DRuntimeError::shallow_move(obj gc) noexcept + DRuntimeError::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index 38a31972..6de8b94d 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DArray::shallow_move(DArray & self, obj gc) noexcept -> Opaque + IGCObject_DArray::gco_shallow_move(DArray & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DArray::visit_gco_children(DArray & self, obj fn) noexcept -> void diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp index d76460df..d791116d 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DBoolean::shallow_move(DBoolean & self, obj gc) noexcept -> Opaque + IGCObject_DBoolean::gco_shallow_move(DBoolean & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DBoolean::visit_gco_children(DBoolean & self, obj fn) noexcept -> void diff --git a/src/object2/IGCObject_DDictionary.cpp b/src/object2/IGCObject_DDictionary.cpp index cd011b19..41d462c9 100644 --- a/src/object2/IGCObject_DDictionary.cpp +++ b/src/object2/IGCObject_DDictionary.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DDictionary::shallow_move(DDictionary & self, obj gc) noexcept -> Opaque + IGCObject_DDictionary::gco_shallow_move(DDictionary & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DDictionary::visit_gco_children(DDictionary & self, obj fn) noexcept -> void diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index ab58f840..adcb9948 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DFloat::shallow_move(DFloat & self, obj gc) noexcept -> Opaque + IGCObject_DFloat::gco_shallow_move(DFloat & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DFloat::visit_gco_children(DFloat & self, obj fn) noexcept -> void diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 13ea8379..b4b57fc6 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DInteger::shallow_move(DInteger & self, obj gc) noexcept -> Opaque + IGCObject_DInteger::gco_shallow_move(DInteger & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DInteger::visit_gco_children(DInteger & self, obj fn) noexcept -> void diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 680d1aa7..79ad3750 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DList::shallow_move(DList & self, obj gc) noexcept -> Opaque + IGCObject_DList::gco_shallow_move(DList & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DList::visit_gco_children(DList & self, obj fn) noexcept -> void diff --git a/src/object2/IGCObject_DRuntimeError.cpp b/src/object2/IGCObject_DRuntimeError.cpp index 7cce9717..800d72ba 100644 --- a/src/object2/IGCObject_DRuntimeError.cpp +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DRuntimeError::shallow_move(DRuntimeError & self, obj gc) noexcept -> Opaque + IGCObject_DRuntimeError::gco_shallow_move(DRuntimeError & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DRuntimeError::visit_gco_children(DRuntimeError & self, obj fn) noexcept -> void From bc248fec2094a8ed6b7fb6247d79ba8f47628d6d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 9 Apr 2026 19:12:41 -0400 Subject: [PATCH 160/176] xo-gc: utest: fairly comprehensive GCObjectStore utest Generative! --- include/xo/object2/DList.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index da21ca44..c61b2978 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -50,6 +50,9 @@ namespace xo { obj car, DList * cdr); + obj head() const noexcept { return head_; } + DList * rest() const noexcept { return rest_; } + /** DList length is at least 1 **/ bool is_empty() const noexcept; /** DList models a finite sequence **/ From 4fdaa64085b22bbfea1d86a26b3c0ef86e2771ad Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 10 Apr 2026 01:10:03 -0400 Subject: [PATCH 161/176] xo-interpreter2 stack: + reason arg to visit_gco_children() Helps streamline DX1Collector in xo-gc/. Want both forward and verify entry points for the same representation. --- include/xo/object2/DArray.hpp | 4 +++- include/xo/object2/DBoolean.hpp | 3 ++- include/xo/object2/DDictionary.hpp | 4 +++- include/xo/object2/DFloat.hpp | 5 ++--- include/xo/object2/DInteger.hpp | 3 ++- include/xo/object2/DList.hpp | 3 ++- include/xo/object2/DRuntimeError.hpp | 3 ++- include/xo/object2/array/IGCObject_DArray.hpp | 3 ++- .../xo/object2/boolean/IGCObject_DBoolean.hpp | 3 ++- .../dictionary/IGCObject_DDictionary.hpp | 3 ++- .../object2/error/IGCObject_DRuntimeError.hpp | 3 ++- include/xo/object2/list/IGCObject_DList.hpp | 3 ++- include/xo/object2/number/IGCObject_DFloat.hpp | 3 ++- .../xo/object2/number/IGCObject_DInteger.hpp | 3 ++- src/object2/DArray.cpp | 8 ++------ src/object2/DBoolean.cpp | 2 +- src/object2/DDictionary.cpp | 6 +++--- src/object2/DFloat.cpp | 2 +- src/object2/DInteger.cpp | 2 +- src/object2/DList.cpp | 8 +++----- src/object2/DRuntimeError.cpp | 17 +++-------------- src/object2/IGCObject_DArray.cpp | 4 ++-- src/object2/IGCObject_DBoolean.cpp | 4 ++-- src/object2/IGCObject_DDictionary.cpp | 4 ++-- src/object2/IGCObject_DFloat.cpp | 4 ++-- src/object2/IGCObject_DInteger.cpp | 4 ++-- src/object2/IGCObject_DList.cpp | 4 ++-- src/object2/IGCObject_DRuntimeError.cpp | 4 ++-- 28 files changed, 58 insertions(+), 61 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index cd2bab29..27b0961d 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -38,6 +38,8 @@ namespace xo { using AGCObject = xo::mm::AGCObject; /** gc-centric object visitor **/ using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + /** hint for object visitor **/ + using VisitReason = xo::mm::VisitReason; /** pretty-printer state for APrintable **/ using ppindentinfo = xo::print::ppindentinfo; @@ -150,7 +152,7 @@ namespace xo { /** move to new address, mandated by @p gc **/ DArray * gco_shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} private: diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index 53ee4b88..904503c3 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -19,6 +19,7 @@ namespace xo { //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; + using VisitReason = xo::mm::VisitReason; using ppindentinfo = xo::print::ppindentinfo; using value_type = long; @@ -40,7 +41,7 @@ namespace xo { // GCObject facet DBoolean * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; private: /** boxed boolean value **/ diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index cda1d6f7..beda6600 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -40,6 +40,8 @@ namespace xo { using AGCObjectVisitor = xo::mm::AGCObjectVisitor; /** gc-aware object facet **/ using AGCObject = xo::mm::AGCObject; + /** color for gco visitor **/ + using VisitReason = xo::mm::VisitReason; /** pretty-printer state for APrintable **/ using ppindentinfo = xo::print::ppindentinfo; /** canonical type representing a key-value pair **/ @@ -206,7 +208,7 @@ namespace xo { /** return shallow copy of this array, using memory from @p mm **/ DDictionary * gco_shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forwarding pointers **/ - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} private: diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index edd4f1ec..54ffe41f 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -6,7 +6,6 @@ #pragma once #include -//#include #include #include #include @@ -15,8 +14,8 @@ namespace xo { namespace scm { struct DFloat { using AAllocator = xo::mm::AAllocator; - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using ppindentinfo = xo::print::ppindentinfo; using value_type = double; @@ -37,7 +36,7 @@ namespace xo { // GCObject facet DFloat * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; private: diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index d82d9890..ddcd9ba1 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -19,6 +19,7 @@ namespace xo { //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; + using VisitReason = xo::mm::VisitReason; using ppindentinfo = xo::print::ppindentinfo; using value_type = long; @@ -42,7 +43,7 @@ namespace xo { // GCObject facet DInteger * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; private: /** boxed integer value **/ diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index c61b2978..608f82b4 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -22,6 +22,7 @@ namespace xo { using AAllocator = xo::mm::AAllocator; using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using ppindentinfo = xo::print::ppindentinfo; public: @@ -75,7 +76,7 @@ namespace xo { /** @defgroup xo-scm-list-gcobject-facet gcobject facet **/ ///@{ DList * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** first member of list **/ diff --git a/include/xo/object2/DRuntimeError.hpp b/include/xo/object2/DRuntimeError.hpp index 43fe4a03..e65b2883 100644 --- a/include/xo/object2/DRuntimeError.hpp +++ b/include/xo/object2/DRuntimeError.hpp @@ -19,6 +19,7 @@ namespace xo { using AGCObject = xo::mm::AGCObject; //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; @@ -51,7 +52,7 @@ namespace xo { ///@{ DRuntimeError * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 75399cf3..4cd5f026 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -43,6 +43,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DArray & self, obj fn) noexcept; + static void visit_gco_children(DArray & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 30fc70fe..8ab00b09 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -43,6 +43,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DBoolean & self, obj fn) noexcept; + static void visit_gco_children(DBoolean & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 5d45179b..52d093bb 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -43,6 +43,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DDictionary & self, obj fn) noexcept; + static void visit_gco_children(DDictionary & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index a0039ad9..19e378b4 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -43,6 +43,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DRuntimeError & self, obj fn) noexcept; + static void visit_gco_children(DRuntimeError & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index 4002106e..10463fef 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -43,6 +43,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DList & self, obj fn) noexcept; + static void visit_gco_children(DList & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index eb50bb37..0d9042f6 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -44,6 +44,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -58,7 +59,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DFloat & self, obj fn) noexcept; + static void visit_gco_children(DFloat & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index fece77f5..5d6d944f 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -43,6 +43,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DInteger & self, obj fn) noexcept; + static void visit_gco_children(DInteger & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index f6c16b79..c6e83ee6 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -198,16 +198,12 @@ namespace xo { } void - DArray::visit_gco_children(obj gc) noexcept + DArray::visit_gco_children(VisitReason reason, obj gc) noexcept { - scope log(XO_DEBUG(false)); - for (size_type i = 0; i < size_; ++i) { - log && log("DArray::visit_gco_children (loop)", xtag("i", i), xtag("z", size_)); - obj & elt = elts_[i]; - gc.visit_child(&elt); + gc.visit_child(reason, &elt); } } diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp index 5d2de407..2e0bafa8 100644 --- a/src/object2/DBoolean.cpp +++ b/src/object2/DBoolean.cpp @@ -36,7 +36,7 @@ namespace xo { } void - DBoolean::visit_gco_children(obj) noexcept + DBoolean::visit_gco_children(VisitReason, obj) noexcept { // no-op. childless } diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index f7806b6a..7d838dd8 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -274,10 +274,10 @@ namespace xo { } void - DDictionary::visit_gco_children(obj gc) noexcept + DDictionary::visit_gco_children(VisitReason reason, obj gc) noexcept { - gc.visit_child(&keys_); - gc.visit_child(&values_); + gc.visit_child(reason, &keys_); + gc.visit_child(reason, &values_); } } /*namespace scm*/ diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index 99d8b23a..6141b283 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -34,7 +34,7 @@ namespace xo { } void - DFloat::visit_gco_children(obj) noexcept + DFloat::visit_gco_children(VisitReason, obj) noexcept { // noop -- childless! } diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 1c17d9cf..03e6a5d0 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -34,7 +34,7 @@ namespace xo { } void - DInteger::visit_gco_children(obj) noexcept + DInteger::visit_gco_children(VisitReason, obj) noexcept { // no-op. childless } diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index fc2070ff..612ed98b 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -185,12 +185,10 @@ namespace xo { } void - DList::visit_gco_children(obj gc) noexcept + DList::visit_gco_children(VisitReason reason, obj gc) noexcept { - //scope log(XO_DEBUG(true)); - - gc.visit_child(&head_); - gc.visit_child(&rest_); + gc.visit_child(reason, &head_); + gc.visit_child(reason, &rest_); } } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/DRuntimeError.cpp b/src/object2/DRuntimeError.cpp index 7edb6227..2d9518e6 100644 --- a/src/object2/DRuntimeError.cpp +++ b/src/object2/DRuntimeError.cpp @@ -59,21 +59,10 @@ namespace xo { } void - DRuntimeError::visit_gco_children(obj gc) noexcept + DRuntimeError::visit_gco_children(VisitReason reason, obj gc) noexcept { - { - gc.visit_child(&src_function_); - - //auto iface = xo::facet::impl_for(); - //gc.forward_inplace(&iface, (void **)(&src_function_)); - } - - { - gc.visit_child(&error_descr_); - - //auto iface = xo::facet::impl_for(); - //gc.forward_inplace(&iface, (void **)(&error_descr_)); - } + gc.visit_child(reason, &src_function_); + gc.visit_child(reason, &error_descr_); } // ----- Printable facet ----- diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index 6de8b94d..e771e335 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DArray::visit_gco_children(DArray & self, obj fn) noexcept -> void + IGCObject_DArray::visit_gco_children(DArray & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp index d791116d..62b82ca7 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DBoolean::visit_gco_children(DBoolean & self, obj fn) noexcept -> void + IGCObject_DBoolean::visit_gco_children(DBoolean & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DDictionary.cpp b/src/object2/IGCObject_DDictionary.cpp index 41d462c9..ae6da864 100644 --- a/src/object2/IGCObject_DDictionary.cpp +++ b/src/object2/IGCObject_DDictionary.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DDictionary::visit_gco_children(DDictionary & self, obj fn) noexcept -> void + IGCObject_DDictionary::visit_gco_children(DDictionary & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index adcb9948..d6399b0b 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DFloat::visit_gco_children(DFloat & self, obj fn) noexcept -> void + IGCObject_DFloat::visit_gco_children(DFloat & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index b4b57fc6..1acd0455 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DInteger::visit_gco_children(DInteger & self, obj fn) noexcept -> void + IGCObject_DInteger::visit_gco_children(DInteger & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 79ad3750..205c3e58 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DList::visit_gco_children(DList & self, obj fn) noexcept -> void + IGCObject_DList::visit_gco_children(DList & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/object2/IGCObject_DRuntimeError.cpp b/src/object2/IGCObject_DRuntimeError.cpp index 800d72ba..3efa863d 100644 --- a/src/object2/IGCObject_DRuntimeError.cpp +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DRuntimeError::visit_gco_children(DRuntimeError & self, obj fn) noexcept -> void + IGCObject_DRuntimeError::visit_gco_children(DRuntimeError & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ From 1ae18830a7cc466085a3f73413e30a157b56764c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 10 Apr 2026 20:30:46 -0400 Subject: [PATCH 162/176] xo-object2: DInteger: fail without ub on oom. --- src/object2/DInteger.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 03e6a5d0..2ff2d5b1 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -18,7 +18,10 @@ namespace xo { void * mem = mm.alloc(typeseq::id(), sizeof(DInteger)); - return new (mem) DInteger(x); + if (mem) + return new (mem) DInteger(x); + + return nullptr; } bool From aea622a1c2e6af7f3a7837059451222c099fcf79 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 10 Apr 2026 20:31:05 -0400 Subject: [PATCH 163/176] xo-object2: DDictionary: fail without ub on oom. --- src/object2/DDictionary.cpp | 54 +++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 7d838dd8..57e71ed4 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -26,13 +26,18 @@ namespace xo { { void * mem = mm.alloc_for(); - if (cap <= 0) - cap = 1; + if (mem) { + if (cap <= 0) + cap = 1; - DArray * keys = DArray::empty(mm, cap); - DArray * values = DArray::empty(mm, cap); + DArray * keys = DArray::empty(mm, cap); + DArray * values = DArray::empty(mm, cap); - return new (mem) DDictionary(keys, values); + if (keys && values) + return new (mem) DDictionary(keys, values); + } + + return nullptr; } std::optional> @@ -142,7 +147,10 @@ namespace xo { { const DString * k1 = DString::from_cstr(mm, key_cstr); - return this->try_upsert(std::make_pair(k1, value)); + if (k1) + return this->try_upsert(std::make_pair(k1, value)); + + return false; } bool @@ -150,7 +158,10 @@ namespace xo { { const DString * k1 = DString::from_cstr(mm, key_cstr); - return this->upsert(mm, std::make_pair(k1, value)); + if (k1) + return this->upsert(mm, std::make_pair(k1, value)); + + return false; } bool @@ -162,10 +173,7 @@ namespace xo { if (keys_->size() == keys_->capacity()) return false; - keys_->push_back(obj(const_cast(kv_pair.first))); - values_->push_back(kv_pair.second); - - return true; + return this->_append_kv_aux(kv_pair); } bool @@ -174,6 +182,8 @@ namespace xo { if (this->try_update(kv_pair)) return true; + // key not present -> must expand {key array, value array} + if (keys_->size() == keys_->capacity()) { assert(keys_->capacity() > 0); @@ -190,10 +200,26 @@ namespace xo { } } - keys_->push_back(obj(const_cast(kv_pair.first))); - values_->push_back(kv_pair.second); + return this->_append_kv_aux(kv_pair); + } - return true; + bool + DDictionary::_append_kv_aux(const pair_type & kv_pair) + { + bool ok + = keys_->push_back(obj(const_cast(kv_pair.first))); + + if (ok) { + ok = values_->push_back(kv_pair.second); + + if (!ok) { + // since we couldn't insert value, also drop key + + keys_->pop_back(); + } + } + + return ok; } void From 7f3c7671b4cad93e31e7bf69e61dd9fb07839198 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 10 Apr 2026 20:31:26 -0400 Subject: [PATCH 164/176] xo-object2: DArray: + DArray.pop_back + no ub on oom --- include/xo/object2/DArray.hpp | 8 ++++++- src/object2/DArray.cpp | 42 +++++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 27b0961d..1d3499aa 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -111,10 +111,16 @@ namespace xo { bool assign_at(size_type index, obj elt) noexcept; /** append @p elt at the end of array. - * true on success, false otherwise + * true on success, false otherwise. + * on failure array is unaltered **/ bool push_back(obj elt) noexcept; + /** store last element in array into @p elt and decrement array size. + * true on success; false on failure (implies array was empty) + **/ + bool pop_back(obj * p_elt = nullptr) noexcept; + ///@} /** @defgroup darray-general general methods **/ ///@{ diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index c6e83ee6..a181f9c3 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -18,6 +18,7 @@ namespace xo { using xo::facet::typeseq; namespace scm { + // TODO: error reporting? DArray * DArray::empty(obj mm, size_type cap) @@ -27,12 +28,14 @@ namespace xo { void * mem = mm.alloc(typeseq::id(), sizeof(DArray) + cap * sizeof(obj)); - result = new (mem) DArray(); + if (mem) [[likely]] { + result = new (mem) DArray(); - assert(result); + assert(result); - result->capacity_ = cap; - result->size_ = 0; + result->capacity_ = cap; + result->size_ = 0; + } return result; } @@ -44,12 +47,14 @@ namespace xo { { DArray * dest = empty(mm, new_cap); - /** could just memcpy here **/ - for (size_type i = 0, n = src->size(); i < n; ++i) { - dest->elts_[i] = src->elts_[i]; - } + if (dest) [[likely]] { + /** could just memcpy here **/ + for (size_type i = 0, n = src->size(); i < n; ++i) { + dest->elts_[i] = src->elts_[i]; + } - dest->size_ = src->size(); + dest->size_ = src->size(); + } return dest; } @@ -98,6 +103,25 @@ namespace xo { } } + bool + DArray::pop_back(obj * p_elt) noexcept + { + if (size_ > 0) { + --size_; + + obj & last = elts_[size_]; + + if (p_elt) + *p_elt = last; + + last.reset(); // hygiene + + return true; + } + + return false; + } + bool DArray::resize(size_type new_z) noexcept { From d414d055b86484b530eaa009d76a58cf78bcab86 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 10 Apr 2026 20:31:54 -0400 Subject: [PATCH 165/176] xo-object2: missed DDictionary.hpp update --- include/xo/object2/DDictionary.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index beda6600..8227721c 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -211,6 +211,15 @@ namespace xo { void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} + private: + /** @defgroup ddictionary-impl-methods implementation methods **/ + ///@{ + /** append {key, value} pair @p kv_pair to this dictionary + * Require: @p kv_pair.first not already present in @ref keys_ + **/ + bool _append_kv_aux(const pair_type & kv_pair); + ///@} + private: /** @defgroup ddictionary-instance-variables instance variables **/ ///@{ From 912ae405506fa3b064b7403a17fdd6de77303fcf Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 11 Apr 2026 16:51:52 -0400 Subject: [PATCH 166/176] xo-gc: bugfixes for GCObjectStore, unit test exapnded In particular: drop casual assignment to DList.rest_, will break acyclic assumption of DList.size() --- include/xo/object2/DList.hpp | 4 ++-- src/object2/DList.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 608f82b4..a862f186 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -65,8 +65,8 @@ namespace xo { /** assign head **/ void assign_head(obj gc, obj h); - /** assign rest-pointer **/ - void assign_rest(DList * r); + /** assign rest-pointer. Caller responsible for preserving acyclic property! **/ + void _assign_rest(DList * r); /** pretty-printing driver; combine layout+printing **/ bool pretty(const ppindentinfo & ppii) const; diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 612ed98b..7208bb9f 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -128,7 +128,7 @@ namespace xo { } void - DList::assign_rest(DList * r) + DList::_assign_rest(DList * r) { scope log(XO_DEBUG(true), "need write barrier"); From d24f851eb5dbcf965e979133bd9d9cd9974e9921 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 28 Apr 2026 23:17:00 -0400 Subject: [PATCH 167/176] xo-object2: obj argument to DArray::push_back() --- include/xo/object2/DArray.hpp | 67 +++++++++++++++++++++++++----- include/xo/object2/DDictionary.hpp | 8 ++-- src/object2/DArray.cpp | 17 ++++---- src/object2/DDictionary.cpp | 38 ++++++++++------- utest/DArray.test.cpp | 36 +++++++++------- 5 files changed, 114 insertions(+), 52 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 1d3499aa..de65d1d2 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -15,6 +15,24 @@ namespace xo { namespace scm { + class DArray; + + namespace detail { + /** null base case **/ + static inline bool do_array_push_back(DArray *, + obj) + { + return true; + } + + template + requires (std::convertible_to>) + static bool do_array_push_back(DArray * lhs, + obj gc, + A arg1, + Rest... rest); + } + /** @class DArray * @brief Polymorphic array implementation with gc hooks * @@ -30,11 +48,8 @@ namespace xo { /** type for array size **/ using size_type = std::uint32_t; - /** xo allocator facet **/ using AAllocator = xo::mm::AAllocator; - /** garbage collector facet **/ - //using ACollector = xo::mm::ACollector; - /** gc-aware object facet **/ + using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; /** gc-centric object visitor **/ using AGCObjectVisitor = xo::mm::AGCObjectVisitor; @@ -59,8 +74,8 @@ namespace xo { * using memory from allocator @p mm. * Nullptr if space exhausted **/ - static DArray * empty(obj mm, - size_type cap); + static DArray * _empty(obj mm, + size_type cap); /** create copy of @p src using memory from @p mm * with capacity for @p new_cap elements @@ -80,8 +95,13 @@ namespace xo { static DArray * array(obj mm, Args... args); ///@} - /** @defgroup darray-access acecss methods **/ + /** @defgroup darray-access access methods **/ ///@{ + + /** create fop for this instance **/ + template + obj ref() { return obj(this); } + /** true iff array is empty **/ bool is_empty() const noexcept { return size_ == 0; } /** only support finite arrays :-) **/ @@ -108,13 +128,17 @@ namespace xo { /** store @p elt at position @p index. * true on success, false otherwise **/ - bool assign_at(size_type index, obj elt) noexcept; + bool assign_at(obj gc, size_type index, obj elt) noexcept; /** append @p elt at the end of array. * true on success, false otherwise. * on failure array is unaltered **/ - bool push_back(obj elt) noexcept; + bool push_back(obj gc, obj elt) noexcept; + + template + requires (std::convertible_to> && ...) + bool push_back_all(obj gc, Args... args) noexcept; /** store last element in array into @p elt and decrement array size. * true on success; false on failure (implies array was empty) @@ -182,13 +206,34 @@ namespace xo { DArray * DArray::array(obj mm, Args... args) { - DArray * result = empty(mm, sizeof...(args)); + obj gc = mm.try_to_facet(); + DArray * result = _empty(mm, sizeof...(args)); if (result) { - (result->push_back(args), ...); + detail::do_array_push_back(result, gc, args...); } return result; } + namespace detail { + template + requires (std::convertible_to>) + static bool do_array_push_back(DArray * lhs, + obj gc, + A arg1, + Rest... rest) + { + return (lhs->push_back(gc, arg1) + && do_array_push_back(lhs, gc, rest...)); + } + } + + template + requires (std::convertible_to> && ...) + bool + DArray::push_back_all(obj gc, Args... args) noexcept { + return detail::do_array_push_back(this, gc, args...); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 8227721c..972c71b2 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -144,12 +144,12 @@ namespace xo { * * @return true if key-value pair updated; false if key not found **/ - bool try_update(const pair_type & kvpair); + bool try_update(obj gc, const pair_type & kvpair); /** update key-value pair for existing @p key to map to @p value. * false if @p key not already present. **/ - bool try_update_cstr(const char * key, obj value); + bool try_update_cstr(obj gc, const char * key, obj value); /** convenience method: * try_upsert pair (k, @p value), after boxing c-style string @p key with @p mm to get k @@ -167,7 +167,7 @@ namespace xo { * * False if dictionary already at capacity **/ - bool try_upsert(const pair_type & kvpair); + bool try_upsert(obj gc, const pair_type & kvpair); /** upsert key-value pair @p kvpair into dictionary. * If at capacity, expand capacity, getting new memory from @p mm. @@ -217,7 +217,7 @@ namespace xo { /** append {key, value} pair @p kv_pair to this dictionary * Require: @p kv_pair.first not already present in @ref keys_ **/ - bool _append_kv_aux(const pair_type & kv_pair); + bool _append_kv_aux(obj gc, const pair_type & kv_pair); ///@} private: diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index a181f9c3..1910e8e9 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -4,6 +4,7 @@ **/ #include "DArray.hpp" +#include "gc/RCollector_aux.hpp" #include #include #include @@ -15,13 +16,14 @@ namespace xo { using xo::print::APrintable; using xo::facet::FacetRegistry; using xo::mm::AGCObject; + using xo::mm::mm_do_assign; using xo::facet::typeseq; namespace scm { // TODO: error reporting? DArray * - DArray::empty(obj mm, - size_type cap) + DArray::_empty(obj mm, + size_type cap) { DArray * result = nullptr; @@ -45,7 +47,7 @@ namespace xo { DArray * src, size_type new_cap) { - DArray * dest = empty(mm, new_cap); + DArray * dest = _empty(mm, new_cap); if (dest) [[likely]] { /** could just memcpy here **/ @@ -73,20 +75,20 @@ namespace xo { } bool - DArray::assign_at(size_type ix, obj x) noexcept + DArray::assign_at(obj gc, size_type ix, obj x) noexcept { if (ix >= size_) return false; scope log(XO_DEBUG(true), "need write barrier"); - this->elts_[ix] = x; + mm_do_assign(gc, this, &elts_[ix], x); return true; } bool - DArray::push_back(obj elt) noexcept + DArray::push_back(obj gc, obj elt) noexcept { if (size_ >= capacity_) { return false; @@ -94,8 +96,9 @@ namespace xo { static_assert(!std::is_trivially_constructible_v>); void * mem = &(elts_[size_]); + new (mem) obj(); - new (mem) obj(elt); + mm_do_assign(gc, this, &(elts_[size_]), elt); ++(this->size_); diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 57e71ed4..43a4e1cd 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -30,8 +30,8 @@ namespace xo { if (cap <= 0) cap = 1; - DArray * keys = DArray::empty(mm, cap); - DArray * values = DArray::empty(mm, cap); + DArray * keys = DArray::_empty(mm, cap); + DArray * values = DArray::_empty(mm, cap); if (keys && values) return new (mem) DDictionary(keys, values); @@ -108,7 +108,7 @@ namespace xo { } bool - DDictionary::try_update(const pair_type & kv_pair) + DDictionary::try_update(obj gc, const pair_type & kv_pair) { for (size_type i = 0, n = keys_->size(); i < n; ++i) { auto key_i = obj::from((*keys_)[i]); @@ -116,7 +116,7 @@ namespace xo { assert(key_i); if (*(key_i.data()) == *(kv_pair.first)) { - values_->assign_at(i, kv_pair.second); + values_->assign_at(gc, i, kv_pair.second); return true; } } @@ -125,7 +125,7 @@ namespace xo { } bool - DDictionary::try_update_cstr(const char * key, obj value) + DDictionary::try_update_cstr(obj gc, const char * key, obj value) { for (size_type i = 0, n = keys_->size(); i < n; ++i) { auto key_i = obj::from((*keys_)[i]); @@ -133,7 +133,7 @@ namespace xo { assert(key_i); if (strcmp(key, key_i->data()) == 0) { - values_->assign_at(i, value); + values_->assign_at(gc, i, value); return true; } @@ -147,8 +147,10 @@ namespace xo { { const DString * k1 = DString::from_cstr(mm, key_cstr); - if (k1) - return this->try_upsert(std::make_pair(k1, value)); + if (k1) { + obj gc = mm.try_to_facet(); + return this->try_upsert(gc, std::make_pair(k1, value)); + } return false; } @@ -165,21 +167,23 @@ namespace xo { } bool - DDictionary::try_upsert(const pair_type & kv_pair) + DDictionary::try_upsert(obj gc, const pair_type & kv_pair) { - if (this->try_update(kv_pair)) + if (this->try_update(gc, kv_pair)) return true; if (keys_->size() == keys_->capacity()) return false; - return this->_append_kv_aux(kv_pair); + return this->_append_kv_aux(gc, kv_pair); } bool DDictionary::upsert(obj mm, const pair_type & kv_pair) { - if (this->try_update(kv_pair)) + obj gc = mm.try_to_facet(); + + if (this->try_update(gc, kv_pair)) return true; // key not present -> must expand {key array, value array} @@ -200,17 +204,19 @@ namespace xo { } } - return this->_append_kv_aux(kv_pair); + return this->_append_kv_aux(gc, kv_pair); } bool - DDictionary::_append_kv_aux(const pair_type & kv_pair) + DDictionary::_append_kv_aux(obj gc, const pair_type & kv_pair) { + DString * key = const_cast(kv_pair.first); + bool ok - = keys_->push_back(obj(const_cast(kv_pair.first))); + = keys_->push_back(gc, obj(key)); if (ok) { - ok = values_->push_back(kv_pair.second); + ok = values_->push_back(gc, kv_pair.second); if (!ok) { // since we couldn't insert value, also drop key diff --git a/utest/DArray.test.cpp b/utest/DArray.test.cpp index 84afbe11..af26c719 100644 --- a/utest/DArray.test.cpp +++ b/utest/DArray.test.cpp @@ -14,6 +14,7 @@ namespace xo { using xo::scm::ListOps; using xo::scm::DArray; using xo::scm::DInteger; + using xo::mm::ACollector; using xo::mm::AAllocator; using xo::mm::AGCObject; using xo::mm::DArena; @@ -31,7 +32,10 @@ namespace xo { REQUIRE(arr.is_empty());; - REQUIRE(arr.push_back(ListOps::nil()) == false); + // null_gc: for no memory barrier + obj null_gc; + + REQUIRE(arr.push_back(null_gc, ListOps::nil()) == false); } TEST_CASE("DArray-empty", "[object2][DArray]") @@ -41,7 +45,7 @@ namespace xo { DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); - DArray * arr = DArray::empty(alloc, 16); + DArray * arr = DArray::_empty(alloc, 16); REQUIRE(arr != nullptr); REQUIRE(arr->capacity() == 16); @@ -57,15 +61,16 @@ namespace xo { .size_ = 4*1024 }; DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); + obj null_gc; - DArray * arr = DArray::empty(alloc, 16); + DArray * arr = DArray::_empty(alloc, 16); REQUIRE(arr != nullptr); REQUIRE(arr->capacity() == 16); REQUIRE(arr->size() == 0); obj elt = DInteger::box(alloc, 42); - bool ok = arr->push_back(elt); + bool ok = arr->push_back(null_gc, elt); REQUIRE(ok == true); REQUIRE(arr->is_empty() == false); @@ -79,8 +84,9 @@ namespace xo { .size_ = 4*1024 }; DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); + obj null_gc; - DArray * arr = DArray::empty(alloc, 4); + DArray * arr = DArray::_empty(alloc, 4); REQUIRE(arr != nullptr); REQUIRE(arr->capacity() == 4); REQUIRE(arr->size() == 0); @@ -90,7 +96,7 @@ namespace xo { REQUIRE(arr->size() == i); obj elt = DInteger::box(alloc, 100 + i); - bool ok = arr->push_back(elt); + bool ok = arr->push_back(null_gc, elt); REQUIRE(ok == true); REQUIRE(arr->capacity() == 4); @@ -106,7 +112,8 @@ namespace xo { DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); - DArray * arr = DArray::empty(alloc, 2); + DArray * arr = DArray::_empty(alloc, 2); + obj null_gc; REQUIRE(arr != nullptr); REQUIRE(arr->capacity() == 2); @@ -116,11 +123,11 @@ namespace xo { obj e2 = DInteger::box(alloc, 2); obj e3 = DInteger::box(alloc, 3); - REQUIRE(arr->push_back(e1) == true); + REQUIRE(arr->push_back(null_gc, e1) == true); REQUIRE(arr->size() == 1); - REQUIRE(arr->push_back(e2) == true); + REQUIRE(arr->push_back(null_gc, e2) == true); REQUIRE(arr->size() == 2); - REQUIRE(arr->push_back(e3) == false); + REQUIRE(arr->push_back(null_gc, e3) == false); REQUIRE(arr->size() == 2); REQUIRE(arr->capacity() == 2); } @@ -132,7 +139,8 @@ namespace xo { DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); - DArray * arr = DArray::empty(alloc, 4); + DArray * arr = DArray::_empty(alloc, 4); + obj null_gc; REQUIRE(arr != nullptr); REQUIRE(arr->size() == 0); @@ -142,9 +150,9 @@ namespace xo { obj e1 = DInteger::box(alloc, 200); obj e2 = DInteger::box(alloc, 300); - arr->push_back(e0); - arr->push_back(e1); - arr->push_back(e2); + arr->push_back(null_gc, e0); + arr->push_back(null_gc, e1); + arr->push_back(null_gc, e2); REQUIRE(arr->size() == 3); From 024574350a95d4b349754ee1856073da0fd405fc Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 1 May 2026 19:54:26 -0400 Subject: [PATCH 168/176] refactor focusing on xo-alloc2/ xo-gc/ write-barrier ability to inform allocator of gco->gco mutation, via AAllocator i/face. --- include/xo/object2/DArray.hpp | 29 ++++++++++++--------------- include/xo/object2/DBoolean.hpp | 2 -- include/xo/object2/DDictionary.hpp | 11 ++++------ include/xo/object2/DInteger.hpp | 2 -- include/xo/object2/DList.hpp | 3 ++- src/object2/DArray.cpp | 15 ++++++++++---- src/object2/DDictionary.cpp | 30 ++++++++++++++-------------- src/object2/DList.cpp | 15 +++++++++++++- utest/DArray.test.cpp | 32 +++++++++++++++--------------- 9 files changed, 75 insertions(+), 64 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index de65d1d2..2dc8e931 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -6,7 +6,6 @@ #pragma once #include -//#include #include #include #include @@ -20,7 +19,7 @@ namespace xo { namespace detail { /** null base case **/ static inline bool do_array_push_back(DArray *, - obj) + obj) { return true; } @@ -28,7 +27,7 @@ namespace xo { template requires (std::convertible_to>) static bool do_array_push_back(DArray * lhs, - obj gc, + obj mm, A arg1, Rest... rest); } @@ -49,7 +48,7 @@ namespace xo { /** type for array size **/ using size_type = std::uint32_t; using AAllocator = xo::mm::AAllocator; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; /** gc-centric object visitor **/ using AGCObjectVisitor = xo::mm::AGCObjectVisitor; @@ -114,8 +113,6 @@ namespace xo { obj at(size_type index) const; const obj & operator[](size_type index) const noexcept { return elts_[index]; } - // TODO: nuke this or provide LValue shim. need write barrier! - obj & operator[](size_type index) noexcept { return elts_[index]; } ///@} /** @defgroup darray-iterators iterators **/ @@ -128,17 +125,17 @@ namespace xo { /** store @p elt at position @p index. * true on success, false otherwise **/ - bool assign_at(obj gc, size_type index, obj elt) noexcept; + bool assign_at(obj mm, size_type index, obj elt) noexcept; /** append @p elt at the end of array. * true on success, false otherwise. * on failure array is unaltered **/ - bool push_back(obj gc, obj elt) noexcept; + bool push_back(obj mm, obj elt) noexcept; template requires (std::convertible_to> && ...) - bool push_back_all(obj gc, Args... args) noexcept; + bool push_back_all(obj mm, Args... args) noexcept; /** store last element in array into @p elt and decrement array size. * true on success; false on failure (implies array was empty) @@ -206,10 +203,10 @@ namespace xo { DArray * DArray::array(obj mm, Args... args) { - obj gc = mm.try_to_facet(); + //obj gc = mm.try_to_facet(); DArray * result = _empty(mm, sizeof...(args)); if (result) { - detail::do_array_push_back(result, gc, args...); + detail::do_array_push_back(result, mm, args...); } return result; } @@ -218,20 +215,20 @@ namespace xo { template requires (std::convertible_to>) static bool do_array_push_back(DArray * lhs, - obj gc, + obj mm, A arg1, Rest... rest) { - return (lhs->push_back(gc, arg1) - && do_array_push_back(lhs, gc, rest...)); + return (lhs->push_back(mm, arg1) + && do_array_push_back(lhs, mm, rest...)); } } template requires (std::convertible_to> && ...) bool - DArray::push_back_all(obj gc, Args... args) noexcept { - return detail::do_array_push_back(this, gc, args...); + DArray::push_back_all(obj mm, Args... args) noexcept { + return detail::do_array_push_back(this, mm, args...); } } /*namespace scm*/ diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index 904503c3..7be4c073 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -5,7 +5,6 @@ #pragma once -//#include #include #include #include @@ -16,7 +15,6 @@ namespace xo { namespace scm { struct DBoolean { using AAllocator = xo::mm::AAllocator; - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; using VisitReason = xo::mm::VisitReason; diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 972c71b2..3fad8ece 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -9,7 +9,6 @@ #include "DString.hpp" #include #include -#include #include #include #include @@ -34,8 +33,6 @@ namespace xo { using size_type = std::uint32_t; /** xo allocator facet **/ using AAllocator = xo::mm::AAllocator; - /** garbage collector facet **/ - using ACollector = xo::mm::ACollector; /** gc-centric object visitor **/ using AGCObjectVisitor = xo::mm::AGCObjectVisitor; /** gc-aware object facet **/ @@ -144,12 +141,12 @@ namespace xo { * * @return true if key-value pair updated; false if key not found **/ - bool try_update(obj gc, const pair_type & kvpair); + bool try_update(obj mm, const pair_type & kvpair); /** update key-value pair for existing @p key to map to @p value. * false if @p key not already present. **/ - bool try_update_cstr(obj gc, const char * key, obj value); + bool try_update_cstr(obj gc, const char * key, obj value); /** convenience method: * try_upsert pair (k, @p value), after boxing c-style string @p key with @p mm to get k @@ -167,7 +164,7 @@ namespace xo { * * False if dictionary already at capacity **/ - bool try_upsert(obj gc, const pair_type & kvpair); + bool try_upsert(obj gc, const pair_type & kvpair); /** upsert key-value pair @p kvpair into dictionary. * If at capacity, expand capacity, getting new memory from @p mm. @@ -217,7 +214,7 @@ namespace xo { /** append {key, value} pair @p kv_pair to this dictionary * Require: @p kv_pair.first not already present in @ref keys_ **/ - bool _append_kv_aux(obj gc, const pair_type & kv_pair); + bool _append_kv_aux(obj mm, const pair_type & kv_pair); ///@} private: diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index ddcd9ba1..8bf881a9 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -5,7 +5,6 @@ #pragma once -//#include #include #include #include @@ -16,7 +15,6 @@ namespace xo { namespace scm { struct DInteger { using AAllocator = xo::mm::AAllocator; - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; using VisitReason = xo::mm::VisitReason; diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index a862f186..b5c340c8 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -64,7 +64,8 @@ namespace xo { obj at(size_type ix) const; /** assign head **/ - void assign_head(obj gc, obj h); + void assign_head(obj mm, obj h); + void assign_head_gc(obj gc, obj h); /** assign rest-pointer. Caller responsible for preserving acyclic property! **/ void _assign_rest(DList * r); diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 1910e8e9..44b5a83e 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -75,20 +75,23 @@ namespace xo { } bool - DArray::assign_at(obj gc, size_type ix, obj x) noexcept + DArray::assign_at(obj mm, size_type ix, obj x) noexcept { if (ix >= size_) return false; scope log(XO_DEBUG(true), "need write barrier"); - mm_do_assign(gc, this, &elts_[ix], x); + mm.barrier_assign_aux(this, + elts_[ix].iface(), elts_[ix].opaque_data_addr(), + x.iface(), x.opaque_data()); + // mm_do_assign(gc, this, &elts_[ix], x); return true; } bool - DArray::push_back(obj gc, obj elt) noexcept + DArray::push_back(obj mm, obj elt) noexcept { if (size_ >= capacity_) { return false; @@ -98,7 +101,11 @@ namespace xo { void * mem = &(elts_[size_]); new (mem) obj(); - mm_do_assign(gc, this, &(elts_[size_]), elt); + mm.barrier_assign_aux(this, + elts_[size_].iface(), elts_[size_].opaque_data_addr(), + elt.iface(), elt.opaque_data()); + + //mm_do_assign(gc, this, &(elts_[size_]), elt); ++(this->size_); diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 43a4e1cd..2f52cae3 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -108,7 +108,7 @@ namespace xo { } bool - DDictionary::try_update(obj gc, const pair_type & kv_pair) + DDictionary::try_update(obj mm, const pair_type & kv_pair) { for (size_type i = 0, n = keys_->size(); i < n; ++i) { auto key_i = obj::from((*keys_)[i]); @@ -116,7 +116,7 @@ namespace xo { assert(key_i); if (*(key_i.data()) == *(kv_pair.first)) { - values_->assign_at(gc, i, kv_pair.second); + values_->assign_at(mm, i, kv_pair.second); return true; } } @@ -125,7 +125,7 @@ namespace xo { } bool - DDictionary::try_update_cstr(obj gc, const char * key, obj value) + DDictionary::try_update_cstr(obj mm, const char * key, obj value) { for (size_type i = 0, n = keys_->size(); i < n; ++i) { auto key_i = obj::from((*keys_)[i]); @@ -133,7 +133,7 @@ namespace xo { assert(key_i); if (strcmp(key, key_i->data()) == 0) { - values_->assign_at(gc, i, value); + values_->assign_at(mm, i, value); return true; } @@ -148,8 +148,8 @@ namespace xo { const DString * k1 = DString::from_cstr(mm, key_cstr); if (k1) { - obj gc = mm.try_to_facet(); - return this->try_upsert(gc, std::make_pair(k1, value)); + //obj gc = mm.try_to_facet(); + return this->try_upsert(mm, std::make_pair(k1, value)); } return false; @@ -167,23 +167,23 @@ namespace xo { } bool - DDictionary::try_upsert(obj gc, const pair_type & kv_pair) + DDictionary::try_upsert(obj mm, const pair_type & kv_pair) { - if (this->try_update(gc, kv_pair)) + if (this->try_update(mm, kv_pair)) return true; if (keys_->size() == keys_->capacity()) return false; - return this->_append_kv_aux(gc, kv_pair); + return this->_append_kv_aux(mm, kv_pair); } bool DDictionary::upsert(obj mm, const pair_type & kv_pair) { - obj gc = mm.try_to_facet(); + //obj gc = mm.try_to_facet(); - if (this->try_update(gc, kv_pair)) + if (this->try_update(mm, kv_pair)) return true; // key not present -> must expand {key array, value array} @@ -204,19 +204,19 @@ namespace xo { } } - return this->_append_kv_aux(gc, kv_pair); + return this->_append_kv_aux(mm, kv_pair); } bool - DDictionary::_append_kv_aux(obj gc, const pair_type & kv_pair) + DDictionary::_append_kv_aux(obj mm, const pair_type & kv_pair) { DString * key = const_cast(kv_pair.first); bool ok - = keys_->push_back(gc, obj(key)); + = keys_->push_back(mm, obj(key)); if (ok) { - ok = values_->push_back(gc, kv_pair.second); + ok = values_->push_back(mm, kv_pair.second); if (!ok) { // since we couldn't insert value, also drop key diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 7208bb9f..0b694aac 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -120,7 +120,20 @@ namespace xo { } void - DList::assign_head(obj gc, obj rhs) + DList::assign_head(obj mm, obj rhs) + { + scope log(XO_DEBUG(true), xtag("mm.data", mm.data_)); + + mm.barrier_assign_aux(this, + head_.iface(), head_.opaque_data_addr(), + rhs.iface(), rhs.opaque_data()); + + //mm_do_assign(gc, this, &head_, rhs); + } + + // vestigial. used in MockCollector + void + DList::assign_head_gc(obj gc, obj rhs) { scope log(XO_DEBUG(true), xtag("gc.data", gc.data_)); diff --git a/utest/DArray.test.cpp b/utest/DArray.test.cpp index af26c719..89353608 100644 --- a/utest/DArray.test.cpp +++ b/utest/DArray.test.cpp @@ -30,12 +30,12 @@ namespace xo { REQUIRE(arr.size() == 0); REQUIRE(arr.capacity() == 0); - REQUIRE(arr.is_empty());; + REQUIRE(arr.is_empty()); - // null_gc: for no memory barrier - obj null_gc; + // null_mm: for no memory barrier + obj null_mm; - REQUIRE(arr.push_back(null_gc, ListOps::nil()) == false); + REQUIRE(arr.push_back(null_mm, ListOps::nil()) == false); } TEST_CASE("DArray-empty", "[object2][DArray]") @@ -61,7 +61,7 @@ namespace xo { .size_ = 4*1024 }; DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); - obj null_gc; + obj null_mm; DArray * arr = DArray::_empty(alloc, 16); REQUIRE(arr != nullptr); @@ -70,7 +70,7 @@ namespace xo { obj elt = DInteger::box(alloc, 42); - bool ok = arr->push_back(null_gc, elt); + bool ok = arr->push_back(null_mm, elt); REQUIRE(ok == true); REQUIRE(arr->is_empty() == false); @@ -84,7 +84,7 @@ namespace xo { .size_ = 4*1024 }; DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); - obj null_gc; + obj null_mm; DArray * arr = DArray::_empty(alloc, 4); REQUIRE(arr != nullptr); @@ -96,7 +96,7 @@ namespace xo { REQUIRE(arr->size() == i); obj elt = DInteger::box(alloc, 100 + i); - bool ok = arr->push_back(null_gc, elt); + bool ok = arr->push_back(null_mm, elt); REQUIRE(ok == true); REQUIRE(arr->capacity() == 4); @@ -113,7 +113,7 @@ namespace xo { auto alloc = with_facet::mkobj(&arena); DArray * arr = DArray::_empty(alloc, 2); - obj null_gc; + obj null_mm; REQUIRE(arr != nullptr); REQUIRE(arr->capacity() == 2); @@ -123,11 +123,11 @@ namespace xo { obj e2 = DInteger::box(alloc, 2); obj e3 = DInteger::box(alloc, 3); - REQUIRE(arr->push_back(null_gc, e1) == true); + REQUIRE(arr->push_back(null_mm, e1) == true); REQUIRE(arr->size() == 1); - REQUIRE(arr->push_back(null_gc, e2) == true); + REQUIRE(arr->push_back(null_mm, e2) == true); REQUIRE(arr->size() == 2); - REQUIRE(arr->push_back(null_gc, e3) == false); + REQUIRE(arr->push_back(null_mm, e3) == false); REQUIRE(arr->size() == 2); REQUIRE(arr->capacity() == 2); } @@ -140,7 +140,7 @@ namespace xo { auto alloc = with_facet::mkobj(&arena); DArray * arr = DArray::_empty(alloc, 4); - obj null_gc; + obj null_mm; REQUIRE(arr != nullptr); REQUIRE(arr->size() == 0); @@ -150,9 +150,9 @@ namespace xo { obj e1 = DInteger::box(alloc, 200); obj e2 = DInteger::box(alloc, 300); - arr->push_back(null_gc, e0); - arr->push_back(null_gc, e1); - arr->push_back(null_gc, e2); + arr->push_back(null_mm, e0); + arr->push_back(null_mm, e1); + arr->push_back(null_mm, e2); REQUIRE(arr->size() == 3); From 6c8da340c81c6043a42bdf4f86b3e8afa1a4cb4b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 1 May 2026 20:14:26 -0400 Subject: [PATCH 169/176] xo-object2 stack: RAllocator.assign_barrier() works. use for DList::assign_head(), DArray::assign_at(). --- src/object2/DArray.cpp | 17 +++++++++-------- src/object2/DList.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 44b5a83e..aeb03196 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -82,10 +82,11 @@ namespace xo { scope log(XO_DEBUG(true), "need write barrier"); - mm.barrier_assign_aux(this, - elts_[ix].iface(), elts_[ix].opaque_data_addr(), - x.iface(), x.opaque_data()); - // mm_do_assign(gc, this, &elts_[ix], x); + mm.barrier_assign(this, &elts_[ix], x); + + //mm.barrier_assign_aux(this, + // elts_[ix].iface(), elts_[ix].opaque_data_addr(), + // x.iface(), x.opaque_data()); return true; } @@ -101,11 +102,11 @@ namespace xo { void * mem = &(elts_[size_]); new (mem) obj(); - mm.barrier_assign_aux(this, - elts_[size_].iface(), elts_[size_].opaque_data_addr(), - elt.iface(), elt.opaque_data()); + mm.barrier_assign(this, &elts_[size_], elt); - //mm_do_assign(gc, this, &(elts_[size_]), elt); + //mm.barrier_assign_aux(this, + // elts_[size_].iface(), elts_[size_].opaque_data_addr(), + // elt.iface(), elt.opaque_data()); ++(this->size_); diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 0b694aac..f6e5d494 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -124,11 +124,11 @@ namespace xo { { scope log(XO_DEBUG(true), xtag("mm.data", mm.data_)); - mm.barrier_assign_aux(this, - head_.iface(), head_.opaque_data_addr(), - rhs.iface(), rhs.opaque_data()); + mm.barrier_assign(this, &head_, rhs); - //mm_do_assign(gc, this, &head_, rhs); + //mm.barrier_assign_aux(this, + // head_.iface(), head_.opaque_data_addr(), + // rhs.iface(), rhs.opaque_data()); } // vestigial. used in MockCollector From 3f7bc2e8e02d6de6fdbf202a811880b038eaa9b0 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 1 May 2026 20:15:45 -0400 Subject: [PATCH 170/176] xo-object2: prep DList for write barrier in _assign_rest() --- src/object2/DList.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index f6e5d494..75bde74c 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -141,11 +141,20 @@ namespace xo { } void - DList::_assign_rest(DList * r) + DList::_assign_rest(DList * rest) { scope log(XO_DEBUG(true), "need write barrier"); - this->rest_ = r; +#ifdef NOT_YET + obj rest_gco(rest); + + mm.barrier_assign_aux(this, + nullptr /*lhs iface unused*/, + &(this->rest_), + rest_gco.iface(), + rest); +#endif + this->rest_ = rest; } bool From 96ebc02d4a4db45fabfae0e638d1b0ec76b1f437 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 1 May 2026 20:38:38 -0400 Subject: [PATCH 171/176] xo-object2: streamline write barriers for DList,DArray muts --- include/xo/object2/DList.hpp | 2 +- src/object2/DArray.cpp | 10 ---------- src/object2/DList.cpp | 9 ++------- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index b5c340c8..fbc64784 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -67,7 +67,7 @@ namespace xo { void assign_head(obj mm, obj h); void assign_head_gc(obj gc, obj h); /** assign rest-pointer. Caller responsible for preserving acyclic property! **/ - void _assign_rest(DList * r); + void _assign_rest(obj mm, DList * r); /** pretty-printing driver; combine layout+printing **/ bool pretty(const ppindentinfo & ppii) const; diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index aeb03196..49c3d64f 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -80,14 +80,8 @@ namespace xo { if (ix >= size_) return false; - scope log(XO_DEBUG(true), "need write barrier"); - mm.barrier_assign(this, &elts_[ix], x); - //mm.barrier_assign_aux(this, - // elts_[ix].iface(), elts_[ix].opaque_data_addr(), - // x.iface(), x.opaque_data()); - return true; } @@ -104,10 +98,6 @@ namespace xo { mm.barrier_assign(this, &elts_[size_], elt); - //mm.barrier_assign_aux(this, - // elts_[size_].iface(), elts_[size_].opaque_data_addr(), - // elt.iface(), elt.opaque_data()); - ++(this->size_); return true; diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 75bde74c..b8494c34 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -141,20 +141,15 @@ namespace xo { } void - DList::_assign_rest(DList * rest) + DList::_assign_rest(obj mm, DList * rest) { - scope log(XO_DEBUG(true), "need write barrier"); - -#ifdef NOT_YET obj rest_gco(rest); mm.barrier_assign_aux(this, nullptr /*lhs iface unused*/, - &(this->rest_), + (void**)&(this->rest_), rest_gco.iface(), rest); -#endif - this->rest_ = rest; } bool From cff5963b31f639263668ab24203143d56dc441d5 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 2 May 2026 13:49:29 -0400 Subject: [PATCH 172/176] xo-gc stack: refactor + streamline. Retiring unused Collector typealiases. Fix #include topology. Fix/improve write barrier setup. --- include/xo/object2/array/IGCObject_DArray.hpp | 1 - include/xo/object2/boolean/IGCObject_DBoolean.hpp | 1 - include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 1 - include/xo/object2/error/IGCObject_DRuntimeError.hpp | 1 - include/xo/object2/list/IGCObject_DList.hpp | 1 - include/xo/object2/number/IGCObject_DFloat.hpp | 1 - include/xo/object2/number/IGCObject_DInteger.hpp | 1 - include/xo/object2/sequence/ISequence_Xfer.hpp | 8 ++++++++ src/object2/DArray.cpp | 4 ++-- src/object2/DList.cpp | 8 +++++++- 10 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 4cd5f026..31ab5742 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -41,7 +41,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 8ab00b09..a3cff7ca 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -41,7 +41,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 52d093bb..acaffdf4 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -41,7 +41,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index 19e378b4..7f31367c 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -41,7 +41,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index 10463fef..94de87d4 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -41,7 +41,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index 0d9042f6..9383014f 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -42,7 +42,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 5d6d944f..b116532f 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -41,7 +41,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/object2/sequence/ISequence_Xfer.hpp b/include/xo/object2/sequence/ISequence_Xfer.hpp index e0511e41..a18ad124 100644 --- a/include/xo/object2/sequence/ISequence_Xfer.hpp +++ b/include/xo/object2/sequence/ISequence_Xfer.hpp @@ -9,10 +9,18 @@ * [iface_facet_any.hpp.j2] * 3. idl for facet methods * [idl/Sequence.json5] + * + * variables: + * {facet_hpp_fname} -> Sequence.hpp + * {impl_hpp_subdir} -> sequence + * {facet_ns1} -> xo + * {facet_detail_subdir} -> sequence + * {abstract_facet_fname} -> ASequence.hpp **/ #pragma once +#include "ASequence.hpp" #include namespace xo { diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 49c3d64f..b22b748e 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -4,7 +4,7 @@ **/ #include "DArray.hpp" -#include "gc/RCollector_aux.hpp" +//#include "gc/RCollector_aux.hpp" #include #include #include @@ -16,7 +16,7 @@ namespace xo { using xo::print::APrintable; using xo::facet::FacetRegistry; using xo::mm::AGCObject; - using xo::mm::mm_do_assign; + //using xo::mm::mm_do_assign; using xo::facet::typeseq; namespace scm { diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index b8494c34..98c82a09 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -6,7 +6,13 @@ #include "DList.hpp" #include "list/IPrintable_DList.hpp" #include "list/IGCObject_DList.hpp" +#include #include + +// need Collector for mm_do_assign() +#include +#include // for mm_do_assign() + #include #include #include @@ -137,7 +143,7 @@ namespace xo { { scope log(XO_DEBUG(true), xtag("gc.data", gc.data_)); - mm_do_assign(gc, this, &head_, rhs); + xo::mm::mm_do_assign(gc, this, &head_, rhs); } void From 05a6aa9425d627ac0d84ad915bba112c25ba117c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 2 May 2026 13:58:22 -0400 Subject: [PATCH 173/176] tidy: drop stale ACollector comments --- include/xo/object2/DArray.hpp | 1 - src/object2/DArray.cpp | 2 -- src/object2/DDictionary.cpp | 3 --- 3 files changed, 6 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 2dc8e931..64d7f52c 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -203,7 +203,6 @@ namespace xo { DArray * DArray::array(obj mm, Args... args) { - //obj gc = mm.try_to_facet(); DArray * result = _empty(mm, sizeof...(args)); if (result) { detail::do_array_push_back(result, mm, args...); diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index b22b748e..2a5c590e 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -4,7 +4,6 @@ **/ #include "DArray.hpp" -//#include "gc/RCollector_aux.hpp" #include #include #include @@ -16,7 +15,6 @@ namespace xo { using xo::print::APrintable; using xo::facet::FacetRegistry; using xo::mm::AGCObject; - //using xo::mm::mm_do_assign; using xo::facet::typeseq; namespace scm { diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 2f52cae3..9e05cfa9 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -148,7 +148,6 @@ namespace xo { const DString * k1 = DString::from_cstr(mm, key_cstr); if (k1) { - //obj gc = mm.try_to_facet(); return this->try_upsert(mm, std::make_pair(k1, value)); } @@ -181,8 +180,6 @@ namespace xo { bool DDictionary::upsert(obj mm, const pair_type & kv_pair) { - //obj gc = mm.try_to_facet(); - if (this->try_update(mm, kv_pair)) return true; From 211bc93c855a23cc9aa91d0e3e170a5bf8f2f907 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 7 May 2026 23:44:32 -0400 Subject: [PATCH 174/176] xo-gc stack: fix mutation setup + xo-reader2 utest --- include/xo/object2/DArray.hpp | 14 ++++++++++++++ src/object2/DArray.cpp | 3 ++- utest/DArray.test.cpp | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 64d7f52c..5f571333 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -76,6 +76,11 @@ namespace xo { static DArray * _empty(obj mm, size_type cap); + /** ofp version of _empty(mm,cap) **/ + template + static obj empty(obj mm, + size_type cap); + /** create copy of @p src using memory from @p mm * with capacity for @p new_cap elements **/ @@ -198,6 +203,15 @@ namespace xo { ///@} }; + template + obj + DArray::empty(obj mm, DArray::size_type cap) + { + DArray * retval = _empty(mm, cap); + + return obj(retval); + } + template requires (std::convertible_to> && ...) DArray * diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 2a5c590e..050f757d 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -84,7 +84,8 @@ namespace xo { } bool - DArray::push_back(obj mm, obj elt) noexcept + DArray::push_back(obj mm, + obj elt) noexcept { if (size_ >= capacity_) { return false; diff --git a/utest/DArray.test.cpp b/utest/DArray.test.cpp index 89353608..15da135e 100644 --- a/utest/DArray.test.cpp +++ b/utest/DArray.test.cpp @@ -63,6 +63,9 @@ namespace xo { auto alloc = with_facet::mkobj(&arena); obj null_mm; + REQUIRE(!null_mm.data()); + REQUIRE(!null_mm._has_null_vptr()); // any + DArray * arr = DArray::_empty(alloc, 16); REQUIRE(arr != nullptr); REQUIRE(arr->capacity() == 16); From 82f13b748d8684f2fe5801b7fff9cda02a39dd27 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 13 May 2026 08:14:58 -0400 Subject: [PATCH 175/176] xo-gc: address some coverage loose ends --- src/object2/DList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 98c82a09..54315823 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -143,7 +143,7 @@ namespace xo { { scope log(XO_DEBUG(true), xtag("gc.data", gc.data_)); - xo::mm::mm_do_assign(gc, this, &head_, rhs); + gc.assign_member(this, &head_, rhs); } void From 8156e5149ab93714465429b9f76f905243401036 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 27 May 2026 08:17:12 -0400 Subject: [PATCH 176/176] xo-object2: - dead comment in CMakeLists.txt --- utest/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 34046715..f3bd90e4 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -12,6 +12,4 @@ set(UTEST_SRCS xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) xo_self_dependency(${UTEST_EXE} xo_object2) -#xo_dependency(${UTEST_EXE} xo_gc) -#xo_dependency(${UTEST_EXE} randomgen) xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2)