From c9944a27aaeea2cc59e7027fa3e2d81967f6ee60 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 6 Mar 2026 13:04:31 +1100 Subject: [PATCH 01/31] xo-type: + DAtomicType [WIP] --- CMakeLists.txt | 70 +++++++++++++++ cmake/xo-bootstrap-macros.cmake | 41 +++++++++ cmake/xo_typeConfig.cmake.in | 15 ++++ idl/IGCObject_DAtomicType.json5 | 16 ++++ idl/IType_DAtomicType.json5 | 16 ++++ idl/Type.json5 | 53 +++++++++++ include/xo/type/AtomicType.hpp | 12 +++ include/xo/type/DAtomicType.hpp | 48 ++++++++++ include/xo/type/Metatype.hpp | 60 +++++++++++++ include/xo/type/Type.hpp | 22 +++++ .../xo/type/atomic/IGCObject_DAtomicType.hpp | 65 ++++++++++++++ include/xo/type/atomic/IType_DAtomicType.hpp | 59 ++++++++++++ include/xo/type/init_type.hpp | 21 +++++ include/xo/type/type/AType.hpp | 77 ++++++++++++++++ include/xo/type/type/IType_Any.hpp | 89 +++++++++++++++++++ include/xo/type/type/IType_Xfer.hpp | 84 +++++++++++++++++ include/xo/type/type/RType.hpp | 85 ++++++++++++++++++ include/xo/type/type_register_facets.hpp | 15 ++++ include/xo/type/type_register_types.hpp | 17 ++++ src/type/CMakeLists.txt | 25 ++++++ src/type/DAtomicType.cpp | 42 +++++++++ src/type/IGCObject_DAtomicType.cpp | 39 ++++++++ src/type/IType_Any.cpp | 42 +++++++++ src/type/IType_DAtomicType.cpp | 28 ++++++ src/type/Metatype.cpp | 32 +++++++ src/type/init_type.cpp | 40 +++++++++ src/type/type_register_facets.cpp | 35 ++++++++ src/type/type_register_types.cpp | 34 +++++++ utest/CMakeLists.txt | 16 ++++ utest/DAtomicType.test.cpp | 40 +++++++++ utest/type_utest_main.cpp | 24 +++++ 31 files changed, 1262 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/xo-bootstrap-macros.cmake create mode 100644 cmake/xo_typeConfig.cmake.in create mode 100644 idl/IGCObject_DAtomicType.json5 create mode 100644 idl/IType_DAtomicType.json5 create mode 100644 idl/Type.json5 create mode 100644 include/xo/type/AtomicType.hpp create mode 100644 include/xo/type/DAtomicType.hpp create mode 100644 include/xo/type/Metatype.hpp create mode 100644 include/xo/type/Type.hpp create mode 100644 include/xo/type/atomic/IGCObject_DAtomicType.hpp create mode 100644 include/xo/type/atomic/IType_DAtomicType.hpp create mode 100644 include/xo/type/init_type.hpp create mode 100644 include/xo/type/type/AType.hpp create mode 100644 include/xo/type/type/IType_Any.hpp create mode 100644 include/xo/type/type/IType_Xfer.hpp create mode 100644 include/xo/type/type/RType.hpp create mode 100644 include/xo/type/type_register_facets.hpp create mode 100644 include/xo/type/type_register_types.hpp create mode 100644 src/type/CMakeLists.txt create mode 100644 src/type/DAtomicType.cpp create mode 100644 src/type/IGCObject_DAtomicType.cpp create mode 100644 src/type/IType_Any.cpp create mode 100644 src/type/IType_DAtomicType.cpp create mode 100644 src/type/Metatype.cpp create mode 100644 src/type/init_type.cpp create mode 100644 src/type/type_register_facets.cpp create mode 100644 src/type/type_register_types.cpp create mode 100644 utest/CMakeLists.txt create mode 100644 utest/DAtomicType.test.cpp create mode 100644 utest/type_utest_main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..e11f53b1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,70 @@ +# xo-type/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(xo_type VERSION 1.0) +enable_language(CXX) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +# one-time project-specific c++ flags. usually empty +set(PROJECT_CXX_FLAGS "") +add_definitions(${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- +# facet code generation + +xo_add_genfacet( + TARGET xo-type-facet-type + FACET Type + INPUT idl/Type.json5 + OUTPUT_HPP_DIR include/xo/type + OUTPUT_IMPL_SUBDIR type +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-type-facetimpl-type-atomictype + FACET_PKG xo_type + FACET Type + REPR AtomicType + INPUT idl/IType_DAtomicType.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-type-facetimpl-gcobject-atomictype + FACET_PKG xo_alloc2 + FACET GCObject + REPR AtomicType + INPUT idl/IGCObject_DAtomicType.json5 +) + +# ---------------------------------------------------------------- + +xo_add_genfacet_all(xo-type-genfacet-all) + +install(DIRECTORY idl/ + DESTINATION share/${PROJECT_NAME}/idl + FILES_MATCHING PATTERN "*.json5") + +# ---------------------------------------------------------------- +# output targets + +add_subdirectory(src/type) +add_subdirectory(utest) + +# ---------------------------------------------------------------- +# cmake export + +xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +# end CMakeLists.txt diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..592272c0 --- /dev/null +++ b/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,41 @@ +# ---------------------------------------------------------------- +# 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 (XO_SUBMODULE_BUILD) + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # local version of xo-cmake macros + set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/xo-cmake/cmake") + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() +else() + 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_typeConfig.cmake.in b/cmake/xo_typeConfig.cmake.in new file mode 100644 index 00000000..2c4c0d1d --- /dev/null +++ b/cmake/xo_typeConfig.cmake.in @@ -0,0 +1,15 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(xo_alloc2) +find_dependency(xo_facet) + +# note: changes to find_dependency() calls here +# must coordinate with xo_dependency() calls +# in src/type/CMakeLists.txt +# +#find_dependency(xo_indentlog) + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Share.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/idl/IGCObject_DAtomicType.json5 b/idl/IGCObject_DAtomicType.json5 new file mode 100644 index 00000000..4cb85c1b --- /dev/null +++ b/idl/IGCObject_DAtomicType.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "atomic", + includes: [ + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DAtomicType", + using_doxygen: true, + repr: "DAtomicType", + doc: [ "implement AGCObject for DAtomicType" ], +} diff --git a/idl/IType_DAtomicType.json5 b/idl/IType_DAtomicType.json5 new file mode 100644 index 00000000..c94c8923 --- /dev/null +++ b/idl/IType_DAtomicType.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "atomic", + includes: [], + local_types: [], + namespace1: "xo", + namespace2: "scm", + + facet_idl: "idl/Type.json5", + brief: "provide AType interface for DAtomicType", + using_doxygen: true, + repr: "DAtomicType", + doc: [ "implement AType for DAtomicType" ], +} diff --git a/idl/Type.json5 b/idl/Type.json5 new file mode 100644 index 00000000..eeb22334 --- /dev/null +++ b/idl/Type.json5 @@ -0,0 +1,53 @@ +{ + mode: "facet", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "type", + includes: [ + "" + ], + user_hpp_includes: [ + ], + namespace1: "xo", + namespace2: "scm", // TODO: change to project namespace if different + pretext: [ + "// pretext if any" + ], + facet: "Type", + detail_subdir: "type", + brief: "Representation for a Schematika type", + using_doxygen: true, + doc: [ + "1. Ability to compare types as members of partial order", + "2. ..." + ], + types: [ + { + name: "obj_AType", + doc: [], + definition: "xo::facet::obj", + } + ], + const_methods: [ + { + name: "metatype", + doc: ["category for this type"], + return_type: "Metatype", + args: [], + const: true, + noexcept: true, + }, + + // TODO: define methods, e.g.: + // { + // name: "my_method", + // doc: ["description"], + // return_type: "bool", + // args: [], + // const: true, + // noexcept: true, + // }, + ], + nonconst_methods: [], + router_facet_explicit_content: [], +} diff --git a/include/xo/type/AtomicType.hpp b/include/xo/type/AtomicType.hpp new file mode 100644 index 00000000..e5515291 --- /dev/null +++ b/include/xo/type/AtomicType.hpp @@ -0,0 +1,12 @@ +/** @file AtomicType.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "DAtomicType.hpp" +#include "atomic/IType_DAtomicType.hpp" +#include "atomic/IGCObject_DAtomicType.hpp" + +/* end AtomicType.hpp */ diff --git a/include/xo/type/DAtomicType.hpp b/include/xo/type/DAtomicType.hpp new file mode 100644 index 00000000..253b678b --- /dev/null +++ b/include/xo/type/DAtomicType.hpp @@ -0,0 +1,48 @@ +/** @file DAtomicType.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "Metatype.hpp" +#include +#include + +namespace xo { + namespace scm { + /** @brief An atomic schematika type + * + * Types that are not parameterized by types or values. + * For example + * unit, bool, i64, f64 + * are atomic in this sense. + **/ + class DAtomicType { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + + public: + explicit DAtomicType(Metatype m) : metatype_{m} {} + + /** create instance using memory from @p mm with metatype @p mtype **/ + static DAtomicType * _make(obj mm, Metatype mtype); + + Metatype metatype() const noexcept { return metatype_; } + + /** @defgroup xo-scm-atomictype-gcobject-facet **/ + ///@{ + std::size_t shallow_size() const noexcept; + DAtomicType * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} + + private: + Metatype metatype_; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DAtomicType.hpp */ diff --git a/include/xo/type/Metatype.hpp b/include/xo/type/Metatype.hpp new file mode 100644 index 00000000..813b1446 --- /dev/null +++ b/include/xo/type/Metatype.hpp @@ -0,0 +1,60 @@ +/** @file Metatype.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + class Metatype { + public: + enum class code { + /* void */ + t_unit, + + t_bool, + t_i64, + t_f64, + t_str, + + /* discriminated union */ + t_sum, + /* list */ + t_list, + /* array */ + t_array, + /* function */ + t_function, + /* struct */ + t_struct, + + /* any type at all */ + t_any, + }; + + public: + explicit Metatype(code x) : code_{x} {} + + static Metatype unit() { return Metatype(code::t_unit); } + + /** description string for this type category **/ + const char * _descr() const noexcept; + + code code() const noexcept { return code_; } + + private: + enum code code_; + }; + + inline std::ostream & + operator<<(std::ostream & os, Metatype x) { + os << x._descr(); + return os; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end Metatype.hpp */ diff --git a/include/xo/type/Type.hpp b/include/xo/type/Type.hpp new file mode 100644 index 00000000..97da0453 --- /dev/null +++ b/include/xo/type/Type.hpp @@ -0,0 +1,22 @@ +/** @file Type.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Type.json5] + * 2. jinja2 template for facet .hpp file: + * [facet.hpp.j2] + * 3. idl for facet methods + * [idl/Type.json5] + **/ + +#pragma once + +#include "type/AType.hpp" +#include "type/IType_Any.hpp" +#include "type/IType_Xfer.hpp" +#include "type/RType.hpp" + + +/* end Type.hpp */ diff --git a/include/xo/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp new file mode 100644 index 00000000..c1fff453 --- /dev/null +++ b/include/xo/type/atomic/IGCObject_DAtomicType.hpp @@ -0,0 +1,65 @@ +/** @file IGCObject_DAtomicType.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DAtomicType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DAtomicType.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include "DAtomicType.hpp" + +namespace xo { namespace scm { class IGCObject_DAtomicType; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DAtomicType + **/ + class IGCObject_DAtomicType { + public: + /** @defgroup scm-gcobject-datomictype-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-datomictype-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DAtomicType & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DAtomicType & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DAtomicType & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/type/atomic/IType_DAtomicType.hpp b/include/xo/type/atomic/IType_DAtomicType.hpp new file mode 100644 index 00000000..8a351cf9 --- /dev/null +++ b/include/xo/type/atomic/IType_DAtomicType.hpp @@ -0,0 +1,59 @@ +/** @file IType_DAtomicType.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DAtomicType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DAtomicType.json5] + **/ + +#pragma once + +#include "Type.hpp" +#include "DAtomicType.hpp" + +namespace xo { namespace scm { class IType_DAtomicType; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IType_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IType_DAtomicType + **/ + class IType_DAtomicType { + public: + /** @defgroup scm-type-datomictype-type-traits **/ + ///@{ + using obj_AType = xo::scm::AType::obj_AType; + using Copaque = xo::scm::AType::Copaque; + using Opaque = xo::scm::AType::Opaque; + ///@} + /** @defgroup scm-type-datomictype-methods **/ + ///@{ + // const methods + /** category for this type **/ + static Metatype metatype(const DAtomicType & self) noexcept; + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/type/init_type.hpp b/include/xo/type/init_type.hpp new file mode 100644 index 00000000..d06f33f8 --- /dev/null +++ b/include/xo/type/init_type.hpp @@ -0,0 +1,21 @@ +/** @file init_type.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + /* tag to represent the xo-expression2/ subsystem within ordered initialization */ + enum S_type_tag {}; + + template <> + struct InitSubsys { + static void init(); + static InitEvidence require(); + }; +} /*namespace xo*/ + +/* end init_type.hpp */ diff --git a/include/xo/type/type/AType.hpp b/include/xo/type/type/AType.hpp new file mode 100644 index 00000000..50389fe7 --- /dev/null +++ b/include/xo/type/type/AType.hpp @@ -0,0 +1,77 @@ +/** @file AType.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Type.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [idl/Type.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include +#include +#include +#include + +// pretext if any + +namespace xo { +namespace scm { + +using Copaque = const void *; +using Opaque = void *; + +/** +1. Ability to compare types as members of partial order +2. ... +**/ +class AType { +public: + /** @defgroup scm-type-type-traits **/ + ///@{ + // types + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using Copaque = const void *; + using Opaque = void *; + /** **/ + using obj_AType = xo::facet::obj; + ///@} + + /** @defgroup scm-type-methods **/ + ///@{ + // 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; + /** category for this type **/ + virtual Metatype metatype(Copaque data) const noexcept = 0; + + // nonconst methods + ///@} +}; /*AType*/ + +/** Implementation IType_DRepr of AType for state DRepr + * should provide a specialization: + * + * template <> + * struct xo::facet::FacetImplementation { + * using Impltype = IType_DRepr; + * }; + * + * then IType_ImplType --> IType_DRepr + **/ +template +using IType_ImplType = xo::facet::FacetImplType; + +} /*namespace scm*/ +} /*namespace xo*/ + +/* AType.hpp */ diff --git a/include/xo/type/type/IType_Any.hpp b/include/xo/type/type/IType_Any.hpp new file mode 100644 index 00000000..6db13097 --- /dev/null +++ b/include/xo/type/type/IType_Any.hpp @@ -0,0 +1,89 @@ +/** @file IType_Any.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Type.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Type.json5] + **/ + +#pragma once + +#include "AType.hpp" +#include + +namespace xo { namespace scm { class IType_Any; } } + +namespace xo { +namespace facet { + +template <> +struct FacetImplementation +{ + using ImplType = xo::scm::IType_Any; +}; + +} +} + +namespace xo { +namespace scm { + + /** @class IType_Any + * @brief AType implementation for empty variant instance + **/ + class IType_Any : public AType { + public: + /** @defgroup scm-type-any-type-traits **/ + ///@{ + + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using obj_AType = AType::obj_AType; + + ///@} + /** @defgroup scm-type-any-methods **/ + ///@{ + + const AType * iface() const { return std::launder(this); } + + // from AType + + // builtin methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); } + + // const methods + [[noreturn]] Metatype metatype(Copaque) const noexcept override { _fatal(); } + + // nonconst methods + + ///@} + + private: + /** @defgraoup scm-type-any-private-methods **/ + ///@{ + + [[noreturn]] static void _fatal(); + + ///@} + + public: + /** @defgroup scm-type-any-member-vars **/ + ///@{ + + static typeseq s_typeseq; + static bool _valid; + + ///@} + }; + +} /*namespace scm */ +} /*namespace xo */ + +/* IType_Any.hpp */ diff --git a/include/xo/type/type/IType_Xfer.hpp b/include/xo/type/type/IType_Xfer.hpp new file mode 100644 index 00000000..ead6c45e --- /dev/null +++ b/include/xo/type/type/IType_Xfer.hpp @@ -0,0 +1,84 @@ +/** @file IType_Xfer.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Type.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Type.json5] + **/ + +#pragma once + +#include + +namespace xo { +namespace scm { + /** @class IType_Xfer + **/ + template + class IType_Xfer : public AType { + public: + /** @defgroup scm-type-xfer-type-traits **/ + ///@{ + /** actual implementation (not generated; often delegates to DRepr) **/ + using Impl = IType_DRepr; + /** integer identifying a type **/ + using typeseq = AType::typeseq; + using obj_AType = AType::obj_AType; + ///@} + + /** @defgroup scm-type-xfer-methods **/ + ///@{ + + static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; } + static DRepr & _dcast(Opaque d) { return *(DRepr *)d; } + + // from AType + + // builtin methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); } + + // const methods + Metatype metatype(Copaque data) const noexcept override { + return I::metatype(_dcast(data)); + } + + // non-const methods + + ///@} + + private: + using I = Impl; + + public: + /** @defgroup scm-type-xfer-member-vars **/ + ///@{ + + /** typeseq for template parameter DRepr **/ + static typeseq s_typeseq; + /** true iff satisfies facet implementation **/ + static bool _valid; + + ///@} + }; + + template + xo::facet::typeseq + IType_Xfer::s_typeseq + = xo::facet::typeseq::id(); + + template + bool + IType_Xfer::_valid + = xo::facet::valid_facet_implementation(); + +} /*namespace scm */ +} /*namespace xo*/ + +/* end IType_Xfer.hpp */ diff --git a/include/xo/type/type/RType.hpp b/include/xo/type/type/RType.hpp new file mode 100644 index 00000000..a6376fe0 --- /dev/null +++ b/include/xo/type/type/RType.hpp @@ -0,0 +1,85 @@ +/** @file RType.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Type.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Type.json5] + **/ + +#pragma once + +#include "AType.hpp" + +namespace xo { +namespace scm { + +/** @class RType + **/ +template +class RType : public Object { +private: + using O = Object; + +public: + /** @defgroup scm-type-router-type-traits **/ + ///@{ + using ObjectType = Object; + using DataPtr = Object::DataPtr; + using typeseq = xo::reflect::typeseq; + using obj_AType = AType::obj_AType; + ///@} + + /** @defgroup scm-type-router-ctors **/ + ///@{ + RType() {} + RType(Object::DataPtr data) : Object{std::move(data)} {} + RType(const AType * iface, void * data) + requires std::is_same_v + : Object(iface, data) {} + + ///@} + /** @defgroup scm-type-router-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 + Metatype metatype() const noexcept { + return O::iface()->metatype(O::data()); + } + + // non-const methods (still const in router!) + + ///@} + /** @defgroup scm-type-member-vars **/ + ///@{ + + static bool _valid; + + ///@} +}; + +template +bool +RType::_valid = xo::facet::valid_object_router(); + +} /*namespace scm*/ +} /*namespace xo*/ + +namespace xo { namespace facet { + template + struct RoutingFor { + using RoutingType = xo::scm::RType; + }; +} } + +/* end RType.hpp */ diff --git a/include/xo/type/type_register_facets.hpp b/include/xo/type/type_register_facets.hpp new file mode 100644 index 00000000..f418eab5 --- /dev/null +++ b/include/xo/type/type_register_facets.hpp @@ -0,0 +1,15 @@ +/** @file type_register_facets.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +namespace xo { + namespace scm { + /** Register type (facet,impl) combinations with FacetRegistry **/ + bool type_register_facets(); + } +} + +/* end type_register_facets.hpp */ diff --git a/include/xo/type/type_register_types.hpp b/include/xo/type/type_register_types.hpp new file mode 100644 index 00000000..5ab1db0d --- /dev/null +++ b/include/xo/type/type_register_types.hpp @@ -0,0 +1,17 @@ +/** @file type_register_types.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + /** Register type (facet,impl) combinations with FacetRegistry **/ + bool type_register_types(obj gc); + } +} + +/* end type_register_types.hpp */ diff --git a/src/type/CMakeLists.txt b/src/type/CMakeLists.txt new file mode 100644 index 00000000..36f88958 --- /dev/null +++ b/src/type/CMakeLists.txt @@ -0,0 +1,25 @@ +# xo-type/src/type/CMakeLists.txt + +set(SELF_LIB xo_type) +set(SELF_SRCS + init_type.cpp + type_register_facets.cpp + type_register_types.cpp + Metatype.cpp + DAtomicType.cpp + IType_DAtomicType.cpp + IGCObject_DAtomicType.cpp +) + +xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) + +# ---------------------------------------------------------------- +# input dependencies +# +# NOTE: dependency set here must be kept consistent with +# xo-type/cmake/xo_typeConfig.cmake.in + +xo_dependency(${SELF_LIB} xo_alloc2) +xo_dependency(${SELF_LIB} xo_facet) + +# end src/type/CMakeLists.txt diff --git a/src/type/DAtomicType.cpp b/src/type/DAtomicType.cpp new file mode 100644 index 00000000..561e8777 --- /dev/null +++ b/src/type/DAtomicType.cpp @@ -0,0 +1,42 @@ +/** @file DAtomicType.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "AtomicType.hpp" + +namespace xo { + namespace scm { + + DAtomicType * + DAtomicType::_make(obj mm, Metatype mtype) + { + void * mem = mm.alloc_for(); + + return new (mem) DAtomicType(mtype); + } + + // ----- GCObject facet ----- + + std::size_t + DAtomicType::shallow_size() const noexcept + { + return sizeof(DAtomicType); + } + + DAtomicType * + DAtomicType::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DAtomicType::forward_children(obj) noexcept + { + return this->shallow_size(); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DAtomicType.cpp */ diff --git a/src/type/IGCObject_DAtomicType.cpp b/src/type/IGCObject_DAtomicType.cpp new file mode 100644 index 00000000..17f3a56a --- /dev/null +++ b/src/type/IGCObject_DAtomicType.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DAtomicType.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DAtomicType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DAtomicType.json5] +**/ + +#include "atomic/IGCObject_DAtomicType.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DAtomicType::shallow_size(const DAtomicType & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DAtomicType::shallow_copy(const DAtomicType & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DAtomicType::forward_children(DAtomicType & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DAtomicType.cpp */ diff --git a/src/type/IType_Any.cpp b/src/type/IType_Any.cpp new file mode 100644 index 00000000..bb9690fb --- /dev/null +++ b/src/type/IType_Any.cpp @@ -0,0 +1,42 @@ +/** @file IType_Any.cpp + * + **/ + +#include "type/IType_Any.hpp" +#include +#include + +namespace xo { +namespace scm { + +using xo::facet::DVariantPlaceholder; +using xo::facet::typeseq; +using xo::facet::valid_facet_implementation; + +void +IType_Any::_fatal() +{ + /* control here on uninitialized IAllocator_Any. + * Initialized instance will have specific implementation type + */ + std::cerr << "fatal" + << ": attempt to call uninitialized" + << " IType_Any method" + << std::endl; + std::terminate(); +} + +typeseq +IType_Any::s_typeseq = typeseq::id(); + +bool +IType_Any::_valid + = valid_facet_implementation(); + +// nonconst methods + + +} /*namespace scm*/ +} /*namespace xo*/ + +/* end IType_Any.cpp */ diff --git a/src/type/IType_DAtomicType.cpp b/src/type/IType_DAtomicType.cpp new file mode 100644 index 00000000..663653ad --- /dev/null +++ b/src/type/IType_DAtomicType.cpp @@ -0,0 +1,28 @@ +/** @file IType_DAtomicType.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DAtomicType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DAtomicType.json5] +**/ + +#include "atomic/IType_DAtomicType.hpp" + +namespace xo { + namespace scm { + auto + IType_DAtomicType::metatype(const DAtomicType & self) noexcept -> Metatype + { + return self.metatype(); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IType_DAtomicType.cpp */ diff --git a/src/type/Metatype.cpp b/src/type/Metatype.cpp new file mode 100644 index 00000000..acc82b67 --- /dev/null +++ b/src/type/Metatype.cpp @@ -0,0 +1,32 @@ +/** @file Metatype.cpp + * + * @author Roland Conybeare, Nar 2026 + **/ + +#include "Metatype.hpp" + +namespace xo { + namespace scm { + + const char * + Metatype::_descr() const noexcept + { + switch (code_) { + case code::t_any: return "any"; + case code::t_bool: return "bool"; + case code::t_i64: return "i64"; + case code::t_f64: return "f64"; + case code::t_str: return "str"; + case code::t_sum: return "sum"; + case code::t_list: return "list"; + case code::t_array: return "array"; + case code::t_function: return "function"; + case code::t_struct: return "struct"; + case code::t_unit: return "unit"; + } + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end Metatype.cpp */ diff --git a/src/type/init_type.cpp b/src/type/init_type.cpp new file mode 100644 index 00000000..bbae93d2 --- /dev/null +++ b/src/type/init_type.cpp @@ -0,0 +1,40 @@ +/** @file init_type.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_type.hpp" +#include "type_register_facets.hpp" +#include "type_register_types.hpp" +#include +#include + +namespace xo { + using xo::scm::type_register_facets; + using xo::scm::type_register_types; + using xo::mm::CollectorTypeRegistry; + + void + InitSubsys::init() + { + type_register_facets(); + + CollectorTypeRegistry::instance().register_types(&type_register_types); + } + + InitEvidence + InitSubsys::require() + { + InitEvidence retval; + + /* direct subsystem deps for xo-type/ */ + retval ^= InitSubsys::require(); + + /* xo-type/'s own initialization code */ + retval ^= Subsystem::provide("type", &init); + + return retval; + } +} /*namespace xo*/ + +/* end init_type.cpp */ diff --git a/src/type/type_register_facets.cpp b/src/type/type_register_facets.cpp new file mode 100644 index 00000000..6c7bd512 --- /dev/null +++ b/src/type/type_register_facets.cpp @@ -0,0 +1,35 @@ +/** @file type_register_facets.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "type_register_facets.hpp" + +#include +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::facet::FacetRegistry; + //using xo::facet::TypeRegistry; + using xo::reflect::typeseq; + + namespace scm { + + bool + type_register_facets() + { + scope log(XO_DEBUG(true)); + + FacetRegistry::register_impl(); + + log && log(xtag("DAtomicType.tseq", typeseq::id())); + + return true; + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end type_register_facets.cpp */ diff --git a/src/type/type_register_types.cpp b/src/type/type_register_types.cpp new file mode 100644 index 00000000..e5da5d1d --- /dev/null +++ b/src/type/type_register_types.cpp @@ -0,0 +1,34 @@ +/** @file type_register_types.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "type_register_types.hpp" + +#include "AtomicType.hpp" +#include +#include +#include + +namespace xo { + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::facet::impl_for; + using xo::scope; + + namespace scm { + bool + type_register_types(obj gc) + { + scope log(XO_DEBUG(true)); + + bool ok = true; + + ok &= gc.install_type(impl_for()); + + return ok; + } + } +} /*namespace xo*/ + +/* end type_register_types.cpp */ diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt new file mode 100644 index 00000000..ff79bda4 --- /dev/null +++ b/utest/CMakeLists.txt @@ -0,0 +1,16 @@ +# built unittest xo-type/utest + +set(UTEST_EXE utest.type) +set(UTEST_SRCS + type_utest_main.cpp + DAtomicType.test.cpp +# DString.test.cpp +# StringOps.test.cpp +# X1Collector.test.cpp +# Printable.test.cpp +) + +xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) +xo_self_dependency(${UTEST_EXE} xo_type) +#xo_dependency(${UTEST_EXE} xo_alloc2) +xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2) diff --git a/utest/DAtomicType.test.cpp b/utest/DAtomicType.test.cpp new file mode 100644 index 00000000..6ee26cee --- /dev/null +++ b/utest/DAtomicType.test.cpp @@ -0,0 +1,40 @@ +/** @file DAtomicType.test.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "init_type.hpp" +#include "AtomicType.hpp" +#include +#include +#include +#include + +namespace xo { + using xo::scm::AType; + using xo::scm::DAtomicType; + using xo::scm::Metatype; + using xo::mm::AAllocator; + using xo::mm::DArena; + using xo::mm::ArenaConfig; + + namespace ut { + static InitEvidence s_init = (InitSubsys::require()); + + TEST_CASE("DAtomicType-make", "[type][DAtomicType]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = obj(&arena); + + auto f64_type = obj(DAtomicType::_make(alloc, Metatype::unit())); + + REQUIRE(f64_type); + REQUIRE(f64_type.metatype().code() == Metatype::unit().code()); + } + + } /*namespace ut*/ +} /*namespace xo*/ + +/* end DAtomicType.test.cpp */ diff --git a/utest/type_utest_main.cpp b/utest/type_utest_main.cpp new file mode 100644 index 00000000..d4615d40 --- /dev/null +++ b/utest/type_utest_main.cpp @@ -0,0 +1,24 @@ +/* file type_utest_main.cpp */ + +#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 type_utest_main.cpp */ From deedc6c825f747604bd76c99215366330647b719 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 6 Mar 2026 13:11:45 +1100 Subject: [PATCH 02/31] nix build: + xo.type --- cmake/xo_typeConfig.cmake.in | 1 + src/type/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/cmake/xo_typeConfig.cmake.in b/cmake/xo_typeConfig.cmake.in index 2c4c0d1d..186f1817 100644 --- a/cmake/xo_typeConfig.cmake.in +++ b/cmake/xo_typeConfig.cmake.in @@ -3,6 +3,7 @@ include(CMakeFindDependencyMacro) find_dependency(xo_alloc2) find_dependency(xo_facet) +find_dependency(subsys) # note: changes to find_dependency() calls here # must coordinate with xo_dependency() calls diff --git a/src/type/CMakeLists.txt b/src/type/CMakeLists.txt index 36f88958..806e67a9 100644 --- a/src/type/CMakeLists.txt +++ b/src/type/CMakeLists.txt @@ -21,5 +21,6 @@ xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 $ xo_dependency(${SELF_LIB} xo_alloc2) xo_dependency(${SELF_LIB} xo_facet) +xo_dependency(${SELF_LIB} subsys) # end src/type/CMakeLists.txt From 0e3e0d875127eafaa7abeb8f238c9b73fa182c8e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 7 Mar 2026 00:01:57 +1100 Subject: [PATCH 03/31] xo-type: + gcobject facet + DListType --- CMakeLists.txt | 20 +++++ idl/IGCObject_DListType.json5 | 16 ++++ idl/IType_DListType.json5 | 16 ++++ idl/Type.json5 | 19 +++- include/xo/type/DAtomicType.hpp | 7 +- include/xo/type/DListType.hpp | 63 ++++++++++++++ include/xo/type/ListType.hpp | 12 +++ include/xo/type/Metatype.hpp | 22 +++++ include/xo/type/TypeOps.hpp | 31 +++++++ include/xo/type/atomic/IType_DAtomicType.hpp | 4 + include/xo/type/list/IGCObject_DListType.hpp | 65 ++++++++++++++ include/xo/type/list/IType_DListType.hpp | 63 ++++++++++++++ include/xo/type/type/AType.hpp | 4 + include/xo/type/type/IType_Any.hpp | 2 + include/xo/type/type/IType_Xfer.hpp | 6 ++ include/xo/type/type/RType.hpp | 6 ++ src/type/CMakeLists.txt | 5 ++ src/type/DAtomicType.cpp | 20 +++++ src/type/DListType.cpp | 92 ++++++++++++++++++++ src/type/IGCObject_DListType.cpp | 39 +++++++++ src/type/IType_DAtomicType.cpp | 12 +++ src/type/IType_DListType.cpp | 40 +++++++++ src/type/Metatype.cpp | 29 ++++++ src/type/TypeOps.cpp | 15 ++++ src/type/type_register_facets.cpp | 7 +- src/type/type_register_types.cpp | 2 + utest/CMakeLists.txt | 1 + utest/DAtomicType.test.cpp | 72 ++++++++++++++- utest/DListType.test.cpp | 65 ++++++++++++++ 29 files changed, 749 insertions(+), 6 deletions(-) create mode 100644 idl/IGCObject_DListType.json5 create mode 100644 idl/IType_DListType.json5 create mode 100644 include/xo/type/DListType.hpp create mode 100644 include/xo/type/ListType.hpp create mode 100644 include/xo/type/TypeOps.hpp create mode 100644 include/xo/type/list/IGCObject_DListType.hpp create mode 100644 include/xo/type/list/IType_DListType.hpp create mode 100644 src/type/DListType.cpp create mode 100644 src/type/IGCObject_DListType.cpp create mode 100644 src/type/IType_DListType.cpp create mode 100644 src/type/TypeOps.cpp create mode 100644 utest/DListType.test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e11f53b1..b1ea2905 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,26 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-type-facetimpl-type-listtype + FACET_PKG xo_type + FACET Type + REPR ListType + INPUT idl/IType_DListType.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-type-facetimpl-gcobject-listtype + FACET_PKG xo_alloc2 + FACET GCObject + REPR ListType + INPUT idl/IGCObject_DListType.json5 +) + +# ---------------------------------------------------------------- + xo_add_genfacet_all(xo-type-genfacet-all) install(DIRECTORY idl/ diff --git a/idl/IGCObject_DListType.json5 b/idl/IGCObject_DListType.json5 new file mode 100644 index 00000000..1f4c00ea --- /dev/null +++ b/idl/IGCObject_DListType.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "list", + includes: [ + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DListType", + using_doxygen: true, + repr: "DListType", + doc: [ "implement AGCObject for DListType" ], +} diff --git a/idl/IType_DListType.json5 b/idl/IType_DListType.json5 new file mode 100644 index 00000000..0cd59785 --- /dev/null +++ b/idl/IType_DListType.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "list", + includes: [], + local_types: [], + namespace1: "xo", + namespace2: "scm", + + facet_idl: "idl/Type.json5", + brief: "provide AType interface for DListType", + using_doxygen: true, + repr: "DListType", + doc: [ "implement AType for DListType" ], +} diff --git a/idl/Type.json5 b/idl/Type.json5 index eeb22334..1ddac826 100644 --- a/idl/Type.json5 +++ b/idl/Type.json5 @@ -37,6 +37,22 @@ const: true, noexcept: true, }, + { + name: "is_equal_to", + doc: ["true iff this type is equal to y"], + return_type: "bool", + args: [ + {type: "const obj_AType &", name: "y"}, + ] + }, + { + name: "is_subtype_of", + doc: ["true iff this is a subtype of y"], + return_type: "bool", + args: [ + {type: "const obj_AType &", name: "y"}, + ] + }, // TODO: define methods, e.g.: // { @@ -49,5 +65,6 @@ // }, ], nonconst_methods: [], - router_facet_explicit_content: [], + router_facet_explicit_content: [ + ], } diff --git a/include/xo/type/DAtomicType.hpp b/include/xo/type/DAtomicType.hpp index 253b678b..074e0c64 100644 --- a/include/xo/type/DAtomicType.hpp +++ b/include/xo/type/DAtomicType.hpp @@ -5,6 +5,7 @@ #pragma once +#include "Type.hpp" #include "Metatype.hpp" #include #include @@ -29,8 +30,12 @@ namespace xo { /** create instance using memory from @p mm with metatype @p mtype **/ static DAtomicType * _make(obj mm, Metatype mtype); + /** @defgroup xo-scm-atomictype-type-facet **/ + ///@{ Metatype metatype() const noexcept { return metatype_; } - + bool is_equal_to(const obj & y) const noexcept; + bool is_subtype_of(const obj & y) const noexcept; + ///@} /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; diff --git a/include/xo/type/DListType.hpp b/include/xo/type/DListType.hpp new file mode 100644 index 00000000..41808ce6 --- /dev/null +++ b/include/xo/type/DListType.hpp @@ -0,0 +1,63 @@ +/** @file DListType.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "Type.hpp" +#include "Metatype.hpp" +#include +#include + +namespace xo { + namespace scm { + /** @brief An atomic schematika type + * + * Types that are not parameterized by types or values. + * For example + * unit, bool, i64, f64 + * are atomic in this sense. + **/ + class DListType { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + + public: + /** @defgroup xo-scm-listtype-ctors **/ + ///@{ + + explicit DListType(obj elt); + + /** create instance using memory from @p mm with metatype @p mtype **/ + static DListType * _make(obj mm, obj elt_type); + + ///@} + /** @defgroup xo-scm-listtype-type-facet **/ + ///@{ + Metatype metatype() const noexcept { return Metatype::list(); } + bool is_equal_to(const obj & y) const noexcept; + bool is_subtype_of(const obj & y) const noexcept; + ///@} + /** @defgroup xo-scm-listtype-gcobject-facet **/ + ///@{ + std::size_t shallow_size() const noexcept; + DListType * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} + + private: + /** @defgroup xo-scm-listtype-member-vars **/ + ///@{ + + /** all list elements satisfy @ref elt_type_ **/ + obj elt_type_; + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DListType.hpp */ diff --git a/include/xo/type/ListType.hpp b/include/xo/type/ListType.hpp new file mode 100644 index 00000000..3b573792 --- /dev/null +++ b/include/xo/type/ListType.hpp @@ -0,0 +1,12 @@ +/** @file ListType.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "DListType.hpp" +#include "list/IType_DListType.hpp" +#include "list/IGCObject_DListType.hpp" + +/* end ListType.hpp */ diff --git a/include/xo/type/Metatype.hpp b/include/xo/type/Metatype.hpp index 813b1446..2d7b2a5d 100644 --- a/include/xo/type/Metatype.hpp +++ b/include/xo/type/Metatype.hpp @@ -39,16 +39,38 @@ namespace xo { explicit Metatype(code x) : code_{x} {} static Metatype unit() { return Metatype(code::t_unit); } + static Metatype t_bool() { return Metatype(code::t_bool); } + static Metatype i64() { return Metatype(code::t_i64); } + static Metatype f64() { return Metatype(code::t_f64); } + static Metatype str() { return Metatype(code::t_str); } + static Metatype any() { return Metatype(code::t_any); } + + static Metatype list() { return Metatype(code::t_list); } /** description string for this type category **/ const char * _descr() const noexcept; code code() const noexcept { return code_; } + /** true iff this metatype is non-parametric: + * i.e. stands for a single type + **/ + bool is_atomic() const noexcept; + private: enum code code_; }; + inline bool + operator==(Metatype x, Metatype y) { + return (x.code() == y.code()); + } + + inline bool + operator!=(Metatype x, Metatype y) { + return (x.code() != y.code()); + } + inline std::ostream & operator<<(std::ostream & os, Metatype x) { os << x._descr(); diff --git a/include/xo/type/TypeOps.hpp b/include/xo/type/TypeOps.hpp new file mode 100644 index 00000000..b31fa039 --- /dev/null +++ b/include/xo/type/TypeOps.hpp @@ -0,0 +1,31 @@ +/** @file TypeOps.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "AtomicType.hpp" +#include "ListType.hpp" +#include + +namespace xo { + namespace scm { + class TypeOps { + public: + using AAllocator = xo::mm::AAllocator; + + template + static obj atomic_type(obj mm, Metatype metatype) { + assert(metatype.is_atomic()); + return obj(DAtomicType::_make(mm, metatype)); + } + + template + static obj list_type(obj mm, obj elt_type) { + return obj(DListType::_make(mm, elt_type)); + } + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end TypeOps.hpp */ diff --git a/include/xo/type/atomic/IType_DAtomicType.hpp b/include/xo/type/atomic/IType_DAtomicType.hpp index 8a351cf9..fc73539f 100644 --- a/include/xo/type/atomic/IType_DAtomicType.hpp +++ b/include/xo/type/atomic/IType_DAtomicType.hpp @@ -48,6 +48,10 @@ namespace xo { // const methods /** category for this type **/ static Metatype metatype(const DAtomicType & self) noexcept; + /** true iff this type is equal to y **/ + static bool is_equal_to(const DAtomicType & self, const obj_AType & y); + /** true iff this is a subtype of y **/ + static bool is_subtype_of(const DAtomicType & self, const obj_AType & y); // non-const methods ///@} diff --git a/include/xo/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp new file mode 100644 index 00000000..6393d35b --- /dev/null +++ b/include/xo/type/list/IGCObject_DListType.hpp @@ -0,0 +1,65 @@ +/** @file IGCObject_DListType.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DListType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DListType.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include "DListType.hpp" + +namespace xo { namespace scm { class IGCObject_DListType; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DListType + **/ + class IGCObject_DListType { + public: + /** @defgroup scm-gcobject-dlisttype-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-dlisttype-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DListType & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DListType & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DListType & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/type/list/IType_DListType.hpp b/include/xo/type/list/IType_DListType.hpp new file mode 100644 index 00000000..546b9cbe --- /dev/null +++ b/include/xo/type/list/IType_DListType.hpp @@ -0,0 +1,63 @@ +/** @file IType_DListType.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DListType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DListType.json5] + **/ + +#pragma once + +#include "Type.hpp" +#include "DListType.hpp" + +namespace xo { namespace scm { class IType_DListType; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IType_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IType_DListType + **/ + class IType_DListType { + public: + /** @defgroup scm-type-dlisttype-type-traits **/ + ///@{ + using obj_AType = xo::scm::AType::obj_AType; + using Copaque = xo::scm::AType::Copaque; + using Opaque = xo::scm::AType::Opaque; + ///@} + /** @defgroup scm-type-dlisttype-methods **/ + ///@{ + // const methods + /** category for this type **/ + static Metatype metatype(const DListType & self) noexcept; + /** true iff this type is equal to y **/ + static bool is_equal_to(const DListType & self, const obj_AType & y); + /** true iff this is a subtype of y **/ + static bool is_subtype_of(const DListType & self, const obj_AType & y); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/type/type/AType.hpp b/include/xo/type/type/AType.hpp index 50389fe7..dde14805 100644 --- a/include/xo/type/type/AType.hpp +++ b/include/xo/type/type/AType.hpp @@ -53,6 +53,10 @@ public: virtual void _drop(Opaque d) const noexcept = 0; /** category for this type **/ virtual Metatype metatype(Copaque data) const noexcept = 0; + /** true iff this type is equal to y **/ + virtual bool is_equal_to(Copaque data, const obj_AType & y) = 0; + /** true iff this is a subtype of y **/ + virtual bool is_subtype_of(Copaque data, const obj_AType & y) = 0; // nonconst methods ///@} diff --git a/include/xo/type/type/IType_Any.hpp b/include/xo/type/type/IType_Any.hpp index 6db13097..b8bdb58c 100644 --- a/include/xo/type/type/IType_Any.hpp +++ b/include/xo/type/type/IType_Any.hpp @@ -60,6 +60,8 @@ namespace scm { // const methods [[noreturn]] Metatype metatype(Copaque) const noexcept override { _fatal(); } + [[noreturn]] bool is_equal_to(Copaque, const obj_AType &) override { _fatal(); } + [[noreturn]] bool is_subtype_of(Copaque, const obj_AType &) override { _fatal(); } // nonconst methods diff --git a/include/xo/type/type/IType_Xfer.hpp b/include/xo/type/type/IType_Xfer.hpp index ead6c45e..98b138c7 100644 --- a/include/xo/type/type/IType_Xfer.hpp +++ b/include/xo/type/type/IType_Xfer.hpp @@ -47,6 +47,12 @@ namespace scm { Metatype metatype(Copaque data) const noexcept override { return I::metatype(_dcast(data)); } + bool is_equal_to(Copaque data, const obj_AType & y) override { + return I::is_equal_to(_dcast(data), y); + } + bool is_subtype_of(Copaque data, const obj_AType & y) override { + return I::is_subtype_of(_dcast(data), y); + } // non-const methods diff --git a/include/xo/type/type/RType.hpp b/include/xo/type/type/RType.hpp index a6376fe0..853745ed 100644 --- a/include/xo/type/type/RType.hpp +++ b/include/xo/type/type/RType.hpp @@ -56,6 +56,12 @@ public: Metatype metatype() const noexcept { return O::iface()->metatype(O::data()); } + bool is_equal_to(const obj_AType & y) { + return O::iface()->is_equal_to(O::data(), y); + } + bool is_subtype_of(const obj_AType & y) { + return O::iface()->is_subtype_of(O::data(), y); + } // non-const methods (still const in router!) diff --git a/src/type/CMakeLists.txt b/src/type/CMakeLists.txt index 806e67a9..7f708fb4 100644 --- a/src/type/CMakeLists.txt +++ b/src/type/CMakeLists.txt @@ -5,10 +5,15 @@ set(SELF_SRCS init_type.cpp type_register_facets.cpp type_register_types.cpp + TypeOps.cpp Metatype.cpp DAtomicType.cpp + DListType.cpp + IType_Any.cpp IType_DAtomicType.cpp + IType_DListType.cpp IGCObject_DAtomicType.cpp + IGCObject_DListType.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/type/DAtomicType.cpp b/src/type/DAtomicType.cpp index 561e8777..18c64c81 100644 --- a/src/type/DAtomicType.cpp +++ b/src/type/DAtomicType.cpp @@ -16,6 +16,26 @@ namespace xo { return new (mem) DAtomicType(mtype); } + // ----- Type facet ----- + + bool + DAtomicType::is_equal_to(const obj & y) const noexcept + { + return (metatype_.code() == y.metatype().code()); + } + + bool + DAtomicType::is_subtype_of(const obj & y) const noexcept + { + Metatype x_mtype = metatype_; + Metatype y_mtype = y.metatype(); + + if (y_mtype.code() == Metatype::code::t_any) + return true; + + return (x_mtype.code() == y_mtype.code()); + } + // ----- GCObject facet ----- std::size_t diff --git a/src/type/DListType.cpp b/src/type/DListType.cpp new file mode 100644 index 00000000..4be59a36 --- /dev/null +++ b/src/type/DListType.cpp @@ -0,0 +1,92 @@ +/** @file DListType.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "Type.hpp" +#include "ListType.hpp" +#include +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::mm::AAllocator; + using xo::facet::FacetRegistry; + + namespace scm { + + DListType::DListType(obj elt) : elt_type_{elt} {} + + DListType * + DListType::_make(obj mm, + obj elt_type) + { + void * mem = mm.alloc_for(); + + return new (mem) DListType(elt_type); + } + + // ----- type facet ----- + + bool + DListType::is_equal_to(const obj & y_arg) const noexcept + { + Metatype y_mtype = y_arg.metatype(); + + if (y_mtype != Metatype::list()) + return false; + + auto y = obj::from(y_arg); + + obj e = elt_type_; + + return (e.is_equal_to(y->elt_type_)); + } + + bool + DListType::is_subtype_of(const obj & y_arg) const noexcept + { + Metatype y_mtype = y_arg.metatype(); + + if (y_mtype == Metatype::any()) + return true; + + if (y_mtype != Metatype::list()) + return false; + + auto y = obj::from(y_arg); + + obj e = elt_type_; + + return (e.is_subtype_of(y->elt_type_)); + } + + // ----- gcobject facet ----- + + std::size_t + DListType::shallow_size() const noexcept + { + return sizeof(*this); + } + + DListType * + DListType::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DListType::forward_children(obj gc) noexcept + { + { + auto e = FacetRegistry::instance().variant(elt_type_); + gc.forward_inplace(e.iface(), (void **)&(e.data_)); + } + + return this->shallow_size(); + } + } +} + +/* end DListType.cpp */ diff --git a/src/type/IGCObject_DListType.cpp b/src/type/IGCObject_DListType.cpp new file mode 100644 index 00000000..761ae617 --- /dev/null +++ b/src/type/IGCObject_DListType.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DListType.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DListType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DListType.json5] +**/ + +#include "list/IGCObject_DListType.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DListType::shallow_size(const DListType & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DListType::shallow_copy(const DListType & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DListType::forward_children(DListType & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DListType.cpp */ diff --git a/src/type/IType_DAtomicType.cpp b/src/type/IType_DAtomicType.cpp index 663653ad..65fcb023 100644 --- a/src/type/IType_DAtomicType.cpp +++ b/src/type/IType_DAtomicType.cpp @@ -21,6 +21,18 @@ namespace xo { return self.metatype(); } + auto + IType_DAtomicType::is_equal_to(const DAtomicType & self, const obj_AType & y) -> bool + { + return self.is_equal_to(y); + } + + auto + IType_DAtomicType::is_subtype_of(const DAtomicType & self, const obj_AType & y) -> bool + { + return self.is_subtype_of(y); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/type/IType_DListType.cpp b/src/type/IType_DListType.cpp new file mode 100644 index 00000000..a29e3d74 --- /dev/null +++ b/src/type/IType_DListType.cpp @@ -0,0 +1,40 @@ +/** @file IType_DListType.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DListType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DListType.json5] +**/ + +#include "list/IType_DListType.hpp" + +namespace xo { + namespace scm { + auto + IType_DListType::metatype(const DListType & self) noexcept -> Metatype + { + return self.metatype(); + } + + auto + IType_DListType::is_equal_to(const DListType & self, const obj_AType & y) -> bool + { + return self.is_equal_to(y); + } + + auto + IType_DListType::is_subtype_of(const DListType & self, const obj_AType & y) -> bool + { + return self.is_subtype_of(y); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IType_DListType.cpp */ diff --git a/src/type/Metatype.cpp b/src/type/Metatype.cpp index acc82b67..aa97fdcc 100644 --- a/src/type/Metatype.cpp +++ b/src/type/Metatype.cpp @@ -26,6 +26,35 @@ namespace xo { } } + bool + Metatype::is_atomic() const noexcept + { + switch (code_) { + case code::t_any: + return true; + case code::t_bool: + return true; + case code::t_i64: + return true; + case code::t_f64: + return true; + case code::t_str: + return true; + case code::t_sum: + return false; + case code::t_list: + return false; + case code::t_array: + return false; + case code::t_function: + return false; + case code::t_struct: + return false; + case code::t_unit: + return false; + } + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/type/TypeOps.cpp b/src/type/TypeOps.cpp new file mode 100644 index 00000000..f344fb5b --- /dev/null +++ b/src/type/TypeOps.cpp @@ -0,0 +1,15 @@ +/** @file TypeOps.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "TypeOps.hpp" + +namespace xo { + namespace scm { + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end TypeOps.cpp */ diff --git a/src/type/type_register_facets.cpp b/src/type/type_register_facets.cpp index 6c7bd512..549633cd 100644 --- a/src/type/type_register_facets.cpp +++ b/src/type/type_register_facets.cpp @@ -6,13 +6,13 @@ #include "type_register_facets.hpp" #include +#include #include #include namespace xo { using xo::mm::AGCObject; using xo::facet::FacetRegistry; - //using xo::facet::TypeRegistry; using xo::reflect::typeseq; namespace scm { @@ -22,9 +22,14 @@ namespace xo { { scope log(XO_DEBUG(true)); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DAtomicType.tseq", typeseq::id())); + log && log(xtag("DListType.tseq", typeseq::id())); return true; } diff --git a/src/type/type_register_types.cpp b/src/type/type_register_types.cpp index e5da5d1d..8e2cdda6 100644 --- a/src/type/type_register_types.cpp +++ b/src/type/type_register_types.cpp @@ -6,6 +6,7 @@ #include "type_register_types.hpp" #include "AtomicType.hpp" +#include "ListType.hpp" #include #include #include @@ -25,6 +26,7 @@ namespace xo { bool ok = true; ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); return ok; } diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index ff79bda4..cc18708a 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -4,6 +4,7 @@ set(UTEST_EXE utest.type) set(UTEST_SRCS type_utest_main.cpp DAtomicType.test.cpp + DListType.test.cpp # DString.test.cpp # StringOps.test.cpp # X1Collector.test.cpp diff --git a/utest/DAtomicType.test.cpp b/utest/DAtomicType.test.cpp index 6ee26cee..9bab45d0 100644 --- a/utest/DAtomicType.test.cpp +++ b/utest/DAtomicType.test.cpp @@ -28,10 +28,76 @@ namespace xo { DArena arena = DArena::map(cfg); auto alloc = obj(&arena); - auto f64_type = obj(DAtomicType::_make(alloc, Metatype::unit())); + auto unit_type = obj(DAtomicType::_make(alloc, Metatype::unit())); + auto i64_type = obj(DAtomicType::_make(alloc, Metatype::i64())); + auto f64_type = obj(DAtomicType::_make(alloc, Metatype::f64())); + auto str_type = obj(DAtomicType::_make(alloc, Metatype::str())); + auto any_type = obj(DAtomicType::_make(alloc, Metatype::any())); + { + REQUIRE(unit_type); + REQUIRE(unit_type.metatype().code() == Metatype::unit().code()); - REQUIRE(f64_type); - REQUIRE(f64_type.metatype().code() == Metatype::unit().code()); + REQUIRE(unit_type.is_equal_to(unit_type)); + REQUIRE(unit_type.is_subtype_of(unit_type)); + } + + { + REQUIRE(i64_type); + REQUIRE(i64_type.metatype().code() == Metatype::i64().code()); + + REQUIRE(i64_type.is_equal_to(i64_type)); + REQUIRE(i64_type.is_subtype_of(i64_type)); + + REQUIRE(!i64_type.is_subtype_of(unit_type)); + REQUIRE(!unit_type.is_subtype_of(i64_type)); + } + + { + REQUIRE(f64_type); + REQUIRE(f64_type.metatype().code() == Metatype::f64().code()); + + REQUIRE(f64_type.is_equal_to(f64_type)); + REQUIRE(f64_type.is_subtype_of(f64_type)); + + REQUIRE(!f64_type.is_subtype_of(unit_type)); + REQUIRE(!f64_type.is_subtype_of(i64_type)); + REQUIRE(!unit_type.is_subtype_of(f64_type)); + REQUIRE(!i64_type.is_subtype_of(f64_type)); + } + + { + REQUIRE(str_type); + REQUIRE(str_type.metatype().code() == Metatype::str().code()); + + REQUIRE(str_type.is_equal_to(str_type)); + REQUIRE(str_type.is_subtype_of(str_type)); + + REQUIRE(!str_type.is_subtype_of(unit_type)); + REQUIRE(!str_type.is_subtype_of(i64_type)); + REQUIRE(!str_type.is_subtype_of(f64_type)); + + REQUIRE(!unit_type.is_subtype_of(str_type)); + REQUIRE(!i64_type.is_subtype_of(str_type)); + REQUIRE(!f64_type.is_subtype_of(str_type)); + } + + { + REQUIRE(any_type); + REQUIRE(any_type.metatype().code() == Metatype::any().code()); + + REQUIRE(any_type.is_equal_to(any_type)); + REQUIRE(any_type.is_subtype_of(any_type)); + + REQUIRE(!any_type.is_subtype_of(unit_type)); + REQUIRE(!any_type.is_subtype_of(i64_type)); + REQUIRE(!any_type.is_subtype_of(f64_type)); + REQUIRE(!any_type.is_subtype_of(str_type)); + + REQUIRE(unit_type.is_subtype_of(any_type)); + REQUIRE(i64_type.is_subtype_of(any_type)); + REQUIRE(f64_type.is_subtype_of(any_type)); + REQUIRE(str_type.is_subtype_of(any_type)); + } } } /*namespace ut*/ diff --git a/utest/DListType.test.cpp b/utest/DListType.test.cpp new file mode 100644 index 00000000..fed5d916 --- /dev/null +++ b/utest/DListType.test.cpp @@ -0,0 +1,65 @@ +/** @file DListType.test.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "init_type.hpp" +#include "TypeOps.hpp" +#include "ListType.hpp" +#include "AtomicType.hpp" +#include +#include +#include +#include + +namespace xo { + using xo::scm::TypeOps; + using xo::scm::AType; + //using xo::scm::DListType; + //using xo::scm::DAtomicType; + using xo::scm::Metatype; + using xo::mm::AAllocator; + using xo::mm::DArena; + using xo::mm::ArenaConfig; + + namespace ut { + static InitEvidence s_init = (InitSubsys::require()); + + TEST_CASE("DListType-make", "[type][DListType]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = obj(&arena); + + auto i64_type = TypeOps::atomic_type(alloc, Metatype::i64()); + auto list_i64_type = TypeOps::list_type(alloc, i64_type); + + REQUIRE(list_i64_type); + REQUIRE(list_i64_type.is_equal_to(list_i64_type)); + + auto bool_type = TypeOps::atomic_type(alloc, Metatype::t_bool()); + auto list_bool_type = TypeOps::list_type(alloc, bool_type); + + REQUIRE(list_bool_type); + REQUIRE(list_bool_type.is_equal_to(list_bool_type)); + + auto any_type = TypeOps::atomic_type(alloc, Metatype::any()); + auto list_any_type = TypeOps::list_type(alloc, any_type); + + REQUIRE(list_any_type); + REQUIRE(list_any_type.is_equal_to(list_any_type)); + + REQUIRE(list_bool_type.is_subtype_of(list_any_type)); + REQUIRE(list_i64_type.is_subtype_of(list_any_type)); + + REQUIRE(!list_i64_type.is_subtype_of(list_bool_type)); + REQUIRE(!list_any_type.is_subtype_of(list_bool_type)); + REQUIRE(!list_bool_type.is_subtype_of(list_i64_type)); + REQUIRE(!list_any_type.is_subtype_of(list_i64_type)); + } + } +} + + +/* end DListType.cpp */ From 553e7c0151593554d5018d8001af292f2001e67d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 7 Mar 2026 00:25:55 +1100 Subject: [PATCH 04/31] xo-type: + DArrayType --- CMakeLists.txt | 20 ++++ idl/IGCObject_DArrayType.json5 | 16 ++++ idl/IType_DArrayType.json5 | 16 ++++ include/xo/type/ArrayType.hpp | 12 +++ include/xo/type/DArrayType.hpp | 60 ++++++++++++ include/xo/type/Metatype.hpp | 1 + include/xo/type/TypeOps.hpp | 6 ++ .../xo/type/array/IGCObject_DArrayType.hpp | 65 +++++++++++++ include/xo/type/array/IType_DArrayType.hpp | 63 +++++++++++++ src/type/CMakeLists.txt | 3 + src/type/DArrayType.cpp | 92 +++++++++++++++++++ src/type/IGCObject_DArrayType.cpp | 39 ++++++++ src/type/IType_DArrayType.cpp | 40 ++++++++ src/type/type_register_facets.cpp | 5 + src/type/type_register_types.cpp | 2 + utest/CMakeLists.txt | 1 + utest/DArrayType.test.cpp | 70 ++++++++++++++ 17 files changed, 511 insertions(+) create mode 100644 idl/IGCObject_DArrayType.json5 create mode 100644 idl/IType_DArrayType.json5 create mode 100644 include/xo/type/ArrayType.hpp create mode 100644 include/xo/type/DArrayType.hpp create mode 100644 include/xo/type/array/IGCObject_DArrayType.hpp create mode 100644 include/xo/type/array/IType_DArrayType.hpp create mode 100644 src/type/DArrayType.cpp create mode 100644 src/type/IGCObject_DArrayType.cpp create mode 100644 src/type/IType_DArrayType.cpp create mode 100644 utest/DArrayType.test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b1ea2905..7a318537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,26 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-type-facetimpl-type-arraytype + FACET_PKG xo_type + FACET Type + REPR ArrayType + INPUT idl/IType_DArrayType.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-type-facetimpl-gcobject-arraytype + FACET_PKG xo_alloc2 + FACET GCObject + REPR ArrayType + INPUT idl/IGCObject_DArrayType.json5 +) + +# ---------------------------------------------------------------- + xo_add_genfacet_all(xo-type-genfacet-all) install(DIRECTORY idl/ diff --git a/idl/IGCObject_DArrayType.json5 b/idl/IGCObject_DArrayType.json5 new file mode 100644 index 00000000..77e59249 --- /dev/null +++ b/idl/IGCObject_DArrayType.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "array", + includes: [ + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DArrayType", + using_doxygen: true, + repr: "DArrayType", + doc: [ "implement AGCObject for DArrayType" ], +} diff --git a/idl/IType_DArrayType.json5 b/idl/IType_DArrayType.json5 new file mode 100644 index 00000000..b84ab477 --- /dev/null +++ b/idl/IType_DArrayType.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "array", + includes: [], + local_types: [], + namespace1: "xo", + namespace2: "scm", + + facet_idl: "idl/Type.json5", + brief: "provide AType interface for DArrayType", + using_doxygen: true, + repr: "DArrayType", + doc: [ "implement AType for DArrayType" ], +} diff --git a/include/xo/type/ArrayType.hpp b/include/xo/type/ArrayType.hpp new file mode 100644 index 00000000..f0c5aa7a --- /dev/null +++ b/include/xo/type/ArrayType.hpp @@ -0,0 +1,12 @@ +/** @file ArrayType.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "DArrayType.hpp" +#include "array/IType_DArrayType.hpp" +#include "array/IGCObject_DArrayType.hpp" + +/* end ArrayType.hpp */ diff --git a/include/xo/type/DArrayType.hpp b/include/xo/type/DArrayType.hpp new file mode 100644 index 00000000..945f7f0a --- /dev/null +++ b/include/xo/type/DArrayType.hpp @@ -0,0 +1,60 @@ +/** @file DArrayType.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "Type.hpp" +#include "Metatype.hpp" +#include +#include + +namespace xo { + namespace scm { + /** @brief A parameterized array type: array(T) + * + * Represents a fixed-size homogeneous collection. + **/ + class DArrayType { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + + public: + /** @defgroup xo-scm-arraytype-ctors **/ + ///@{ + + explicit DArrayType(obj elt); + + /** create instance using memory from @p mm with element type @p elt_type **/ + static DArrayType * _make(obj mm, obj elt_type); + + ///@} + /** @defgroup xo-scm-arraytype-type-facet **/ + ///@{ + Metatype metatype() const noexcept { return Metatype::array(); } + bool is_equal_to(const obj & y) const noexcept; + bool is_subtype_of(const obj & y) const noexcept; + ///@} + /** @defgroup xo-scm-arraytype-gcobject-facet **/ + ///@{ + std::size_t shallow_size() const noexcept; + DArrayType * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} + + private: + /** @defgroup xo-scm-arraytype-member-vars **/ + ///@{ + + /** all array elements satisfy @ref elt_type_ **/ + obj elt_type_; + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DArrayType.hpp */ diff --git a/include/xo/type/Metatype.hpp b/include/xo/type/Metatype.hpp index 2d7b2a5d..e1119801 100644 --- a/include/xo/type/Metatype.hpp +++ b/include/xo/type/Metatype.hpp @@ -46,6 +46,7 @@ namespace xo { static Metatype any() { return Metatype(code::t_any); } static Metatype list() { return Metatype(code::t_list); } + static Metatype array() { return Metatype(code::t_array); } /** description string for this type category **/ const char * _descr() const noexcept; diff --git a/include/xo/type/TypeOps.hpp b/include/xo/type/TypeOps.hpp index b31fa039..8877ae8d 100644 --- a/include/xo/type/TypeOps.hpp +++ b/include/xo/type/TypeOps.hpp @@ -5,6 +5,7 @@ #include "AtomicType.hpp" #include "ListType.hpp" +#include "ArrayType.hpp" #include namespace xo { @@ -23,6 +24,11 @@ namespace xo { static obj list_type(obj mm, obj elt_type) { return obj(DListType::_make(mm, elt_type)); } + + template + static obj array_type(obj mm, obj elt_type) { + return obj(DArrayType::_make(mm, elt_type)); + } }; } /*namespace scm*/ diff --git a/include/xo/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp new file mode 100644 index 00000000..bb71960f --- /dev/null +++ b/include/xo/type/array/IGCObject_DArrayType.hpp @@ -0,0 +1,65 @@ +/** @file IGCObject_DArrayType.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DArrayType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DArrayType.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include "DArrayType.hpp" + +namespace xo { namespace scm { class IGCObject_DArrayType; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DArrayType + **/ + class IGCObject_DArrayType { + public: + /** @defgroup scm-gcobject-darraytype-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-darraytype-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DArrayType & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DArrayType & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DArrayType & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/type/array/IType_DArrayType.hpp b/include/xo/type/array/IType_DArrayType.hpp new file mode 100644 index 00000000..e323931b --- /dev/null +++ b/include/xo/type/array/IType_DArrayType.hpp @@ -0,0 +1,63 @@ +/** @file IType_DArrayType.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DArrayType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DArrayType.json5] + **/ + +#pragma once + +#include "Type.hpp" +#include "DArrayType.hpp" + +namespace xo { namespace scm { class IType_DArrayType; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IType_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IType_DArrayType + **/ + class IType_DArrayType { + public: + /** @defgroup scm-type-darraytype-type-traits **/ + ///@{ + using obj_AType = xo::scm::AType::obj_AType; + using Copaque = xo::scm::AType::Copaque; + using Opaque = xo::scm::AType::Opaque; + ///@} + /** @defgroup scm-type-darraytype-methods **/ + ///@{ + // const methods + /** category for this type **/ + static Metatype metatype(const DArrayType & self) noexcept; + /** true iff this type is equal to y **/ + static bool is_equal_to(const DArrayType & self, const obj_AType & y); + /** true iff this is a subtype of y **/ + static bool is_subtype_of(const DArrayType & self, const obj_AType & y); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/type/CMakeLists.txt b/src/type/CMakeLists.txt index 7f708fb4..d00c30bf 100644 --- a/src/type/CMakeLists.txt +++ b/src/type/CMakeLists.txt @@ -9,11 +9,14 @@ set(SELF_SRCS Metatype.cpp DAtomicType.cpp DListType.cpp + DArrayType.cpp IType_Any.cpp IType_DAtomicType.cpp IType_DListType.cpp + IType_DArrayType.cpp IGCObject_DAtomicType.cpp IGCObject_DListType.cpp + IGCObject_DArrayType.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/type/DArrayType.cpp b/src/type/DArrayType.cpp new file mode 100644 index 00000000..de5320e2 --- /dev/null +++ b/src/type/DArrayType.cpp @@ -0,0 +1,92 @@ +/** @file DArrayType.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "Type.hpp" +#include "ArrayType.hpp" +#include +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::mm::AAllocator; + using xo::facet::FacetRegistry; + + namespace scm { + + DArrayType::DArrayType(obj elt) : elt_type_{elt} {} + + DArrayType * + DArrayType::_make(obj mm, + obj elt_type) + { + void * mem = mm.alloc_for(); + + return new (mem) DArrayType(elt_type); + } + + // ----- type facet ----- + + bool + DArrayType::is_equal_to(const obj & y_arg) const noexcept + { + Metatype y_mtype = y_arg.metatype(); + + if (y_mtype != Metatype::array()) + return false; + + auto y = obj::from(y_arg); + + obj e = elt_type_; + + return (e.is_equal_to(y->elt_type_)); + } + + bool + DArrayType::is_subtype_of(const obj & y_arg) const noexcept + { + Metatype y_mtype = y_arg.metatype(); + + if (y_mtype == Metatype::any()) + return true; + + if (y_mtype != Metatype::array()) + return false; + + auto y = obj::from(y_arg); + + obj e = elt_type_; + + return (e.is_subtype_of(y->elt_type_)); + } + + // ----- gcobject facet ----- + + std::size_t + DArrayType::shallow_size() const noexcept + { + return sizeof(*this); + } + + DArrayType * + DArrayType::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DArrayType::forward_children(obj gc) noexcept + { + { + auto e = FacetRegistry::instance().variant(elt_type_); + gc.forward_inplace(e.iface(), (void **)&(e.data_)); + } + + return this->shallow_size(); + } + } +} + +/* end DArrayType.cpp */ diff --git a/src/type/IGCObject_DArrayType.cpp b/src/type/IGCObject_DArrayType.cpp new file mode 100644 index 00000000..936f8eec --- /dev/null +++ b/src/type/IGCObject_DArrayType.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DArrayType.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DArrayType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DArrayType.json5] +**/ + +#include "array/IGCObject_DArrayType.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DArrayType::shallow_size(const DArrayType & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DArrayType::shallow_copy(const DArrayType & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DArrayType::forward_children(DArrayType & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DArrayType.cpp */ diff --git a/src/type/IType_DArrayType.cpp b/src/type/IType_DArrayType.cpp new file mode 100644 index 00000000..2ed60101 --- /dev/null +++ b/src/type/IType_DArrayType.cpp @@ -0,0 +1,40 @@ +/** @file IType_DArrayType.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DArrayType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DArrayType.json5] +**/ + +#include "array/IType_DArrayType.hpp" + +namespace xo { + namespace scm { + auto + IType_DArrayType::metatype(const DArrayType & self) noexcept -> Metatype + { + return self.metatype(); + } + + auto + IType_DArrayType::is_equal_to(const DArrayType & self, const obj_AType & y) -> bool + { + return self.is_equal_to(y); + } + + auto + IType_DArrayType::is_subtype_of(const DArrayType & self, const obj_AType & y) -> bool + { + return self.is_subtype_of(y); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IType_DArrayType.cpp */ diff --git a/src/type/type_register_facets.cpp b/src/type/type_register_facets.cpp index 549633cd..8cebc6f0 100644 --- a/src/type/type_register_facets.cpp +++ b/src/type/type_register_facets.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -28,8 +29,12 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DAtomicType.tseq", typeseq::id())); log && log(xtag("DListType.tseq", typeseq::id())); + log && log(xtag("DArrayType.tseq", typeseq::id())); return true; } diff --git a/src/type/type_register_types.cpp b/src/type/type_register_types.cpp index 8e2cdda6..884de0cd 100644 --- a/src/type/type_register_types.cpp +++ b/src/type/type_register_types.cpp @@ -7,6 +7,7 @@ #include "AtomicType.hpp" #include "ListType.hpp" +#include "ArrayType.hpp" #include #include #include @@ -27,6 +28,7 @@ namespace xo { ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); return ok; } diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index cc18708a..6ddf4ce4 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -5,6 +5,7 @@ set(UTEST_SRCS type_utest_main.cpp DAtomicType.test.cpp DListType.test.cpp + DArrayType.test.cpp # DString.test.cpp # StringOps.test.cpp # X1Collector.test.cpp diff --git a/utest/DArrayType.test.cpp b/utest/DArrayType.test.cpp new file mode 100644 index 00000000..fc4ed8cb --- /dev/null +++ b/utest/DArrayType.test.cpp @@ -0,0 +1,70 @@ +/** @file DArrayType.test.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "init_type.hpp" +#include "TypeOps.hpp" +#include "ArrayType.hpp" +#include "ListType.hpp" +#include "AtomicType.hpp" +#include +#include +#include +#include + +namespace xo { + using xo::scm::TypeOps; + using xo::scm::AType; + using xo::scm::Metatype; + using xo::mm::AAllocator; + using xo::mm::DArena; + using xo::mm::ArenaConfig; + + namespace ut { + static InitEvidence s_init = (InitSubsys::require()); + + TEST_CASE("DArrayType-make", "[type][DArrayType]") + { + ArenaConfig cfg { .name_ = "testarena", + .size_ = 4*1024 }; + DArena arena = DArena::map(cfg); + auto alloc = obj(&arena); + + auto i64_type = TypeOps::atomic_type(alloc, Metatype::i64()); + auto array_i64_type = TypeOps::array_type(alloc, i64_type); + + REQUIRE(array_i64_type); + REQUIRE(array_i64_type.is_equal_to(array_i64_type)); + + auto bool_type = TypeOps::atomic_type(alloc, Metatype::t_bool()); + auto array_bool_type = TypeOps::array_type(alloc, bool_type); + + REQUIRE(array_bool_type); + REQUIRE(array_bool_type.is_equal_to(array_bool_type)); + + auto any_type = TypeOps::atomic_type(alloc, Metatype::any()); + auto array_any_type = TypeOps::array_type(alloc, any_type); + + REQUIRE(array_any_type); + REQUIRE(array_any_type.is_equal_to(array_any_type)); + + REQUIRE(array_bool_type.is_subtype_of(array_any_type)); + REQUIRE(array_i64_type.is_subtype_of(array_any_type)); + + REQUIRE(!array_i64_type.is_subtype_of(array_bool_type)); + REQUIRE(!array_any_type.is_subtype_of(array_bool_type)); + REQUIRE(!array_bool_type.is_subtype_of(array_i64_type)); + REQUIRE(!array_any_type.is_subtype_of(array_i64_type)); + + // array and list are unrelated + auto list_i64_type = TypeOps::list_type(alloc, i64_type); + REQUIRE(!array_i64_type.is_equal_to(list_i64_type)); + REQUIRE(!array_i64_type.is_subtype_of(list_i64_type)); + REQUIRE(!list_i64_type.is_subtype_of(array_i64_type)); + } + } +} + + +/* end DArrayType.test.cpp */ From 1d0054cd7f222bd860f6f3aa72d79b51f3541e8b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 7 Mar 2026 11:43:14 +1100 Subject: [PATCH 05/31] xo-type: + DFunctionType --- CMakeLists.txt | 20 ++++ cmake/xo_typeConfig.cmake.in | 1 + idl/IGCObject_DFunctionType.json5 | 16 +++ idl/IType_DFunctionType.json5 | 16 +++ include/xo/type/DFunctionType.hpp | 92 +++++++++++++++ include/xo/type/FunctionType.hpp | 12 ++ include/xo/type/Metatype.hpp | 1 + .../type/function/IGCObject_DFunctionType.hpp | 65 +++++++++++ .../xo/type/function/IType_DFunctionType.hpp | 63 ++++++++++ src/type/CMakeLists.txt | 4 + src/type/DFunctionType.cpp | 109 ++++++++++++++++++ src/type/IGCObject_DFunctionType.cpp | 39 +++++++ src/type/IType_DFunctionType.cpp | 40 +++++++ src/type/type_register_facets.cpp | 5 + src/type/type_register_types.cpp | 2 + 15 files changed, 485 insertions(+) create mode 100644 idl/IGCObject_DFunctionType.json5 create mode 100644 idl/IType_DFunctionType.json5 create mode 100644 include/xo/type/DFunctionType.hpp create mode 100644 include/xo/type/FunctionType.hpp create mode 100644 include/xo/type/function/IGCObject_DFunctionType.hpp create mode 100644 include/xo/type/function/IType_DFunctionType.hpp create mode 100644 src/type/DFunctionType.cpp create mode 100644 src/type/IGCObject_DFunctionType.cpp create mode 100644 src/type/IType_DFunctionType.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a318537..82cdc685 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,26 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-type-facetimpl-type-functiontype + FACET_PKG xo_type + FACET Type + REPR FunctionType + INPUT idl/IType_DFunctionType.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-type-facetimpl-gcobject-functiontype + FACET_PKG xo_alloc2 + FACET GCObject + REPR FunctionType + INPUT idl/IGCObject_DFunctionType.json5 +) + +# ---------------------------------------------------------------- + xo_add_genfacet_all(xo-type-genfacet-all) install(DIRECTORY idl/ diff --git a/cmake/xo_typeConfig.cmake.in b/cmake/xo_typeConfig.cmake.in index 186f1817..e1618c2b 100644 --- a/cmake/xo_typeConfig.cmake.in +++ b/cmake/xo_typeConfig.cmake.in @@ -1,6 +1,7 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) +find_dependency(xo_object2) find_dependency(xo_alloc2) find_dependency(xo_facet) find_dependency(subsys) diff --git a/idl/IGCObject_DFunctionType.json5 b/idl/IGCObject_DFunctionType.json5 new file mode 100644 index 00000000..af1f3c9b --- /dev/null +++ b/idl/IGCObject_DFunctionType.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "function", + includes: [ + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DFunctionType", + using_doxygen: true, + repr: "DFunctionType", + doc: [ "implement AGCObject for DFunctionType" ], +} diff --git a/idl/IType_DFunctionType.json5 b/idl/IType_DFunctionType.json5 new file mode 100644 index 00000000..99dd82bc --- /dev/null +++ b/idl/IType_DFunctionType.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "function", + includes: [], + local_types: [], + namespace1: "xo", + namespace2: "scm", + + facet_idl: "idl/Type.json5", + brief: "provide AType interface for DFunctionType", + using_doxygen: true, + repr: "DFunctionType", + doc: [ "implement AType for DFunctionType" ], +} diff --git a/include/xo/type/DFunctionType.hpp b/include/xo/type/DFunctionType.hpp new file mode 100644 index 00000000..3ceafb71 --- /dev/null +++ b/include/xo/type/DFunctionType.hpp @@ -0,0 +1,92 @@ +/** @file DFunctionType.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "Type.hpp" +#include "Metatype.hpp" +#include +#include +#include + +namespace xo { + namespace scm { + /** @brief A parameterized array type: array(T) + * + * Represents a fixed-size homogeneous collection. + **/ + class DFunctionType { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + + public: + /** @defgroup xo-scm-arraytype-ctors **/ + ///@{ + + /** create instance using memory from @p mm, + * for a function with return type @p ret_type and arguments @p args + **/ + template + requires (std::same_as> && ...) + explicit DFunctionType(obj mm, obj ret_type, Args... args); + + /** create instance using memory from @p mm, + * for a function with return type @p ret_type and arguments @p args + **/ + template + requires (std::same_as> && ...) + static DFunctionType * _make(obj mm, + obj ret_type, Args... args); + + ///@} + /** @defgroup xo-scm-arraytype-type-facet **/ + ///@{ + Metatype metatype() const noexcept { return Metatype::array(); } + bool is_equal_to(obj y) const noexcept; + bool is_subtype_of(const obj & y) const noexcept; + ///@} + /** @defgroup xo-scm-arraytype-gcobject-facet **/ + ///@{ + std::size_t shallow_size() const noexcept; + DFunctionType * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} + + private: + /** @defgroup xo-scm-arraytype-member-vars **/ + ///@{ + + /** function return type **/ + obj return_type_; + + /** argument types **/ + DArray * arg_types_ = nullptr; + + ///@} + }; + + template + requires (std::same_as> && ...) + DFunctionType::DFunctionType(obj mm, obj return_type, Args... args) + : return_type_{return_type}, + arg_types_{DArray::array(mm, args...)} + {} + + template + requires (std::same_as> && ...) + DFunctionType * + DFunctionType::_make(obj mm, obj ret_type, Args... args) + { + void * mem = mm.alloc_for(); + + return new (mem) DFunctionType(mm, ret_type, args...); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DFunctionType.hpp */ diff --git a/include/xo/type/FunctionType.hpp b/include/xo/type/FunctionType.hpp new file mode 100644 index 00000000..28cdc11f --- /dev/null +++ b/include/xo/type/FunctionType.hpp @@ -0,0 +1,12 @@ +/** @file FunctionType.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "DFunctionType.hpp" +#include "function/IType_DFunctionType.hpp" +#include "function/IGCObject_DFunctionType.hpp" + +/* end FunctionType.hpp */ diff --git a/include/xo/type/Metatype.hpp b/include/xo/type/Metatype.hpp index e1119801..b8a509e6 100644 --- a/include/xo/type/Metatype.hpp +++ b/include/xo/type/Metatype.hpp @@ -47,6 +47,7 @@ namespace xo { static Metatype list() { return Metatype(code::t_list); } static Metatype array() { return Metatype(code::t_array); } + static Metatype function() { return Metatype(code::t_function); } /** description string for this type category **/ const char * _descr() const noexcept; diff --git a/include/xo/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp new file mode 100644 index 00000000..431c19e8 --- /dev/null +++ b/include/xo/type/function/IGCObject_DFunctionType.hpp @@ -0,0 +1,65 @@ +/** @file IGCObject_DFunctionType.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DFunctionType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DFunctionType.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include "DFunctionType.hpp" + +namespace xo { namespace scm { class IGCObject_DFunctionType; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DFunctionType + **/ + class IGCObject_DFunctionType { + public: + /** @defgroup scm-gcobject-dfunctiontype-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-dfunctiontype-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DFunctionType & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DFunctionType & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DFunctionType & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/type/function/IType_DFunctionType.hpp b/include/xo/type/function/IType_DFunctionType.hpp new file mode 100644 index 00000000..b28050ab --- /dev/null +++ b/include/xo/type/function/IType_DFunctionType.hpp @@ -0,0 +1,63 @@ +/** @file IType_DFunctionType.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DFunctionType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DFunctionType.json5] + **/ + +#pragma once + +#include "Type.hpp" +#include "DFunctionType.hpp" + +namespace xo { namespace scm { class IType_DFunctionType; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IType_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IType_DFunctionType + **/ + class IType_DFunctionType { + public: + /** @defgroup scm-type-dfunctiontype-type-traits **/ + ///@{ + using obj_AType = xo::scm::AType::obj_AType; + using Copaque = xo::scm::AType::Copaque; + using Opaque = xo::scm::AType::Opaque; + ///@} + /** @defgroup scm-type-dfunctiontype-methods **/ + ///@{ + // const methods + /** category for this type **/ + static Metatype metatype(const DFunctionType & self) noexcept; + /** true iff this type is equal to y **/ + static bool is_equal_to(const DFunctionType & self, const obj_AType & y); + /** true iff this is a subtype of y **/ + static bool is_subtype_of(const DFunctionType & self, const obj_AType & y); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/type/CMakeLists.txt b/src/type/CMakeLists.txt index d00c30bf..3bc7b2eb 100644 --- a/src/type/CMakeLists.txt +++ b/src/type/CMakeLists.txt @@ -10,13 +10,16 @@ set(SELF_SRCS DAtomicType.cpp DListType.cpp DArrayType.cpp + DFunctionType.cpp IType_Any.cpp IType_DAtomicType.cpp IType_DListType.cpp IType_DArrayType.cpp + IType_DFunctionType.cpp IGCObject_DAtomicType.cpp IGCObject_DListType.cpp IGCObject_DArrayType.cpp + IGCObject_DFunctionType.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) @@ -27,6 +30,7 @@ xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 $ # NOTE: dependency set here must be kept consistent with # xo-type/cmake/xo_typeConfig.cmake.in +xo_dependency(${SELF_LIB} xo_object2) xo_dependency(${SELF_LIB} xo_alloc2) xo_dependency(${SELF_LIB} xo_facet) xo_dependency(${SELF_LIB} subsys) diff --git a/src/type/DFunctionType.cpp b/src/type/DFunctionType.cpp new file mode 100644 index 00000000..5fdbbdf3 --- /dev/null +++ b/src/type/DFunctionType.cpp @@ -0,0 +1,109 @@ +/** @file DFunctionType.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "FunctionType.hpp" +#include + +namespace xo { + using xo::facet::FacetRegistry; + + namespace scm { + + // ----- type facet ----- + + bool + DFunctionType::is_equal_to(obj y_arg) const noexcept + { + Metatype y_mtype = y_arg.metatype(); + + if (y_mtype != Metatype::function()) + return false; + + auto y = obj::from(y_arg); + assert(y); + + if (arg_types_->size() != y->arg_types_->size()) + return false; + + if (obj(return_type_).is_equal_to(y->return_type_)) + return false; + + for (size_t i = 0, n = arg_types_->size(); i < n; ++i) { + auto argtype1 + = FacetRegistry::instance().variant((*arg_types_)[i]); + auto argtype2 + = FacetRegistry::instance().variant((*(y->arg_types_))[i]); + + if (argtype1.is_equal_to(argtype2)) + return false; + } + + return true; + } + + bool + DFunctionType::is_subtype_of(const obj & y_arg) const noexcept + { + Metatype y_mtype = y_arg.metatype(); + + if (y_mtype == Metatype::any()) + return true; + + if (y_mtype != Metatype::function()) + return false; + + auto y = obj::from(y_arg); + assert(y); + + if (arg_types_->size() != y->arg_types_->size()) + return false; + + if (!obj(return_type_).is_subtype_of(y->return_type_)) + return false; + + for (size_t i = 0, n = arg_types_->size(); i < n; ++i) { + auto x_argtype + = FacetRegistry::instance().variant((*arg_types_)[i]); + auto y_argtype + = FacetRegistry::instance().variant((*(y->arg_types_))[i]); + + if (!y_argtype.is_subtype_of(x_argtype)) + return false; + } + + return true; + } + + // ----- gcobject facet ----- + + std::size_t + DFunctionType::shallow_size() const noexcept + { + return sizeof(*this); + } + + DFunctionType * + DFunctionType::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DFunctionType::forward_children(obj gc) noexcept + { + { + auto e = FacetRegistry::instance().variant(return_type_); + gc.forward_inplace(e.iface(), (void **)&(e.data_)); + } + + gc.forward_inplace(&arg_types_); + + return this->shallow_size(); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DFunctionType.cpp */ diff --git a/src/type/IGCObject_DFunctionType.cpp b/src/type/IGCObject_DFunctionType.cpp new file mode 100644 index 00000000..45141b3a --- /dev/null +++ b/src/type/IGCObject_DFunctionType.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DFunctionType.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DFunctionType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DFunctionType.json5] +**/ + +#include "function/IGCObject_DFunctionType.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DFunctionType::shallow_size(const DFunctionType & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DFunctionType::shallow_copy(const DFunctionType & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DFunctionType::forward_children(DFunctionType & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DFunctionType.cpp */ diff --git a/src/type/IType_DFunctionType.cpp b/src/type/IType_DFunctionType.cpp new file mode 100644 index 00000000..230cf67d --- /dev/null +++ b/src/type/IType_DFunctionType.cpp @@ -0,0 +1,40 @@ +/** @file IType_DFunctionType.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DFunctionType.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DFunctionType.json5] +**/ + +#include "function/IType_DFunctionType.hpp" + +namespace xo { + namespace scm { + auto + IType_DFunctionType::metatype(const DFunctionType & self) noexcept -> Metatype + { + return self.metatype(); + } + + auto + IType_DFunctionType::is_equal_to(const DFunctionType & self, const obj_AType & y) -> bool + { + return self.is_equal_to(y); + } + + auto + IType_DFunctionType::is_subtype_of(const DFunctionType & self, const obj_AType & y) -> bool + { + return self.is_subtype_of(y); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IType_DFunctionType.cpp */ diff --git a/src/type/type_register_facets.cpp b/src/type/type_register_facets.cpp index 8cebc6f0..9cada7e0 100644 --- a/src/type/type_register_facets.cpp +++ b/src/type/type_register_facets.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -32,9 +33,13 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DAtomicType.tseq", typeseq::id())); log && log(xtag("DListType.tseq", typeseq::id())); log && log(xtag("DArrayType.tseq", typeseq::id())); + log && log(xtag("DFunctionType.tseq", typeseq::id())); return true; } diff --git a/src/type/type_register_types.cpp b/src/type/type_register_types.cpp index 884de0cd..e031ce50 100644 --- a/src/type/type_register_types.cpp +++ b/src/type/type_register_types.cpp @@ -8,6 +8,7 @@ #include "AtomicType.hpp" #include "ListType.hpp" #include "ArrayType.hpp" +#include "FunctionType.hpp" #include #include #include @@ -29,6 +30,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 99c30bf9753c41c80c7f3a731f551b2338580681 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 07:49:14 -0500 Subject: [PATCH 06/31] xo-reader2 stack: expand symbol table to store typedefs + typedef utest + misc qol policy choices --- cmake/xo_typeConfig.cmake.in | 1 + idl/Type.json5 | 32 ++++++++------ include/xo/type/DArrayType.hpp | 4 +- include/xo/type/DAtomicType.hpp | 4 ++ include/xo/type/DFunctionType.hpp | 4 +- include/xo/type/DListType.hpp | 8 +++- include/xo/type/Metatype.hpp | 41 ++++++++++++------ include/xo/type/array/IType_DArrayType.hpp | 3 ++ include/xo/type/atomic/IType_DAtomicType.hpp | 3 ++ .../xo/type/function/IType_DFunctionType.hpp | 3 ++ include/xo/type/list/IType_DListType.hpp | 3 ++ include/xo/type/type/AType.hpp | 9 +++- include/xo/type/type/IType_Any.hpp | 6 ++- include/xo/type/type/IType_Xfer.hpp | 9 +++- include/xo/type/type/RType.hpp | 8 +++- src/type/CMakeLists.txt | 1 + src/type/DArrayType.cpp | 22 +++++++--- src/type/DAtomicType.cpp | 16 +++++++ src/type/DFunctionType.cpp | 17 ++++++-- src/type/DListType.cpp | 18 ++++++-- src/type/IType_DArrayType.cpp | 6 +++ src/type/IType_DAtomicType.cpp | 6 +++ src/type/IType_DFunctionType.cpp | 6 +++ src/type/IType_DListType.cpp | 6 +++ src/type/Metatype.cpp | 42 +++++++++++++------ utest/DArrayType.test.cpp | 4 +- utest/DAtomicType.test.cpp | 20 ++++----- utest/DListType.test.cpp | 4 +- 28 files changed, 230 insertions(+), 76 deletions(-) diff --git a/cmake/xo_typeConfig.cmake.in b/cmake/xo_typeConfig.cmake.in index e1618c2b..2d7841a5 100644 --- a/cmake/xo_typeConfig.cmake.in +++ b/cmake/xo_typeConfig.cmake.in @@ -2,6 +2,7 @@ include(CMakeFindDependencyMacro) find_dependency(xo_object2) +find_dependnecy(reflect) find_dependency(xo_alloc2) find_dependency(xo_facet) find_dependency(subsys) diff --git a/idl/Type.json5 b/idl/Type.json5 index 1ddac826..06fa2dce 100644 --- a/idl/Type.json5 +++ b/idl/Type.json5 @@ -4,7 +4,8 @@ output_hpp_dir: "include/xo/type", output_impl_subdir: "type", includes: [ - "" + "", + "", ], user_hpp_includes: [ ], @@ -26,6 +27,11 @@ name: "obj_AType", doc: [], definition: "xo::facet::obj", + }, + { + name: "TypeDescr", + doc: [], + definition: "xo::reflect::TypeDescr", } ], const_methods: [ @@ -37,13 +43,22 @@ const: true, noexcept: true, }, + { + name: "repr_td", + doc: ["reflected representation for instances of this type"], + return_type: "TypeDescr", + args: [], + const: true, + noexcept: true, + }, { name: "is_equal_to", doc: ["true iff this type is equal to y"], return_type: "bool", args: [ {type: "const obj_AType &", name: "y"}, - ] + ], + const: true, }, { name: "is_subtype_of", @@ -51,18 +66,9 @@ return_type: "bool", args: [ {type: "const obj_AType &", name: "y"}, - ] + ], + const: true, }, - - // TODO: define methods, e.g.: - // { - // name: "my_method", - // doc: ["description"], - // return_type: "bool", - // args: [], - // const: true, - // noexcept: true, - // }, ], nonconst_methods: [], router_facet_explicit_content: [ diff --git a/include/xo/type/DArrayType.hpp b/include/xo/type/DArrayType.hpp index 945f7f0a..a8efe329 100644 --- a/include/xo/type/DArrayType.hpp +++ b/include/xo/type/DArrayType.hpp @@ -20,6 +20,7 @@ namespace xo { public: using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; public: /** @defgroup xo-scm-arraytype-ctors **/ @@ -33,7 +34,8 @@ namespace xo { ///@} /** @defgroup xo-scm-arraytype-type-facet **/ ///@{ - Metatype metatype() const noexcept { return Metatype::array(); } + Metatype metatype() const noexcept { return Metatype::t_array(); } + TypeDescr repr_td() const noexcept; bool is_equal_to(const obj & y) const noexcept; bool is_subtype_of(const obj & y) const noexcept; ///@} diff --git a/include/xo/type/DAtomicType.hpp b/include/xo/type/DAtomicType.hpp index 074e0c64..6cd11ba5 100644 --- a/include/xo/type/DAtomicType.hpp +++ b/include/xo/type/DAtomicType.hpp @@ -23,16 +23,20 @@ namespace xo { public: using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; public: explicit DAtomicType(Metatype m) : metatype_{m} {} /** create instance using memory from @p mm with metatype @p mtype **/ static DAtomicType * _make(obj mm, Metatype mtype); + /** create instance **/ + static obj make(obj mm, Metatype mtype); /** @defgroup xo-scm-atomictype-type-facet **/ ///@{ Metatype metatype() const noexcept { return metatype_; } + TypeDescr repr_td() const noexcept; bool is_equal_to(const obj & y) const noexcept; bool is_subtype_of(const obj & y) const noexcept; ///@} diff --git a/include/xo/type/DFunctionType.hpp b/include/xo/type/DFunctionType.hpp index 3ceafb71..7090a60b 100644 --- a/include/xo/type/DFunctionType.hpp +++ b/include/xo/type/DFunctionType.hpp @@ -22,6 +22,7 @@ namespace xo { using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using TypeDescr = xo::reflect::TypeDescr; public: /** @defgroup xo-scm-arraytype-ctors **/ @@ -45,7 +46,8 @@ namespace xo { ///@} /** @defgroup xo-scm-arraytype-type-facet **/ ///@{ - Metatype metatype() const noexcept { return Metatype::array(); } + Metatype metatype() const noexcept { return Metatype::t_array(); } + TypeDescr repr_td() const noexcept; bool is_equal_to(obj y) const noexcept; bool is_subtype_of(const obj & y) const noexcept; ///@} diff --git a/include/xo/type/DListType.hpp b/include/xo/type/DListType.hpp index 41808ce6..51db9414 100644 --- a/include/xo/type/DListType.hpp +++ b/include/xo/type/DListType.hpp @@ -7,6 +7,7 @@ #include "Type.hpp" #include "Metatype.hpp" +#include #include #include @@ -21,6 +22,7 @@ namespace xo { **/ class DListType { public: + using TypeDescr = xo::reflect::TypeDescr; using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; @@ -31,12 +33,14 @@ namespace xo { explicit DListType(obj elt); /** create instance using memory from @p mm with metatype @p mtype **/ - static DListType * _make(obj mm, obj elt_type); + static DListType * _make(obj mm, + obj elt_type); ///@} /** @defgroup xo-scm-listtype-type-facet **/ ///@{ - Metatype metatype() const noexcept { return Metatype::list(); } + Metatype metatype() const noexcept { return Metatype::t_list(); } + TypeDescr repr_td() const noexcept; bool is_equal_to(const obj & y) const noexcept; bool is_subtype_of(const obj & y) const noexcept; ///@} diff --git a/include/xo/type/Metatype.hpp b/include/xo/type/Metatype.hpp index b8a509e6..6fc193ae 100644 --- a/include/xo/type/Metatype.hpp +++ b/include/xo/type/Metatype.hpp @@ -14,12 +14,21 @@ namespace xo { enum class code { /* void */ t_unit, - t_bool, - t_i64, - t_f64, t_str, + /* int16_t */ + t_i16, + /* int32_t */ + t_i32, + /* int64_t */ + t_i64, + + /* float */ + t_f32, + /* double */ + t_f64, + /* discriminated union */ t_sum, /* list */ @@ -38,16 +47,24 @@ namespace xo { public: explicit Metatype(code x) : code_{x} {} - static Metatype unit() { return Metatype(code::t_unit); } - static Metatype t_bool() { return Metatype(code::t_bool); } - static Metatype i64() { return Metatype(code::t_i64); } - static Metatype f64() { return Metatype(code::t_f64); } - static Metatype str() { return Metatype(code::t_str); } - static Metatype any() { return Metatype(code::t_any); } + static Metatype t_unit() { return Metatype(code::t_unit); } + static Metatype t_bool() { return Metatype(code::t_bool); } + static Metatype t_str() { return Metatype(code::t_str); } - static Metatype list() { return Metatype(code::t_list); } - static Metatype array() { return Metatype(code::t_array); } - static Metatype function() { return Metatype(code::t_function); } + static Metatype t_i16() { return Metatype(code::t_i16); } + static Metatype t_i32() { return Metatype(code::t_i32); } + static Metatype t_i64() { return Metatype(code::t_i64); } + + static Metatype t_f32() { return Metatype(code::t_f32); } + static Metatype t_f64() { return Metatype(code::t_f64); } + + static Metatype t_sum() { return Metatype(code::t_sum); } + static Metatype t_list() { return Metatype(code::t_list); } + static Metatype t_array() { return Metatype(code::t_array); } + static Metatype t_function() { return Metatype(code::t_function); } + static Metatype t_struct() { return Metatype(code::t_struct); } + + static Metatype t_any() { return Metatype(code::t_any); } /** description string for this type category **/ const char * _descr() const noexcept; diff --git a/include/xo/type/array/IType_DArrayType.hpp b/include/xo/type/array/IType_DArrayType.hpp index e323931b..afeb63f7 100644 --- a/include/xo/type/array/IType_DArrayType.hpp +++ b/include/xo/type/array/IType_DArrayType.hpp @@ -40,6 +40,7 @@ namespace xo { /** @defgroup scm-type-darraytype-type-traits **/ ///@{ using obj_AType = xo::scm::AType::obj_AType; + using TypeDescr = xo::scm::AType::TypeDescr; using Copaque = xo::scm::AType::Copaque; using Opaque = xo::scm::AType::Opaque; ///@} @@ -48,6 +49,8 @@ namespace xo { // const methods /** category for this type **/ static Metatype metatype(const DArrayType & self) noexcept; + /** reflected representation for instances of this type **/ + static TypeDescr repr_td(const DArrayType & self) noexcept; /** true iff this type is equal to y **/ static bool is_equal_to(const DArrayType & self, const obj_AType & y); /** true iff this is a subtype of y **/ diff --git a/include/xo/type/atomic/IType_DAtomicType.hpp b/include/xo/type/atomic/IType_DAtomicType.hpp index fc73539f..54210946 100644 --- a/include/xo/type/atomic/IType_DAtomicType.hpp +++ b/include/xo/type/atomic/IType_DAtomicType.hpp @@ -40,6 +40,7 @@ namespace xo { /** @defgroup scm-type-datomictype-type-traits **/ ///@{ using obj_AType = xo::scm::AType::obj_AType; + using TypeDescr = xo::scm::AType::TypeDescr; using Copaque = xo::scm::AType::Copaque; using Opaque = xo::scm::AType::Opaque; ///@} @@ -48,6 +49,8 @@ namespace xo { // const methods /** category for this type **/ static Metatype metatype(const DAtomicType & self) noexcept; + /** reflected representation for instances of this type **/ + static TypeDescr repr_td(const DAtomicType & self) noexcept; /** true iff this type is equal to y **/ static bool is_equal_to(const DAtomicType & self, const obj_AType & y); /** true iff this is a subtype of y **/ diff --git a/include/xo/type/function/IType_DFunctionType.hpp b/include/xo/type/function/IType_DFunctionType.hpp index b28050ab..3dba4572 100644 --- a/include/xo/type/function/IType_DFunctionType.hpp +++ b/include/xo/type/function/IType_DFunctionType.hpp @@ -40,6 +40,7 @@ namespace xo { /** @defgroup scm-type-dfunctiontype-type-traits **/ ///@{ using obj_AType = xo::scm::AType::obj_AType; + using TypeDescr = xo::scm::AType::TypeDescr; using Copaque = xo::scm::AType::Copaque; using Opaque = xo::scm::AType::Opaque; ///@} @@ -48,6 +49,8 @@ namespace xo { // const methods /** category for this type **/ static Metatype metatype(const DFunctionType & self) noexcept; + /** reflected representation for instances of this type **/ + static TypeDescr repr_td(const DFunctionType & self) noexcept; /** true iff this type is equal to y **/ static bool is_equal_to(const DFunctionType & self, const obj_AType & y); /** true iff this is a subtype of y **/ diff --git a/include/xo/type/list/IType_DListType.hpp b/include/xo/type/list/IType_DListType.hpp index 546b9cbe..658348fe 100644 --- a/include/xo/type/list/IType_DListType.hpp +++ b/include/xo/type/list/IType_DListType.hpp @@ -40,6 +40,7 @@ namespace xo { /** @defgroup scm-type-dlisttype-type-traits **/ ///@{ using obj_AType = xo::scm::AType::obj_AType; + using TypeDescr = xo::scm::AType::TypeDescr; using Copaque = xo::scm::AType::Copaque; using Opaque = xo::scm::AType::Opaque; ///@} @@ -48,6 +49,8 @@ namespace xo { // const methods /** category for this type **/ static Metatype metatype(const DListType & self) noexcept; + /** reflected representation for instances of this type **/ + static TypeDescr repr_td(const DListType & self) noexcept; /** true iff this type is equal to y **/ static bool is_equal_to(const DListType & self, const obj_AType & y); /** true iff this is a subtype of y **/ diff --git a/include/xo/type/type/AType.hpp b/include/xo/type/type/AType.hpp index dde14805..d0e8361f 100644 --- a/include/xo/type/type/AType.hpp +++ b/include/xo/type/type/AType.hpp @@ -15,6 +15,7 @@ // includes (via {facet_includes}) #include +#include #include #include #include @@ -42,6 +43,8 @@ public: using Opaque = void *; /** **/ using obj_AType = xo::facet::obj; + /** **/ + using TypeDescr = xo::reflect::TypeDescr; ///@} /** @defgroup scm-type-methods **/ @@ -53,10 +56,12 @@ public: virtual void _drop(Opaque d) const noexcept = 0; /** category for this type **/ virtual Metatype metatype(Copaque data) const noexcept = 0; + /** reflected representation for instances of this type **/ + virtual TypeDescr repr_td(Copaque data) const noexcept = 0; /** true iff this type is equal to y **/ - virtual bool is_equal_to(Copaque data, const obj_AType & y) = 0; + virtual bool is_equal_to(Copaque data, const obj_AType & y) const = 0; /** true iff this is a subtype of y **/ - virtual bool is_subtype_of(Copaque data, const obj_AType & y) = 0; + virtual bool is_subtype_of(Copaque data, const obj_AType & y) const = 0; // nonconst methods ///@} diff --git a/include/xo/type/type/IType_Any.hpp b/include/xo/type/type/IType_Any.hpp index b8bdb58c..624db20a 100644 --- a/include/xo/type/type/IType_Any.hpp +++ b/include/xo/type/type/IType_Any.hpp @@ -45,6 +45,7 @@ namespace scm { /** integer identifying a type **/ using typeseq = xo::facet::typeseq; using obj_AType = AType::obj_AType; + using TypeDescr = AType::TypeDescr; ///@} /** @defgroup scm-type-any-methods **/ @@ -60,8 +61,9 @@ namespace scm { // const methods [[noreturn]] Metatype metatype(Copaque) const noexcept override { _fatal(); } - [[noreturn]] bool is_equal_to(Copaque, const obj_AType &) override { _fatal(); } - [[noreturn]] bool is_subtype_of(Copaque, const obj_AType &) override { _fatal(); } + [[noreturn]] TypeDescr repr_td(Copaque) const noexcept override { _fatal(); } + [[noreturn]] bool is_equal_to(Copaque, const obj_AType &) const override { _fatal(); } + [[noreturn]] bool is_subtype_of(Copaque, const obj_AType &) const override { _fatal(); } // nonconst methods diff --git a/include/xo/type/type/IType_Xfer.hpp b/include/xo/type/type/IType_Xfer.hpp index 98b138c7..dbc82bc1 100644 --- a/include/xo/type/type/IType_Xfer.hpp +++ b/include/xo/type/type/IType_Xfer.hpp @@ -14,6 +14,7 @@ #pragma once #include +#include namespace xo { namespace scm { @@ -29,6 +30,7 @@ namespace scm { /** integer identifying a type **/ using typeseq = AType::typeseq; using obj_AType = AType::obj_AType; + using TypeDescr = AType::TypeDescr; ///@} /** @defgroup scm-type-xfer-methods **/ @@ -47,10 +49,13 @@ namespace scm { Metatype metatype(Copaque data) const noexcept override { return I::metatype(_dcast(data)); } - bool is_equal_to(Copaque data, const obj_AType & y) override { + TypeDescr repr_td(Copaque data) const noexcept override { + return I::repr_td(_dcast(data)); + } + bool is_equal_to(Copaque data, const obj_AType & y) const override { return I::is_equal_to(_dcast(data), y); } - bool is_subtype_of(Copaque data, const obj_AType & y) override { + bool is_subtype_of(Copaque data, const obj_AType & y) const override { return I::is_subtype_of(_dcast(data), y); } diff --git a/include/xo/type/type/RType.hpp b/include/xo/type/type/RType.hpp index 853745ed..648749bf 100644 --- a/include/xo/type/type/RType.hpp +++ b/include/xo/type/type/RType.hpp @@ -32,6 +32,7 @@ public: using DataPtr = Object::DataPtr; using typeseq = xo::reflect::typeseq; using obj_AType = AType::obj_AType; + using TypeDescr = AType::TypeDescr; ///@} /** @defgroup scm-type-router-ctors **/ @@ -56,10 +57,13 @@ public: Metatype metatype() const noexcept { return O::iface()->metatype(O::data()); } - bool is_equal_to(const obj_AType & y) { + TypeDescr repr_td() const noexcept { + return O::iface()->repr_td(O::data()); + } + bool is_equal_to(const obj_AType & y) const { return O::iface()->is_equal_to(O::data(), y); } - bool is_subtype_of(const obj_AType & y) { + bool is_subtype_of(const obj_AType & y) const { return O::iface()->is_subtype_of(O::data(), y); } diff --git a/src/type/CMakeLists.txt b/src/type/CMakeLists.txt index 3bc7b2eb..6d6cdcc1 100644 --- a/src/type/CMakeLists.txt +++ b/src/type/CMakeLists.txt @@ -31,6 +31,7 @@ xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 $ # xo-type/cmake/xo_typeConfig.cmake.in xo_dependency(${SELF_LIB} xo_object2) +xo_dependency(${SELF_LIB} reflect) xo_dependency(${SELF_LIB} xo_alloc2) xo_dependency(${SELF_LIB} xo_facet) xo_dependency(${SELF_LIB} subsys) diff --git a/src/type/DArrayType.cpp b/src/type/DArrayType.cpp index de5320e2..652186ab 100644 --- a/src/type/DArrayType.cpp +++ b/src/type/DArrayType.cpp @@ -5,18 +5,24 @@ #include "Type.hpp" #include "ArrayType.hpp" +#include "TypeDescr.hpp" +#include #include #include #include namespace xo { + using xo::reflect::Reflect; + using xo::reflect::TypeDescr; using xo::mm::AGCObject; using xo::mm::AAllocator; using xo::facet::FacetRegistry; namespace scm { - DArrayType::DArrayType(obj elt) : elt_type_{elt} {} + DArrayType::DArrayType(obj elt) + : elt_type_{elt} + {} DArrayType * DArrayType::_make(obj mm, @@ -29,12 +35,18 @@ namespace xo { // ----- type facet ----- + TypeDescr + DArrayType::repr_td() const noexcept + { + return Reflect::require(); + } + bool DArrayType::is_equal_to(const obj & y_arg) const noexcept { Metatype y_mtype = y_arg.metatype(); - if (y_mtype != Metatype::array()) + if (y_mtype != Metatype::t_array()) return false; auto y = obj::from(y_arg); @@ -49,10 +61,10 @@ namespace xo { { Metatype y_mtype = y_arg.metatype(); - if (y_mtype == Metatype::any()) + if (y_mtype == Metatype::t_any()) return true; - if (y_mtype != Metatype::array()) + if (y_mtype != Metatype::t_array()) return false; auto y = obj::from(y_arg); @@ -81,7 +93,7 @@ namespace xo { { { auto e = FacetRegistry::instance().variant(elt_type_); - gc.forward_inplace(e.iface(), (void **)&(e.data_)); + gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_)); } return this->shallow_size(); diff --git a/src/type/DAtomicType.cpp b/src/type/DAtomicType.cpp index 18c64c81..bc2fe558 100644 --- a/src/type/DAtomicType.cpp +++ b/src/type/DAtomicType.cpp @@ -4,8 +4,12 @@ **/ #include "AtomicType.hpp" +#include namespace xo { + using xo::reflect::Reflect; + using xo::reflect::TypeDescr; + namespace scm { DAtomicType * @@ -16,8 +20,20 @@ namespace xo { return new (mem) DAtomicType(mtype); } + obj + DAtomicType::make(obj mm, Metatype mtype) + { + return obj(_make(mm, mtype)); + } + // ----- Type facet ----- + TypeDescr + DAtomicType::repr_td() const noexcept + { + return Reflect::require(); + } + bool DAtomicType::is_equal_to(const obj & y) const noexcept { diff --git a/src/type/DFunctionType.cpp b/src/type/DFunctionType.cpp index 5fdbbdf3..88de628b 100644 --- a/src/type/DFunctionType.cpp +++ b/src/type/DFunctionType.cpp @@ -4,21 +4,30 @@ **/ #include "FunctionType.hpp" +#include #include namespace xo { + using xo::reflect::Reflect; + using xo::reflect::TypeDescr; using xo::facet::FacetRegistry; namespace scm { // ----- type facet ----- + TypeDescr + DFunctionType::repr_td() const noexcept + { + return Reflect::require(); + } + bool DFunctionType::is_equal_to(obj y_arg) const noexcept { Metatype y_mtype = y_arg.metatype(); - if (y_mtype != Metatype::function()) + if (y_mtype != Metatype::t_function()) return false; auto y = obj::from(y_arg); @@ -48,10 +57,10 @@ namespace xo { { Metatype y_mtype = y_arg.metatype(); - if (y_mtype == Metatype::any()) + if (y_mtype == Metatype::t_any()) return true; - if (y_mtype != Metatype::function()) + if (y_mtype != Metatype::t_function()) return false; auto y = obj::from(y_arg); @@ -95,7 +104,7 @@ namespace xo { { { auto e = FacetRegistry::instance().variant(return_type_); - gc.forward_inplace(e.iface(), (void **)&(e.data_)); + gc.forward_inplace(e.iface(), (void **)&(return_type_.data_)); } gc.forward_inplace(&arg_types_); diff --git a/src/type/DListType.cpp b/src/type/DListType.cpp index 4be59a36..35b29235 100644 --- a/src/type/DListType.cpp +++ b/src/type/DListType.cpp @@ -5,11 +5,15 @@ #include "Type.hpp" #include "ListType.hpp" +#include "TypeDescr.hpp" +#include #include #include #include namespace xo { + using xo::reflect::Reflect; + using xo::reflect::TypeDescr; using xo::mm::AGCObject; using xo::mm::AAllocator; using xo::facet::FacetRegistry; @@ -29,12 +33,18 @@ namespace xo { // ----- type facet ----- + TypeDescr + DListType::repr_td() const noexcept + { + return Reflect::require(); + } + bool DListType::is_equal_to(const obj & y_arg) const noexcept { Metatype y_mtype = y_arg.metatype(); - if (y_mtype != Metatype::list()) + if (y_mtype != Metatype::t_list()) return false; auto y = obj::from(y_arg); @@ -49,10 +59,10 @@ namespace xo { { Metatype y_mtype = y_arg.metatype(); - if (y_mtype == Metatype::any()) + if (y_mtype == Metatype::t_any()) return true; - if (y_mtype != Metatype::list()) + if (y_mtype != Metatype::t_list()) return false; auto y = obj::from(y_arg); @@ -81,7 +91,7 @@ namespace xo { { { auto e = FacetRegistry::instance().variant(elt_type_); - gc.forward_inplace(e.iface(), (void **)&(e.data_)); + gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_)); } return this->shallow_size(); diff --git a/src/type/IType_DArrayType.cpp b/src/type/IType_DArrayType.cpp index 2ed60101..363e79c1 100644 --- a/src/type/IType_DArrayType.cpp +++ b/src/type/IType_DArrayType.cpp @@ -21,6 +21,12 @@ namespace xo { return self.metatype(); } + auto + IType_DArrayType::repr_td(const DArrayType & self) noexcept -> TypeDescr + { + return self.repr_td(); + } + auto IType_DArrayType::is_equal_to(const DArrayType & self, const obj_AType & y) -> bool { diff --git a/src/type/IType_DAtomicType.cpp b/src/type/IType_DAtomicType.cpp index 65fcb023..fd137cbb 100644 --- a/src/type/IType_DAtomicType.cpp +++ b/src/type/IType_DAtomicType.cpp @@ -21,6 +21,12 @@ namespace xo { return self.metatype(); } + auto + IType_DAtomicType::repr_td(const DAtomicType & self) noexcept -> TypeDescr + { + return self.repr_td(); + } + auto IType_DAtomicType::is_equal_to(const DAtomicType & self, const obj_AType & y) -> bool { diff --git a/src/type/IType_DFunctionType.cpp b/src/type/IType_DFunctionType.cpp index 230cf67d..6e77a152 100644 --- a/src/type/IType_DFunctionType.cpp +++ b/src/type/IType_DFunctionType.cpp @@ -21,6 +21,12 @@ namespace xo { return self.metatype(); } + auto + IType_DFunctionType::repr_td(const DFunctionType & self) noexcept -> TypeDescr + { + return self.repr_td(); + } + auto IType_DFunctionType::is_equal_to(const DFunctionType & self, const obj_AType & y) -> bool { diff --git a/src/type/IType_DListType.cpp b/src/type/IType_DListType.cpp index a29e3d74..9632f403 100644 --- a/src/type/IType_DListType.cpp +++ b/src/type/IType_DListType.cpp @@ -21,6 +21,12 @@ namespace xo { return self.metatype(); } + auto + IType_DListType::repr_td(const DListType & self) noexcept -> TypeDescr + { + return self.repr_td(); + } + auto IType_DListType::is_equal_to(const DListType & self, const obj_AType & y) -> bool { diff --git a/src/type/Metatype.cpp b/src/type/Metatype.cpp index aa97fdcc..ca61d9c9 100644 --- a/src/type/Metatype.cpp +++ b/src/type/Metatype.cpp @@ -12,17 +12,24 @@ namespace xo { Metatype::_descr() const noexcept { switch (code_) { - case code::t_any: return "any"; + case code::t_unit: return "unit"; case code::t_bool: return "bool"; - case code::t_i64: return "i64"; - case code::t_f64: return "f64"; case code::t_str: return "str"; + + case code::t_i16: return "i16"; + case code::t_i32: return "i32"; + case code::t_i64: return "i64"; + + case code::t_f32: return "f32"; + case code::t_f64: return "f64"; + case code::t_sum: return "sum"; case code::t_list: return "list"; case code::t_array: return "array"; case code::t_function: return "function"; case code::t_struct: return "struct"; - case code::t_unit: return "unit"; + + case code::t_any: return "any"; } } @@ -30,16 +37,26 @@ namespace xo { Metatype::is_atomic() const noexcept { switch (code_) { - case code::t_any: - return true; + case code::t_unit: + return false; + case code::t_bool: return true; - case code::t_i64: - return true; - case code::t_f64: - return true; case code::t_str: return true; + + case code::t_i16: + return true; + case code::t_i32: + return true; + case code::t_i64: + return true; + + case code::t_f32: + return true; + case code::t_f64: + return true; + case code::t_sum: return false; case code::t_list: @@ -50,8 +67,9 @@ namespace xo { return false; case code::t_struct: return false; - case code::t_unit: - return false; + + case code::t_any: + return true; } } diff --git a/utest/DArrayType.test.cpp b/utest/DArrayType.test.cpp index fc4ed8cb..5947eb3a 100644 --- a/utest/DArrayType.test.cpp +++ b/utest/DArrayType.test.cpp @@ -31,7 +31,7 @@ namespace xo { DArena arena = DArena::map(cfg); auto alloc = obj(&arena); - auto i64_type = TypeOps::atomic_type(alloc, Metatype::i64()); + auto i64_type = TypeOps::atomic_type(alloc, Metatype::t_i64()); auto array_i64_type = TypeOps::array_type(alloc, i64_type); REQUIRE(array_i64_type); @@ -43,7 +43,7 @@ namespace xo { REQUIRE(array_bool_type); REQUIRE(array_bool_type.is_equal_to(array_bool_type)); - auto any_type = TypeOps::atomic_type(alloc, Metatype::any()); + auto any_type = TypeOps::atomic_type(alloc, Metatype::t_any()); auto array_any_type = TypeOps::array_type(alloc, any_type); REQUIRE(array_any_type); diff --git a/utest/DAtomicType.test.cpp b/utest/DAtomicType.test.cpp index 9bab45d0..54557010 100644 --- a/utest/DAtomicType.test.cpp +++ b/utest/DAtomicType.test.cpp @@ -28,14 +28,14 @@ namespace xo { DArena arena = DArena::map(cfg); auto alloc = obj(&arena); - auto unit_type = obj(DAtomicType::_make(alloc, Metatype::unit())); - auto i64_type = obj(DAtomicType::_make(alloc, Metatype::i64())); - auto f64_type = obj(DAtomicType::_make(alloc, Metatype::f64())); - auto str_type = obj(DAtomicType::_make(alloc, Metatype::str())); - auto any_type = obj(DAtomicType::_make(alloc, Metatype::any())); + auto unit_type = obj(DAtomicType::_make(alloc, Metatype::t_unit())); + auto i64_type = obj(DAtomicType::_make(alloc, Metatype::t_i64())); + auto f64_type = obj(DAtomicType::_make(alloc, Metatype::t_f64())); + auto str_type = obj(DAtomicType::_make(alloc, Metatype::t_str())); + auto any_type = obj(DAtomicType::_make(alloc, Metatype::t_any())); { REQUIRE(unit_type); - REQUIRE(unit_type.metatype().code() == Metatype::unit().code()); + REQUIRE(unit_type.metatype().code() == Metatype::t_unit().code()); REQUIRE(unit_type.is_equal_to(unit_type)); REQUIRE(unit_type.is_subtype_of(unit_type)); @@ -43,7 +43,7 @@ namespace xo { { REQUIRE(i64_type); - REQUIRE(i64_type.metatype().code() == Metatype::i64().code()); + REQUIRE(i64_type.metatype().code() == Metatype::t_i64().code()); REQUIRE(i64_type.is_equal_to(i64_type)); REQUIRE(i64_type.is_subtype_of(i64_type)); @@ -54,7 +54,7 @@ namespace xo { { REQUIRE(f64_type); - REQUIRE(f64_type.metatype().code() == Metatype::f64().code()); + REQUIRE(f64_type.metatype().code() == Metatype::t_f64().code()); REQUIRE(f64_type.is_equal_to(f64_type)); REQUIRE(f64_type.is_subtype_of(f64_type)); @@ -67,7 +67,7 @@ namespace xo { { REQUIRE(str_type); - REQUIRE(str_type.metatype().code() == Metatype::str().code()); + REQUIRE(str_type.metatype().code() == Metatype::t_str().code()); REQUIRE(str_type.is_equal_to(str_type)); REQUIRE(str_type.is_subtype_of(str_type)); @@ -83,7 +83,7 @@ namespace xo { { REQUIRE(any_type); - REQUIRE(any_type.metatype().code() == Metatype::any().code()); + REQUIRE(any_type.metatype().code() == Metatype::t_any().code()); REQUIRE(any_type.is_equal_to(any_type)); REQUIRE(any_type.is_subtype_of(any_type)); diff --git a/utest/DListType.test.cpp b/utest/DListType.test.cpp index fed5d916..1eace386 100644 --- a/utest/DListType.test.cpp +++ b/utest/DListType.test.cpp @@ -32,7 +32,7 @@ namespace xo { DArena arena = DArena::map(cfg); auto alloc = obj(&arena); - auto i64_type = TypeOps::atomic_type(alloc, Metatype::i64()); + auto i64_type = TypeOps::atomic_type(alloc, Metatype::t_i64()); auto list_i64_type = TypeOps::list_type(alloc, i64_type); REQUIRE(list_i64_type); @@ -44,7 +44,7 @@ namespace xo { REQUIRE(list_bool_type); REQUIRE(list_bool_type.is_equal_to(list_bool_type)); - auto any_type = TypeOps::atomic_type(alloc, Metatype::any()); + auto any_type = TypeOps::atomic_type(alloc, Metatype::t_any()); auto list_any_type = TypeOps::list_type(alloc, any_type); REQUIRE(list_any_type); From cacc139c033f1baf42d92ead719866d2b3740196 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 08:41:57 -0500 Subject: [PATCH 07/31] build: retiring REPR argument to xo_add_genfacetimpl() --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82cdc685..bfa7668d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-atomictype FACET_PKG xo_type FACET Type - REPR AtomicType +# REPR AtomicType INPUT idl/IType_DAtomicType.json5 ) @@ -44,7 +44,7 @@ xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-atomictype FACET_PKG xo_alloc2 FACET GCObject - REPR AtomicType +# REPR AtomicType INPUT idl/IGCObject_DAtomicType.json5 ) @@ -55,7 +55,7 @@ xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-listtype FACET_PKG xo_type FACET Type - REPR ListType +# REPR ListType INPUT idl/IType_DListType.json5 ) @@ -64,7 +64,7 @@ xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-listtype FACET_PKG xo_alloc2 FACET GCObject - REPR ListType +# REPR ListType INPUT idl/IGCObject_DListType.json5 ) @@ -75,7 +75,7 @@ xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-arraytype FACET_PKG xo_type FACET Type - REPR ArrayType +# REPR ArrayType INPUT idl/IType_DArrayType.json5 ) @@ -84,7 +84,7 @@ xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-arraytype FACET_PKG xo_alloc2 FACET GCObject - REPR ArrayType +# REPR ArrayType INPUT idl/IGCObject_DArrayType.json5 ) @@ -95,7 +95,7 @@ xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-functiontype FACET_PKG xo_type FACET Type - REPR FunctionType +# REPR FunctionType INPUT idl/IType_DFunctionType.json5 ) @@ -104,7 +104,7 @@ xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-functiontype FACET_PKG xo_alloc2 FACET GCObject - REPR FunctionType +# REPR FunctionType INPUT idl/IGCObject_DFunctionType.json5 ) From e4e27909b9e371baf227009662fded760e692e85 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 10:03:46 -0500 Subject: [PATCH 08/31] build: retire FACET argument to genfacetimpl --- CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfa7668d..0c7d3805 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,6 @@ xo_add_genfacet( xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-atomictype FACET_PKG xo_type - FACET Type # REPR AtomicType INPUT idl/IType_DAtomicType.json5 ) @@ -43,7 +42,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-atomictype FACET_PKG xo_alloc2 - FACET GCObject # REPR AtomicType INPUT idl/IGCObject_DAtomicType.json5 ) @@ -54,7 +52,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-listtype FACET_PKG xo_type - FACET Type # REPR ListType INPUT idl/IType_DListType.json5 ) @@ -63,7 +60,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-listtype FACET_PKG xo_alloc2 - FACET GCObject # REPR ListType INPUT idl/IGCObject_DListType.json5 ) @@ -74,7 +70,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-arraytype FACET_PKG xo_type - FACET Type # REPR ArrayType INPUT idl/IType_DArrayType.json5 ) @@ -83,7 +78,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-arraytype FACET_PKG xo_alloc2 - FACET GCObject # REPR ArrayType INPUT idl/IGCObject_DArrayType.json5 ) @@ -94,7 +88,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-functiontype FACET_PKG xo_type - FACET Type # REPR FunctionType INPUT idl/IType_DFunctionType.json5 ) @@ -103,7 +96,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-functiontype FACET_PKG xo_alloc2 - FACET GCObject # REPR FunctionType INPUT idl/IGCObject_DFunctionType.json5 ) From a911125605e84c78fc6f42b9ac7f1b5c65f8a677 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 14:13:48 -0500 Subject: [PATCH 09/31] xo-reader2: parse list types + utest --- include/xo/type/DListType.hpp | 5 ++++- src/type/DListType.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/xo/type/DListType.hpp b/include/xo/type/DListType.hpp index 51db9414..e19e48b2 100644 --- a/include/xo/type/DListType.hpp +++ b/include/xo/type/DListType.hpp @@ -32,9 +32,12 @@ namespace xo { explicit DListType(obj elt); - /** create instance using memory from @p mm with metatype @p mtype **/ + /** create instance using memory from @p mm with element type @p elt_type **/ static DListType * _make(obj mm, obj elt_type); + /** create fop to new instance using memory from @p mm with element type @p elt_type **/ + static obj make(obj mm, + obj elt_type); ///@} /** @defgroup xo-scm-listtype-type-facet **/ diff --git a/src/type/DListType.cpp b/src/type/DListType.cpp index 35b29235..47c8ea1f 100644 --- a/src/type/DListType.cpp +++ b/src/type/DListType.cpp @@ -31,6 +31,13 @@ namespace xo { return new (mem) DListType(elt_type); } + obj + DListType::make(obj mm, + obj elt_type) + { + return obj(_make(mm, elt_type)); + } + // ----- type facet ----- TypeDescr From 106ed35b525b459f1035277c63495c506fef86aa Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Mar 2026 20:31:46 -0500 Subject: [PATCH 10/31] xo-type: + TypeVarRef --- CMakeLists.txt | 16 ++++++++++++++++ src/type/CMakeLists.txt | 3 +++ src/type/type_register_facets.cpp | 13 +++++++++---- src/type/type_register_types.cpp | 2 ++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c7d3805..e61de986 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,22 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-type-facetimpl-type-typevarref + FACET_PKG xo_type + INPUT idl/IType_DTypeVarRef.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-type-facetimpl-gcobject-typevarref + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DTypeVarRef.json5 +) + +# ---------------------------------------------------------------- + xo_add_genfacet_all(xo-type-genfacet-all) install(DIRECTORY idl/ diff --git a/src/type/CMakeLists.txt b/src/type/CMakeLists.txt index 6d6cdcc1..d4203498 100644 --- a/src/type/CMakeLists.txt +++ b/src/type/CMakeLists.txt @@ -11,15 +11,18 @@ set(SELF_SRCS DListType.cpp DArrayType.cpp DFunctionType.cpp + DTypeVarRef.cpp IType_Any.cpp IType_DAtomicType.cpp IType_DListType.cpp IType_DArrayType.cpp IType_DFunctionType.cpp + IType_DTypeVarRef.cpp IGCObject_DAtomicType.cpp IGCObject_DListType.cpp IGCObject_DArrayType.cpp IGCObject_DFunctionType.cpp + IGCObject_DTypeVarRef.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/type/type_register_facets.cpp b/src/type/type_register_facets.cpp index 9cada7e0..047fb9fe 100644 --- a/src/type/type_register_facets.cpp +++ b/src/type/type_register_facets.cpp @@ -4,11 +4,12 @@ **/ #include "type_register_facets.hpp" +#include "AtomicType.hpp" +#include "ListType.hpp" +#include "ArrayType.hpp" +#include "FunctionType.hpp" +#include "TypeVarRef.hpp" -#include -#include -#include -#include #include #include @@ -36,10 +37,14 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DAtomicType.tseq", typeseq::id())); log && log(xtag("DListType.tseq", typeseq::id())); log && log(xtag("DArrayType.tseq", typeseq::id())); log && log(xtag("DFunctionType.tseq", typeseq::id())); + log && log(xtag("DTypeVarRef.tseq", typeseq::id())); return true; } diff --git a/src/type/type_register_types.cpp b/src/type/type_register_types.cpp index e031ce50..28e9f9af 100644 --- a/src/type/type_register_types.cpp +++ b/src/type/type_register_types.cpp @@ -9,6 +9,7 @@ #include "ListType.hpp" #include "ArrayType.hpp" #include "FunctionType.hpp" +#include "TypeVarRef.hpp" #include #include #include @@ -31,6 +32,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 e3a1d707235bff3358c840c75b3c290a002ff049 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Mar 2026 20:43:14 -0500 Subject: [PATCH 11/31] xo-procedure2: + type_ member [WIP] --- include/xo/type/Metatype.hpp | 4 ++++ src/type/Metatype.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/include/xo/type/Metatype.hpp b/include/xo/type/Metatype.hpp index 6fc193ae..30952df8 100644 --- a/include/xo/type/Metatype.hpp +++ b/include/xo/type/Metatype.hpp @@ -40,6 +40,9 @@ namespace xo { /* struct */ t_struct, + /* any numeric type: i16|i32|i64|f32|f64 */ + t_numeric, + /* any type at all */ t_any, }; @@ -64,6 +67,7 @@ namespace xo { static Metatype t_function() { return Metatype(code::t_function); } static Metatype t_struct() { return Metatype(code::t_struct); } + static Metatype t_numeric() { return Metatype(code::t_numeric); } static Metatype t_any() { return Metatype(code::t_any); } /** description string for this type category **/ diff --git a/src/type/Metatype.cpp b/src/type/Metatype.cpp index ca61d9c9..9e50f11a 100644 --- a/src/type/Metatype.cpp +++ b/src/type/Metatype.cpp @@ -29,6 +29,7 @@ namespace xo { case code::t_function: return "function"; case code::t_struct: return "struct"; + case code::t_numeric: return "numeric"; case code::t_any: return "any"; } } @@ -68,6 +69,8 @@ namespace xo { case code::t_struct: return false; + case code::t_numeric: + return true; case code::t_any: return true; } From 60a34aec87ebc9a579327a18510a736c9b3e9ad1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Mar 2026 20:43:43 -0500 Subject: [PATCH 12/31] xo-type: + DTypeVarRef --- idl/IGCObject_DTypeVar.json5 | 16 +++ idl/IGCObject_DTypeVarRef.json5 | 16 +++ idl/IType_DTypeVarRef.json5 | 16 +++ include/xo/type/TypeVarRef.hpp | 12 ++ include/xo/type/typevar/DTypeVarRef.hpp | 72 ++++++++++++ .../xo/type/typevar/IGCObject_DTypeVarRef.hpp | 65 +++++++++++ include/xo/type/typevar/IType_DTypeVarRef.hpp | 66 +++++++++++ src/type/DTypeVarRef.cpp | 103 ++++++++++++++++++ src/type/IGCObject_DTypeVar.cpp | 39 +++++++ src/type/IGCObject_DTypeVarRef.cpp | 39 +++++++ src/type/IType_DTypeVar.cpp | 46 ++++++++ src/type/IType_DTypeVarRef.cpp | 46 ++++++++ 12 files changed, 536 insertions(+) create mode 100644 idl/IGCObject_DTypeVar.json5 create mode 100644 idl/IGCObject_DTypeVarRef.json5 create mode 100644 idl/IType_DTypeVarRef.json5 create mode 100644 include/xo/type/TypeVarRef.hpp create mode 100644 include/xo/type/typevar/DTypeVarRef.hpp create mode 100644 include/xo/type/typevar/IGCObject_DTypeVarRef.hpp create mode 100644 include/xo/type/typevar/IType_DTypeVarRef.hpp create mode 100644 src/type/DTypeVarRef.cpp create mode 100644 src/type/IGCObject_DTypeVar.cpp create mode 100644 src/type/IGCObject_DTypeVarRef.cpp create mode 100644 src/type/IType_DTypeVar.cpp create mode 100644 src/type/IType_DTypeVarRef.cpp diff --git a/idl/IGCObject_DTypeVar.json5 b/idl/IGCObject_DTypeVar.json5 new file mode 100644 index 00000000..7e45e223 --- /dev/null +++ b/idl/IGCObject_DTypeVar.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "typevar", + includes: [ + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DTypeVar", + using_doxygen: true, + repr: "DTypeVar", + doc: [ "implement AGCObject for DTypeVar" ], +} diff --git a/idl/IGCObject_DTypeVarRef.json5 b/idl/IGCObject_DTypeVarRef.json5 new file mode 100644 index 00000000..e75802b5 --- /dev/null +++ b/idl/IGCObject_DTypeVarRef.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "typevar", + includes: [ + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DTypeVarRef", + using_doxygen: true, + repr: "DTypeVarRef", + doc: [ "implement AGCObject for DTypeVarRef" ], +} diff --git a/idl/IType_DTypeVarRef.json5 b/idl/IType_DTypeVarRef.json5 new file mode 100644 index 00000000..245b597c --- /dev/null +++ b/idl/IType_DTypeVarRef.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/type", + output_hpp_dir: "include/xo/type", + output_impl_subdir: "typevar", + includes: [], + local_types: [], + namespace1: "xo", + namespace2: "scm", + + facet_idl: "idl/Type.json5", + brief: "provide AType interface for DTypeVarRef", + using_doxygen: true, + repr: "DTypeVarRef", + doc: [ "implement AType for DTypeVarRef" ], +} diff --git a/include/xo/type/TypeVarRef.hpp b/include/xo/type/TypeVarRef.hpp new file mode 100644 index 00000000..10b80b18 --- /dev/null +++ b/include/xo/type/TypeVarRef.hpp @@ -0,0 +1,12 @@ +/** @file TypeVarRef.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "typevar/DTypeVarRef.hpp" +#include "typevar/IGCObject_DTypeVarRef.hpp" +#include "typevar/IType_DTypeVarRef.hpp" + +/* end TypeVarRef.hpp */ diff --git a/include/xo/type/typevar/DTypeVarRef.hpp b/include/xo/type/typevar/DTypeVarRef.hpp new file mode 100644 index 00000000..0f67ee1b --- /dev/null +++ b/include/xo/type/typevar/DTypeVarRef.hpp @@ -0,0 +1,72 @@ +/** @file DTypeVarRef.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "Type.hpp" +#include "Metatype.hpp" +#include +#include +#include + +namespace xo { + namespace scm { + /** @brief An atomic schematika type + * + * Types that are not parameterized by types or values. + * For example + * unit, bool, i64, f64 + * are atomic in this sense. + **/ + class DTypeVarRef { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + + public: + /** @defgroup xo-scm-typevarref-ctors constructors **/ + ///@{ + + explicit DTypeVarRef(const DUniqueString * name) : name_{name} {} + + /** create instance using memory from @p mm with metatype @p mtype **/ + static DTypeVarRef * _make(obj mm, const DUniqueString * name); + /** create instance **/ + static obj make(obj mm, const DUniqueString * name); + + ///@} + /** @defgroup xo-scm-typevarref-general-methods general methods **/ + ///@{ + + const DUniqueString * name() const noexcept { return name_; } + + ///@} + /** @defgroup xo-scm-atomictype-type-facet **/ + ///@{ + Metatype metatype() const noexcept; + TypeDescr repr_td() const noexcept; + bool is_equal_to(const obj & y) const noexcept; + bool is_subtype_of(const obj & y) const noexcept; + ///@} + /** @defgroup xo-scm-atomictype-gcobject-facet **/ + ///@{ + std::size_t shallow_size() const noexcept; + DTypeVarRef * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} + + private: + /** unique type-variable name **/ + const DUniqueString * name_ = nullptr; + + /** resolved type (if/when established) **/ + obj type_; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DTypeVarRef.hpp */ diff --git a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp new file mode 100644 index 00000000..876caaaa --- /dev/null +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp @@ -0,0 +1,65 @@ +/** @file IGCObject_DTypeVarRef.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DTypeVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DTypeVarRef.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include "DTypeVarRef.hpp" + +namespace xo { namespace scm { class IGCObject_DTypeVarRef; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DTypeVarRef + **/ + class IGCObject_DTypeVarRef { + public: + /** @defgroup scm-gcobject-dtypevarref-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-dtypevarref-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DTypeVarRef & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DTypeVarRef & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DTypeVarRef & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/type/typevar/IType_DTypeVarRef.hpp b/include/xo/type/typevar/IType_DTypeVarRef.hpp new file mode 100644 index 00000000..5386a284 --- /dev/null +++ b/include/xo/type/typevar/IType_DTypeVarRef.hpp @@ -0,0 +1,66 @@ +/** @file IType_DTypeVarRef.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DTypeVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DTypeVarRef.json5] + **/ + +#pragma once + +#include "Type.hpp" +#include "DTypeVarRef.hpp" + +namespace xo { namespace scm { class IType_DTypeVarRef; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IType_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IType_DTypeVarRef + **/ + class IType_DTypeVarRef { + public: + /** @defgroup scm-type-dtypevarref-type-traits **/ + ///@{ + using obj_AType = xo::scm::AType::obj_AType; + using TypeDescr = xo::scm::AType::TypeDescr; + using Copaque = xo::scm::AType::Copaque; + using Opaque = xo::scm::AType::Opaque; + ///@} + /** @defgroup scm-type-dtypevarref-methods **/ + ///@{ + // const methods + /** category for this type **/ + static Metatype metatype(const DTypeVarRef & self) noexcept; + /** reflected representation for instances of this type **/ + static TypeDescr repr_td(const DTypeVarRef & self) noexcept; + /** true iff this type is equal to y **/ + static bool is_equal_to(const DTypeVarRef & self, const obj_AType & y); + /** true iff this is a subtype of y **/ + static bool is_subtype_of(const DTypeVarRef & self, const obj_AType & y); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/type/DTypeVarRef.cpp b/src/type/DTypeVarRef.cpp new file mode 100644 index 00000000..88223ee3 --- /dev/null +++ b/src/type/DTypeVarRef.cpp @@ -0,0 +1,103 @@ +/** @file DTypeVarRef.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "Metatype.hpp" +#include "TypeVarRef.hpp" +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::reflect::Reflect; + using xo::reflect::TypeDescr; + using xo::facet::FacetRegistry; + + namespace scm { + + DTypeVarRef * + DTypeVarRef::_make(obj mm, const DUniqueString * name) + { + void * mem = mm.alloc_for(); + + return new (mem) DTypeVarRef(name); + } + + obj + DTypeVarRef::make(obj mm, const DUniqueString * name) + { + return obj(_make(mm, name)); + } + + // ----- Type facet ----- + + Metatype + DTypeVarRef::metatype() const noexcept + { + if (type_) { + // resolved typevar reference + + return type_.metatype(); + } else { + // type var reference, not yet resolved + + return Metatype::t_any(); + } + } + + TypeDescr + DTypeVarRef::repr_td() const noexcept + { + return Reflect::require(); + } + + bool + DTypeVarRef::is_equal_to(const obj & y) const noexcept + { + // not really well-defined until types are resolved + + return (this->metatype().code() == y.metatype().code()); + } + + bool + DTypeVarRef::is_subtype_of(const obj & y) const noexcept + { + Metatype x_mtype = this->metatype(); + Metatype y_mtype = y.metatype(); + + if (y_mtype.code() == Metatype::code::t_any) + return true; + + return (x_mtype.code() == y_mtype.code()); + } + + // ----- GCObject facet ----- + + std::size_t + DTypeVarRef::shallow_size() const noexcept + { + return sizeof(DTypeVarRef); + } + + DTypeVarRef * + DTypeVarRef::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DTypeVarRef::forward_children(obj gc) noexcept + { + { + auto e = FacetRegistry::instance().variant(type_); + gc.forward_inplace(e.iface(), (void **)&type_.data_); + } + + return this->shallow_size(); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DTypeVarRef.cpp */ diff --git a/src/type/IGCObject_DTypeVar.cpp b/src/type/IGCObject_DTypeVar.cpp new file mode 100644 index 00000000..799cf663 --- /dev/null +++ b/src/type/IGCObject_DTypeVar.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DTypeVar.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DTypeVar.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DTypeVar.json5] +**/ + +#include "typevar/IGCObject_DTypeVar.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DTypeVar::shallow_size(const DTypeVar & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DTypeVar::shallow_copy(const DTypeVar & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DTypeVar::forward_children(DTypeVar & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DTypeVar.cpp */ diff --git a/src/type/IGCObject_DTypeVarRef.cpp b/src/type/IGCObject_DTypeVarRef.cpp new file mode 100644 index 00000000..c0aeb3bc --- /dev/null +++ b/src/type/IGCObject_DTypeVarRef.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DTypeVarRef.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DTypeVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DTypeVarRef.json5] +**/ + +#include "typevar/IGCObject_DTypeVarRef.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DTypeVarRef::shallow_size(const DTypeVarRef & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DTypeVarRef::shallow_copy(const DTypeVarRef & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DTypeVarRef::forward_children(DTypeVarRef & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DTypeVarRef.cpp */ diff --git a/src/type/IType_DTypeVar.cpp b/src/type/IType_DTypeVar.cpp new file mode 100644 index 00000000..16397beb --- /dev/null +++ b/src/type/IType_DTypeVar.cpp @@ -0,0 +1,46 @@ +/** @file IType_DTypeVar.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DTypeVar.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DTypeVar.json5] +**/ + +#include "typevar/IType_DTypeVar.hpp" + +namespace xo { + namespace scm { + auto + IType_DTypeVar::metatype(const DTypeVar & self) noexcept -> Metatype + { + return self.metatype(); + } + + auto + IType_DTypeVar::repr_td(const DTypeVar & self) noexcept -> TypeDescr + { + return self.repr_td(); + } + + auto + IType_DTypeVar::is_equal_to(const DTypeVar & self, const obj_AType & y) -> bool + { + return self.is_equal_to(y); + } + + auto + IType_DTypeVar::is_subtype_of(const DTypeVar & self, const obj_AType & y) -> bool + { + return self.is_subtype_of(y); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IType_DTypeVar.cpp */ diff --git a/src/type/IType_DTypeVarRef.cpp b/src/type/IType_DTypeVarRef.cpp new file mode 100644 index 00000000..f1ce54ce --- /dev/null +++ b/src/type/IType_DTypeVarRef.cpp @@ -0,0 +1,46 @@ +/** @file IType_DTypeVarRef.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IType_DTypeVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IType_DTypeVarRef.json5] +**/ + +#include "typevar/IType_DTypeVarRef.hpp" + +namespace xo { + namespace scm { + auto + IType_DTypeVarRef::metatype(const DTypeVarRef & self) noexcept -> Metatype + { + return self.metatype(); + } + + auto + IType_DTypeVarRef::repr_td(const DTypeVarRef & self) noexcept -> TypeDescr + { + return self.repr_td(); + } + + auto + IType_DTypeVarRef::is_equal_to(const DTypeVarRef & self, const obj_AType & y) -> bool + { + return self.is_equal_to(y); + } + + auto + IType_DTypeVarRef::is_subtype_of(const DTypeVarRef & self, const obj_AType & y) -> bool + { + return self.is_subtype_of(y); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IType_DTypeVarRef.cpp */ From bc4f80e29b556c9ea753e6bf76fa54ea4022ae9a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 09:03:24 -0500 Subject: [PATCH 13/31] xo-interpreter2 stack: + dict type + pop more pm types --- include/xo/type/DFunctionType.hpp | 32 ++++++++++++++++++++++++++----- include/xo/type/Metatype.hpp | 9 ++++++++- src/type/Metatype.cpp | 6 ++++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/include/xo/type/DFunctionType.hpp b/include/xo/type/DFunctionType.hpp index 7090a60b..51568bf5 100644 --- a/include/xo/type/DFunctionType.hpp +++ b/include/xo/type/DFunctionType.hpp @@ -32,17 +32,27 @@ namespace xo { * for a function with return type @p ret_type and arguments @p args **/ template - requires (std::same_as> && ...) + requires (std::convertible_to> && ...) explicit DFunctionType(obj mm, obj ret_type, Args... args); /** create instance using memory from @p mm, * for a function with return type @p ret_type and arguments @p args **/ template - requires (std::same_as> && ...) + requires (std::convertible_to> && ...) static DFunctionType * _make(obj mm, obj ret_type, Args... args); +#ifdef NOT_USING + /** create instance using memory from @p mm + * for function with return type @p ret_type and arguments @p args + **/ + template + requires (std::same_as> && ...) + static obj make(obj mm, + obj ret_type, Args... args); +#endif + ///@} /** @defgroup xo-scm-arraytype-type-facet **/ ///@{ @@ -72,14 +82,14 @@ namespace xo { }; template - requires (std::same_as> && ...) + requires (std::convertible_to> && ...) DFunctionType::DFunctionType(obj mm, obj return_type, Args... args) : return_type_{return_type}, - arg_types_{DArray::array(mm, args...)} + arg_types_{DArray::array(mm, args.template to_facet()...)} {} template - requires (std::same_as> && ...) + requires (std::convertible_to> && ...) DFunctionType * DFunctionType::_make(obj mm, obj ret_type, Args... args) { @@ -88,6 +98,18 @@ namespace xo { return new (mem) DFunctionType(mm, ret_type, args...); } +#ifdef NOT_USING + template + requires (std::same_as> && ...) + obj + DFunctionType::make(obj mm, obj ret_type, Args... args) + { + void * mem = mm.alloc_for(); + + return obj(_make(mm, ret_type, args...)); + } +#endif + } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/type/Metatype.hpp b/include/xo/type/Metatype.hpp index 30952df8..0b0aeefe 100644 --- a/include/xo/type/Metatype.hpp +++ b/include/xo/type/Metatype.hpp @@ -39,8 +39,13 @@ namespace xo { t_function, /* struct */ t_struct, + /* dicttionary: like struct, but w/ dynamic key/value pairs */ + t_dict, - /* any numeric type: i16|i32|i64|f32|f64 */ + /** any integer type: i16|i32|i64 **/ + t_integer, + + /** any numeric type: i16|i32|i64|f32|f64 **/ t_numeric, /* any type at all */ @@ -66,7 +71,9 @@ namespace xo { static Metatype t_array() { return Metatype(code::t_array); } static Metatype t_function() { return Metatype(code::t_function); } static Metatype t_struct() { return Metatype(code::t_struct); } + static Metatype t_dict() { return Metatype(code::t_dict); } + static Metatype t_integer() { return Metatype(code::t_integer); } static Metatype t_numeric() { return Metatype(code::t_numeric); } static Metatype t_any() { return Metatype(code::t_any); } diff --git a/src/type/Metatype.cpp b/src/type/Metatype.cpp index 9e50f11a..be42f61c 100644 --- a/src/type/Metatype.cpp +++ b/src/type/Metatype.cpp @@ -28,7 +28,9 @@ namespace xo { case code::t_array: return "array"; case code::t_function: return "function"; case code::t_struct: return "struct"; + case code::t_dict: return "dict"; + case code::t_integer: return "integer"; case code::t_numeric: return "numeric"; case code::t_any: return "any"; } @@ -68,7 +70,11 @@ namespace xo { return false; case code::t_struct: return false; + case code::t_dict: + return true; + case code::t_integer: + return true; case code::t_numeric: return true; case code::t_any: From 67228c0dc9a317891c6a701a8fa034071289aa6b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 12:34:59 -0500 Subject: [PATCH 14/31] xo-interpreter2 stack: + more primitive function-type decoration --- include/xo/type/Metatype.hpp | 6 +++++- src/type/Metatype.cpp | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/xo/type/Metatype.hpp b/include/xo/type/Metatype.hpp index 0b0aeefe..8f7fc628 100644 --- a/include/xo/type/Metatype.hpp +++ b/include/xo/type/Metatype.hpp @@ -48,6 +48,9 @@ namespace xo { /** any numeric type: i16|i32|i64|f32|f64 **/ t_numeric, + /** any callable type (e.g. all function types) **/ + t_callable, + /* any type at all */ t_any, }; @@ -71,10 +74,11 @@ namespace xo { static Metatype t_array() { return Metatype(code::t_array); } static Metatype t_function() { return Metatype(code::t_function); } static Metatype t_struct() { return Metatype(code::t_struct); } - static Metatype t_dict() { return Metatype(code::t_dict); } + static Metatype t_dict() { return Metatype(code::t_dict); } static Metatype t_integer() { return Metatype(code::t_integer); } static Metatype t_numeric() { return Metatype(code::t_numeric); } + static Metatype t_callable() { return Metatype(code::t_callable); } static Metatype t_any() { return Metatype(code::t_any); } /** description string for this type category **/ diff --git a/src/type/Metatype.cpp b/src/type/Metatype.cpp index be42f61c..aa1a1bb2 100644 --- a/src/type/Metatype.cpp +++ b/src/type/Metatype.cpp @@ -32,6 +32,7 @@ namespace xo { case code::t_integer: return "integer"; case code::t_numeric: return "numeric"; + case code::t_callable: return "callable"; case code::t_any: return "any"; } } @@ -77,6 +78,8 @@ namespace xo { return true; case code::t_numeric: return true; + case code::t_callable: + return true; case code::t_any: return true; } From c8d08133ae76b3964992501e627afd7bdb6120fe Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 13:51:51 -0500 Subject: [PATCH 15/31] xo-numeric: attach type to numeric primitives --- include/xo/type/Metatype.hpp | 4 ++++ src/type/Metatype.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/include/xo/type/Metatype.hpp b/include/xo/type/Metatype.hpp index 8f7fc628..9ff612aa 100644 --- a/include/xo/type/Metatype.hpp +++ b/include/xo/type/Metatype.hpp @@ -48,6 +48,9 @@ namespace xo { /** any numeric type: i16|i32|i64|f32|f64 **/ t_numeric, + /** generalized boolean type: bool, function with bool codomain **/ + t_booleic, + /** any callable type (e.g. all function types) **/ t_callable, @@ -78,6 +81,7 @@ namespace xo { static Metatype t_dict() { return Metatype(code::t_dict); } static Metatype t_integer() { return Metatype(code::t_integer); } static Metatype t_numeric() { return Metatype(code::t_numeric); } + static Metatype t_booleic() { return Metatype(code::t_booleic); } static Metatype t_callable() { return Metatype(code::t_callable); } static Metatype t_any() { return Metatype(code::t_any); } diff --git a/src/type/Metatype.cpp b/src/type/Metatype.cpp index aa1a1bb2..1ac26f62 100644 --- a/src/type/Metatype.cpp +++ b/src/type/Metatype.cpp @@ -31,6 +31,7 @@ namespace xo { case code::t_dict: return "dict"; case code::t_integer: return "integer"; + case code::t_booleic: return "booleic"; case code::t_numeric: return "numeric"; case code::t_callable: return "callable"; case code::t_any: return "any"; @@ -76,6 +77,8 @@ namespace xo { case code::t_integer: return true; + case code::t_booleic: + return true; case code::t_numeric: return true; case code::t_callable: From 2844e5b6ee75084514dab07cc06e3a64cfe81688 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 15:10:53 -0500 Subject: [PATCH 16/31] xo-type: streamline setup --- include/xo/type/SetupType.hpp | 25 +++++++++++ include/xo/type/type_register_facets.hpp | 15 ------- include/xo/type/type_register_types.hpp | 17 -------- src/type/CMakeLists.txt | 3 +- ...type_register_facets.cpp => SetupType.cpp} | 24 +++++++++-- src/type/init_type.cpp | 10 ++--- src/type/type_register_types.cpp | 42 ------------------- 7 files changed, 50 insertions(+), 86 deletions(-) create mode 100644 include/xo/type/SetupType.hpp delete mode 100644 include/xo/type/type_register_facets.hpp delete mode 100644 include/xo/type/type_register_types.hpp rename src/type/{type_register_facets.cpp => SetupType.cpp} (70%) delete mode 100644 src/type/type_register_types.cpp diff --git a/include/xo/type/SetupType.hpp b/include/xo/type/SetupType.hpp new file mode 100644 index 00000000..93304907 --- /dev/null +++ b/include/xo/type/SetupType.hpp @@ -0,0 +1,25 @@ +/** @file SetupType.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + struct SetupType { + public: + using ACollector = xo::mm::ACollector; + + public: + /** Register type (facet,impl) combinations with FacetRegistry **/ + static bool register_facets(); + /** Register type (facet,impl) combinations with FacetRegistry **/ + static bool register_types(obj gc); + }; + } +} + +/* end SetupType.hpp */ diff --git a/include/xo/type/type_register_facets.hpp b/include/xo/type/type_register_facets.hpp deleted file mode 100644 index f418eab5..00000000 --- a/include/xo/type/type_register_facets.hpp +++ /dev/null @@ -1,15 +0,0 @@ -/** @file type_register_facets.hpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#pragma once - -namespace xo { - namespace scm { - /** Register type (facet,impl) combinations with FacetRegistry **/ - bool type_register_facets(); - } -} - -/* end type_register_facets.hpp */ diff --git a/include/xo/type/type_register_types.hpp b/include/xo/type/type_register_types.hpp deleted file mode 100644 index 5ab1db0d..00000000 --- a/include/xo/type/type_register_types.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/** @file type_register_types.hpp - * - * @author Roland Conybeare, Dec 2025 - **/ - -#pragma once - -#include - -namespace xo { - namespace scm { - /** Register type (facet,impl) combinations with FacetRegistry **/ - bool type_register_types(obj gc); - } -} - -/* end type_register_types.hpp */ diff --git a/src/type/CMakeLists.txt b/src/type/CMakeLists.txt index d4203498..59f2b9ff 100644 --- a/src/type/CMakeLists.txt +++ b/src/type/CMakeLists.txt @@ -3,8 +3,7 @@ set(SELF_LIB xo_type) set(SELF_SRCS init_type.cpp - type_register_facets.cpp - type_register_types.cpp + SetupType.cpp TypeOps.cpp Metatype.cpp DAtomicType.cpp diff --git a/src/type/type_register_facets.cpp b/src/type/SetupType.cpp similarity index 70% rename from src/type/type_register_facets.cpp rename to src/type/SetupType.cpp index 047fb9fe..ff5f4988 100644 --- a/src/type/type_register_facets.cpp +++ b/src/type/SetupType.cpp @@ -1,9 +1,9 @@ -/** @file type_register_facets.cpp +/** @file SetupType.cpp * * @author Roland Conybeare, Feb 2026 **/ -#include "type_register_facets.hpp" +#include "SetupType.hpp" #include "AtomicType.hpp" #include "ListType.hpp" #include "ArrayType.hpp" @@ -16,12 +16,13 @@ namespace xo { using xo::mm::AGCObject; using xo::facet::FacetRegistry; + using xo::facet::impl_for; using xo::reflect::typeseq; namespace scm { bool - type_register_facets() + SetupType::register_facets() { scope log(XO_DEBUG(true)); @@ -49,7 +50,22 @@ namespace xo { return true; } + bool + SetupType::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()); + + return ok; + } } /*namespace scm*/ } /*namespace xo*/ -/* end type_register_facets.cpp */ +/* end SetupType.cpp */ diff --git a/src/type/init_type.cpp b/src/type/init_type.cpp index bbae93d2..6a544396 100644 --- a/src/type/init_type.cpp +++ b/src/type/init_type.cpp @@ -4,22 +4,20 @@ **/ #include "init_type.hpp" -#include "type_register_facets.hpp" -#include "type_register_types.hpp" +#include "SetupType.hpp" #include #include namespace xo { - using xo::scm::type_register_facets; - using xo::scm::type_register_types; + using xo::scm::SetupType; using xo::mm::CollectorTypeRegistry; void InitSubsys::init() { - type_register_facets(); + SetupType::register_facets(); - CollectorTypeRegistry::instance().register_types(&type_register_types); + CollectorTypeRegistry::instance().register_types(&SetupType::register_types); } InitEvidence diff --git a/src/type/type_register_types.cpp b/src/type/type_register_types.cpp deleted file mode 100644 index 28e9f9af..00000000 --- a/src/type/type_register_types.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/** @file type_register_types.cpp - * - * @author Roland Conybeare, Dec 2025 - **/ - -#include "type_register_types.hpp" - -#include "AtomicType.hpp" -#include "ListType.hpp" -#include "ArrayType.hpp" -#include "FunctionType.hpp" -#include "TypeVarRef.hpp" -#include -#include -#include - -namespace xo { - using xo::mm::ACollector; - using xo::mm::AGCObject; - using xo::facet::impl_for; - using xo::scope; - - namespace scm { - bool - type_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()); - - return ok; - } - } -} /*namespace xo*/ - -/* end type_register_types.cpp */ From 39c80aed06690498b2a684598604a870d699feb6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Mar 2026 12:28:12 -0400 Subject: [PATCH 17/31] xo-type: nit: need return value even on impossible paths --- src/type/Metatype.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/type/Metatype.cpp b/src/type/Metatype.cpp index 1ac26f62..1eb0138e 100644 --- a/src/type/Metatype.cpp +++ b/src/type/Metatype.cpp @@ -4,6 +4,7 @@ **/ #include "Metatype.hpp" +#include namespace xo { namespace scm { @@ -36,6 +37,9 @@ namespace xo { case code::t_callable: return "callable"; case code::t_any: return "any"; } + + assert(false); + return "?metatype"; } bool @@ -86,6 +90,9 @@ namespace xo { case code::t_any: return true; } + + assert(false); + return false; } } /*namespace scm*/ From 41e1f060799f2f9b06e3e4440adf5f2ce6c9a341 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 17:43:45 -0400 Subject: [PATCH 18/31] xo-reader2: + SyntaxStateMachine.forward_children method Support gc traversal with goal of making ParserStateMachine a gc root --- src/type/DTypeVarRef.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/type/DTypeVarRef.cpp b/src/type/DTypeVarRef.cpp index 88223ee3..8da0ec0a 100644 --- a/src/type/DTypeVarRef.cpp +++ b/src/type/DTypeVarRef.cpp @@ -6,6 +6,7 @@ #include "Metatype.hpp" #include "TypeVarRef.hpp" #include +#include #include namespace xo { @@ -89,10 +90,12 @@ namespace xo { std::size_t DTypeVarRef::forward_children(obj gc) noexcept { - { - auto e = FacetRegistry::instance().variant(type_); - gc.forward_inplace(e.iface(), (void **)&type_.data_); - } + gc.forward_pivot_inplace(&type_); + + //{ + // auto e = FacetRegistry::instance().variant(type_); + // gc.forward_inplace(e.iface(), (void **)&type_.data_); + //} return this->shallow_size(); } From 96fccec7dca542d6b5d94f963f731c05c8949de4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 14:38:14 -0400 Subject: [PATCH 19/31] refactor: make AGCObject.shallow_copy() non-const prep for moving to ACollector interface --- include/xo/type/DArrayType.hpp | 2 +- include/xo/type/DAtomicType.hpp | 2 +- include/xo/type/DFunctionType.hpp | 2 +- include/xo/type/DListType.hpp | 2 +- include/xo/type/array/IGCObject_DArrayType.hpp | 4 ++-- include/xo/type/atomic/IGCObject_DAtomicType.hpp | 4 ++-- include/xo/type/function/IGCObject_DFunctionType.hpp | 4 ++-- include/xo/type/list/IGCObject_DListType.hpp | 4 ++-- include/xo/type/type/AType.hpp | 5 +++++ include/xo/type/typevar/DTypeVarRef.hpp | 2 +- include/xo/type/typevar/IGCObject_DTypeVarRef.hpp | 4 ++-- src/type/DArrayType.cpp | 2 +- src/type/DAtomicType.cpp | 2 +- src/type/DFunctionType.cpp | 2 +- src/type/DListType.cpp | 2 +- src/type/DTypeVarRef.cpp | 2 +- src/type/IGCObject_DArrayType.cpp | 3 +-- src/type/IGCObject_DAtomicType.cpp | 3 +-- src/type/IGCObject_DFunctionType.cpp | 3 +-- src/type/IGCObject_DListType.cpp | 3 +-- src/type/IGCObject_DTypeVarRef.cpp | 3 +-- 21 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/xo/type/DArrayType.hpp b/include/xo/type/DArrayType.hpp index a8efe329..2d12f19b 100644 --- a/include/xo/type/DArrayType.hpp +++ b/include/xo/type/DArrayType.hpp @@ -42,7 +42,7 @@ namespace xo { /** @defgroup xo-scm-arraytype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DArrayType * shallow_copy(obj mm) const noexcept; + DArrayType * shallow_copy(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DAtomicType.hpp b/include/xo/type/DAtomicType.hpp index 6cd11ba5..406ed469 100644 --- a/include/xo/type/DAtomicType.hpp +++ b/include/xo/type/DAtomicType.hpp @@ -43,7 +43,7 @@ namespace xo { /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DAtomicType * shallow_copy(obj mm) const noexcept; + DAtomicType * shallow_copy(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DFunctionType.hpp b/include/xo/type/DFunctionType.hpp index 51568bf5..c3d409d6 100644 --- a/include/xo/type/DFunctionType.hpp +++ b/include/xo/type/DFunctionType.hpp @@ -64,7 +64,7 @@ namespace xo { /** @defgroup xo-scm-arraytype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DFunctionType * shallow_copy(obj mm) const noexcept; + DFunctionType * shallow_copy(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DListType.hpp b/include/xo/type/DListType.hpp index e19e48b2..8b5e057a 100644 --- a/include/xo/type/DListType.hpp +++ b/include/xo/type/DListType.hpp @@ -50,7 +50,7 @@ namespace xo { /** @defgroup xo-scm-listtype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DListType * shallow_copy(obj mm) const noexcept; + DListType * shallow_copy(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp index bb71960f..a436a089 100644 --- a/include/xo/type/array/IGCObject_DArrayType.hpp +++ b/include/xo/type/array/IGCObject_DArrayType.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DArrayType & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DArrayType & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DArrayType & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DArrayType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp index c1fff453..4a5a5700 100644 --- a/include/xo/type/atomic/IGCObject_DAtomicType.hpp +++ b/include/xo/type/atomic/IGCObject_DAtomicType.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DAtomicType & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DAtomicType & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DAtomicType & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DAtomicType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp index 431c19e8..bc632857 100644 --- a/include/xo/type/function/IGCObject_DFunctionType.hpp +++ b/include/xo/type/function/IGCObject_DFunctionType.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DFunctionType & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DFunctionType & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DFunctionType & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DFunctionType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp index 6393d35b..cd017ec0 100644 --- a/include/xo/type/list/IGCObject_DListType.hpp +++ b/include/xo/type/list/IGCObject_DListType.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DListType & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DListType & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DListType & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DListType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/type/AType.hpp b/include/xo/type/type/AType.hpp index d0e8361f..018c0f54 100644 --- a/include/xo/type/type/AType.hpp +++ b/include/xo/type/type/AType.hpp @@ -50,6 +50,11 @@ public: /** @defgroup scm-type-methods **/ ///@{ // const methods + /** An uninitialized AType 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/include/xo/type/typevar/DTypeVarRef.hpp b/include/xo/type/typevar/DTypeVarRef.hpp index 0f67ee1b..d53caa0c 100644 --- a/include/xo/type/typevar/DTypeVarRef.hpp +++ b/include/xo/type/typevar/DTypeVarRef.hpp @@ -54,7 +54,7 @@ namespace xo { /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DTypeVarRef * shallow_copy(obj mm) const noexcept; + DTypeVarRef * shallow_copy(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp index 876caaaa..56780e3e 100644 --- a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DTypeVarRef & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DTypeVarRef & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DTypeVarRef & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DTypeVarRef & self, obj gc) noexcept; ///@} diff --git a/src/type/DArrayType.cpp b/src/type/DArrayType.cpp index 652186ab..f13f234a 100644 --- a/src/type/DArrayType.cpp +++ b/src/type/DArrayType.cpp @@ -83,7 +83,7 @@ namespace xo { } DArrayType * - DArrayType::shallow_copy(obj mm) const noexcept + DArrayType::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/type/DAtomicType.cpp b/src/type/DAtomicType.cpp index bc2fe558..347e7f5f 100644 --- a/src/type/DAtomicType.cpp +++ b/src/type/DAtomicType.cpp @@ -61,7 +61,7 @@ namespace xo { } DAtomicType * - DAtomicType::shallow_copy(obj mm) const noexcept + DAtomicType::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/type/DFunctionType.cpp b/src/type/DFunctionType.cpp index 88de628b..4cc83dba 100644 --- a/src/type/DFunctionType.cpp +++ b/src/type/DFunctionType.cpp @@ -94,7 +94,7 @@ namespace xo { } DFunctionType * - DFunctionType::shallow_copy(obj mm) const noexcept + DFunctionType::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/type/DListType.cpp b/src/type/DListType.cpp index 47c8ea1f..b4e2cd4e 100644 --- a/src/type/DListType.cpp +++ b/src/type/DListType.cpp @@ -88,7 +88,7 @@ namespace xo { } DListType * - DListType::shallow_copy(obj mm) const noexcept + DListType::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/type/DTypeVarRef.cpp b/src/type/DTypeVarRef.cpp index 8da0ec0a..ec021ab6 100644 --- a/src/type/DTypeVarRef.cpp +++ b/src/type/DTypeVarRef.cpp @@ -82,7 +82,7 @@ namespace xo { } DTypeVarRef * - DTypeVarRef::shallow_copy(obj mm) const noexcept + DTypeVarRef::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/type/IGCObject_DArrayType.cpp b/src/type/IGCObject_DArrayType.cpp index 936f8eec..43287c83 100644 --- a/src/type/IGCObject_DArrayType.cpp +++ b/src/type/IGCObject_DArrayType.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DArrayType::shallow_copy(const DArrayType & self, obj mm) noexcept -> Opaque + IGCObject_DArrayType::shallow_copy(DArrayType & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DArrayType::forward_children(DArrayType & self, obj gc) noexcept -> size_type { diff --git a/src/type/IGCObject_DAtomicType.cpp b/src/type/IGCObject_DAtomicType.cpp index 17f3a56a..a5691676 100644 --- a/src/type/IGCObject_DAtomicType.cpp +++ b/src/type/IGCObject_DAtomicType.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DAtomicType::shallow_copy(const DAtomicType & self, obj mm) noexcept -> Opaque + IGCObject_DAtomicType::shallow_copy(DAtomicType & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DAtomicType::forward_children(DAtomicType & self, obj gc) noexcept -> size_type { diff --git a/src/type/IGCObject_DFunctionType.cpp b/src/type/IGCObject_DFunctionType.cpp index 45141b3a..9ba3ff39 100644 --- a/src/type/IGCObject_DFunctionType.cpp +++ b/src/type/IGCObject_DFunctionType.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DFunctionType::shallow_copy(const DFunctionType & self, obj mm) noexcept -> Opaque + IGCObject_DFunctionType::shallow_copy(DFunctionType & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DFunctionType::forward_children(DFunctionType & self, obj gc) noexcept -> size_type { diff --git a/src/type/IGCObject_DListType.cpp b/src/type/IGCObject_DListType.cpp index 761ae617..da899cd9 100644 --- a/src/type/IGCObject_DListType.cpp +++ b/src/type/IGCObject_DListType.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DListType::shallow_copy(const DListType & self, obj mm) noexcept -> Opaque + IGCObject_DListType::shallow_copy(DListType & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DListType::forward_children(DListType & self, obj gc) noexcept -> size_type { diff --git a/src/type/IGCObject_DTypeVarRef.cpp b/src/type/IGCObject_DTypeVarRef.cpp index c0aeb3bc..ade79944 100644 --- a/src/type/IGCObject_DTypeVarRef.cpp +++ b/src/type/IGCObject_DTypeVarRef.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DTypeVarRef::shallow_copy(const DTypeVarRef & self, obj mm) noexcept -> Opaque + IGCObject_DTypeVarRef::shallow_copy(DTypeVarRef & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DTypeVarRef::forward_children(DTypeVarRef & self, obj gc) noexcept -> size_type { From f7b8c62305030004ad9c3e7ad575d0e9f669f41b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 15:00:53 -0400 Subject: [PATCH 20/31] refactor: rename GCObject.shallow_copy -> shallow_move resolve conflict since relying on move constructor in std_copy_for --- include/xo/type/DArrayType.hpp | 2 +- include/xo/type/DAtomicType.hpp | 2 +- include/xo/type/DFunctionType.hpp | 2 +- include/xo/type/DListType.hpp | 2 +- include/xo/type/array/IGCObject_DArrayType.hpp | 4 ++-- include/xo/type/atomic/IGCObject_DAtomicType.hpp | 4 ++-- include/xo/type/function/IGCObject_DFunctionType.hpp | 4 ++-- include/xo/type/list/IGCObject_DListType.hpp | 4 ++-- include/xo/type/typevar/DTypeVarRef.hpp | 2 +- include/xo/type/typevar/IGCObject_DTypeVarRef.hpp | 4 ++-- src/type/DArrayType.cpp | 2 +- src/type/DAtomicType.cpp | 2 +- src/type/DFunctionType.cpp | 2 +- src/type/DListType.cpp | 2 +- src/type/DTypeVarRef.cpp | 2 +- src/type/IGCObject_DArrayType.cpp | 4 ++-- src/type/IGCObject_DAtomicType.cpp | 4 ++-- src/type/IGCObject_DFunctionType.cpp | 4 ++-- src/type/IGCObject_DListType.cpp | 4 ++-- src/type/IGCObject_DTypeVarRef.cpp | 4 ++-- 20 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/xo/type/DArrayType.hpp b/include/xo/type/DArrayType.hpp index 2d12f19b..a2594649 100644 --- a/include/xo/type/DArrayType.hpp +++ b/include/xo/type/DArrayType.hpp @@ -42,7 +42,7 @@ namespace xo { /** @defgroup xo-scm-arraytype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DArrayType * shallow_copy(obj mm) noexcept; + DArrayType * shallow_move(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DAtomicType.hpp b/include/xo/type/DAtomicType.hpp index 406ed469..7661955c 100644 --- a/include/xo/type/DAtomicType.hpp +++ b/include/xo/type/DAtomicType.hpp @@ -43,7 +43,7 @@ namespace xo { /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DAtomicType * shallow_copy(obj mm) noexcept; + DAtomicType * shallow_move(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DFunctionType.hpp b/include/xo/type/DFunctionType.hpp index c3d409d6..328c93b3 100644 --- a/include/xo/type/DFunctionType.hpp +++ b/include/xo/type/DFunctionType.hpp @@ -64,7 +64,7 @@ namespace xo { /** @defgroup xo-scm-arraytype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DFunctionType * shallow_copy(obj mm) noexcept; + DFunctionType * shallow_move(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DListType.hpp b/include/xo/type/DListType.hpp index 8b5e057a..2dfedb27 100644 --- a/include/xo/type/DListType.hpp +++ b/include/xo/type/DListType.hpp @@ -50,7 +50,7 @@ namespace xo { /** @defgroup xo-scm-listtype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DListType * shallow_copy(obj mm) noexcept; + DListType * shallow_move(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp index a436a089..8c1bfeee 100644 --- a/include/xo/type/array/IGCObject_DArrayType.hpp +++ b/include/xo/type/array/IGCObject_DArrayType.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DArrayType & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DArrayType & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DArrayType & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DArrayType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp index 4a5a5700..00763e4a 100644 --- a/include/xo/type/atomic/IGCObject_DAtomicType.hpp +++ b/include/xo/type/atomic/IGCObject_DAtomicType.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DAtomicType & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DAtomicType & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DAtomicType & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DAtomicType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp index bc632857..9c8727cd 100644 --- a/include/xo/type/function/IGCObject_DFunctionType.hpp +++ b/include/xo/type/function/IGCObject_DFunctionType.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DFunctionType & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DFunctionType & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DFunctionType & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DFunctionType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp index cd017ec0..2459fff4 100644 --- a/include/xo/type/list/IGCObject_DListType.hpp +++ b/include/xo/type/list/IGCObject_DListType.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DListType & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DListType & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DListType & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DListType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/typevar/DTypeVarRef.hpp b/include/xo/type/typevar/DTypeVarRef.hpp index d53caa0c..4ce9a667 100644 --- a/include/xo/type/typevar/DTypeVarRef.hpp +++ b/include/xo/type/typevar/DTypeVarRef.hpp @@ -54,7 +54,7 @@ namespace xo { /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DTypeVarRef * shallow_copy(obj mm) noexcept; + DTypeVarRef * shallow_move(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp index 56780e3e..d0250871 100644 --- a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DTypeVarRef & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DTypeVarRef & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DTypeVarRef & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DTypeVarRef & self, obj gc) noexcept; ///@} diff --git a/src/type/DArrayType.cpp b/src/type/DArrayType.cpp index f13f234a..b7c628af 100644 --- a/src/type/DArrayType.cpp +++ b/src/type/DArrayType.cpp @@ -83,7 +83,7 @@ namespace xo { } DArrayType * - DArrayType::shallow_copy(obj mm) noexcept + DArrayType::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/type/DAtomicType.cpp b/src/type/DAtomicType.cpp index 347e7f5f..f25a159e 100644 --- a/src/type/DAtomicType.cpp +++ b/src/type/DAtomicType.cpp @@ -61,7 +61,7 @@ namespace xo { } DAtomicType * - DAtomicType::shallow_copy(obj mm) noexcept + DAtomicType::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/type/DFunctionType.cpp b/src/type/DFunctionType.cpp index 4cc83dba..f9ac920e 100644 --- a/src/type/DFunctionType.cpp +++ b/src/type/DFunctionType.cpp @@ -94,7 +94,7 @@ namespace xo { } DFunctionType * - DFunctionType::shallow_copy(obj mm) noexcept + DFunctionType::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/type/DListType.cpp b/src/type/DListType.cpp index b4e2cd4e..2906053d 100644 --- a/src/type/DListType.cpp +++ b/src/type/DListType.cpp @@ -88,7 +88,7 @@ namespace xo { } DListType * - DListType::shallow_copy(obj mm) noexcept + DListType::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/type/DTypeVarRef.cpp b/src/type/DTypeVarRef.cpp index ec021ab6..d618a2f2 100644 --- a/src/type/DTypeVarRef.cpp +++ b/src/type/DTypeVarRef.cpp @@ -82,7 +82,7 @@ namespace xo { } DTypeVarRef * - DTypeVarRef::shallow_copy(obj mm) noexcept + DTypeVarRef::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/type/IGCObject_DArrayType.cpp b/src/type/IGCObject_DArrayType.cpp index 43287c83..c9375805 100644 --- a/src/type/IGCObject_DArrayType.cpp +++ b/src/type/IGCObject_DArrayType.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DArrayType::shallow_copy(DArrayType & self, obj mm) noexcept -> Opaque + IGCObject_DArrayType::shallow_move(DArrayType & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DArrayType::forward_children(DArrayType & self, obj gc) noexcept -> size_type diff --git a/src/type/IGCObject_DAtomicType.cpp b/src/type/IGCObject_DAtomicType.cpp index a5691676..3916d761 100644 --- a/src/type/IGCObject_DAtomicType.cpp +++ b/src/type/IGCObject_DAtomicType.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DAtomicType::shallow_copy(DAtomicType & self, obj mm) noexcept -> Opaque + IGCObject_DAtomicType::shallow_move(DAtomicType & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DAtomicType::forward_children(DAtomicType & self, obj gc) noexcept -> size_type diff --git a/src/type/IGCObject_DFunctionType.cpp b/src/type/IGCObject_DFunctionType.cpp index 9ba3ff39..4c7c7c13 100644 --- a/src/type/IGCObject_DFunctionType.cpp +++ b/src/type/IGCObject_DFunctionType.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DFunctionType::shallow_copy(DFunctionType & self, obj mm) noexcept -> Opaque + IGCObject_DFunctionType::shallow_move(DFunctionType & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DFunctionType::forward_children(DFunctionType & self, obj gc) noexcept -> size_type diff --git a/src/type/IGCObject_DListType.cpp b/src/type/IGCObject_DListType.cpp index da899cd9..ff3820d0 100644 --- a/src/type/IGCObject_DListType.cpp +++ b/src/type/IGCObject_DListType.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DListType::shallow_copy(DListType & self, obj mm) noexcept -> Opaque + IGCObject_DListType::shallow_move(DListType & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DListType::forward_children(DListType & self, obj gc) noexcept -> size_type diff --git a/src/type/IGCObject_DTypeVarRef.cpp b/src/type/IGCObject_DTypeVarRef.cpp index ade79944..9dc58dc0 100644 --- a/src/type/IGCObject_DTypeVarRef.cpp +++ b/src/type/IGCObject_DTypeVarRef.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DTypeVarRef::shallow_copy(DTypeVarRef & self, obj mm) noexcept -> Opaque + IGCObject_DTypeVarRef::shallow_move(DTypeVarRef & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DTypeVarRef::forward_children(DTypeVarRef & self, obj gc) noexcept -> size_type From a08fe61a4561b1343b38c3b9f41ccb89481ae731 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:33:35 -0400 Subject: [PATCH 21/31] refactor: rename shallow_copy -> shallow_move + streamline Use RCollector.std_copy_for where appropriate --- include/xo/type/DArrayType.hpp | 2 +- include/xo/type/DAtomicType.hpp | 2 +- include/xo/type/DFunctionType.hpp | 2 +- include/xo/type/DListType.hpp | 2 +- include/xo/type/array/IGCObject_DArrayType.hpp | 2 +- include/xo/type/atomic/IGCObject_DAtomicType.hpp | 2 +- include/xo/type/function/IGCObject_DFunctionType.hpp | 2 +- include/xo/type/list/IGCObject_DListType.hpp | 2 +- include/xo/type/typevar/DTypeVarRef.hpp | 2 +- include/xo/type/typevar/IGCObject_DTypeVarRef.hpp | 2 +- src/type/DArrayType.cpp | 4 ++-- src/type/DAtomicType.cpp | 4 ++-- src/type/DFunctionType.cpp | 4 ++-- src/type/DListType.cpp | 4 ++-- src/type/DTypeVarRef.cpp | 4 ++-- src/type/IGCObject_DArrayType.cpp | 4 ++-- src/type/IGCObject_DAtomicType.cpp | 4 ++-- src/type/IGCObject_DFunctionType.cpp | 4 ++-- src/type/IGCObject_DListType.cpp | 4 ++-- src/type/IGCObject_DTypeVarRef.cpp | 4 ++-- 20 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/xo/type/DArrayType.hpp b/include/xo/type/DArrayType.hpp index a2594649..db827e80 100644 --- a/include/xo/type/DArrayType.hpp +++ b/include/xo/type/DArrayType.hpp @@ -42,7 +42,7 @@ namespace xo { /** @defgroup xo-scm-arraytype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DArrayType * shallow_move(obj mm) noexcept; + DArrayType * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DAtomicType.hpp b/include/xo/type/DAtomicType.hpp index 7661955c..b9daf767 100644 --- a/include/xo/type/DAtomicType.hpp +++ b/include/xo/type/DAtomicType.hpp @@ -43,7 +43,7 @@ namespace xo { /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DAtomicType * shallow_move(obj mm) noexcept; + DAtomicType * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DFunctionType.hpp b/include/xo/type/DFunctionType.hpp index 328c93b3..5fbb93a7 100644 --- a/include/xo/type/DFunctionType.hpp +++ b/include/xo/type/DFunctionType.hpp @@ -64,7 +64,7 @@ namespace xo { /** @defgroup xo-scm-arraytype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DFunctionType * shallow_move(obj mm) noexcept; + DFunctionType * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DListType.hpp b/include/xo/type/DListType.hpp index 2dfedb27..b2fd196b 100644 --- a/include/xo/type/DListType.hpp +++ b/include/xo/type/DListType.hpp @@ -50,7 +50,7 @@ namespace xo { /** @defgroup xo-scm-listtype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DListType * shallow_move(obj mm) noexcept; + DListType * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp index 8c1bfeee..55c58b55 100644 --- a/include/xo/type/array/IGCObject_DArrayType.hpp +++ b/include/xo/type/array/IGCObject_DArrayType.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DArrayType & self, obj mm) noexcept; + static Opaque shallow_move(DArrayType & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DArrayType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp index 00763e4a..6907e7cb 100644 --- a/include/xo/type/atomic/IGCObject_DAtomicType.hpp +++ b/include/xo/type/atomic/IGCObject_DAtomicType.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DAtomicType & self, obj mm) noexcept; + static Opaque shallow_move(DAtomicType & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DAtomicType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp index 9c8727cd..f43b41ee 100644 --- a/include/xo/type/function/IGCObject_DFunctionType.hpp +++ b/include/xo/type/function/IGCObject_DFunctionType.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DFunctionType & self, obj mm) noexcept; + static Opaque shallow_move(DFunctionType & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DFunctionType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp index 2459fff4..296779e9 100644 --- a/include/xo/type/list/IGCObject_DListType.hpp +++ b/include/xo/type/list/IGCObject_DListType.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DListType & self, obj mm) noexcept; + static Opaque shallow_move(DListType & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DListType & self, obj gc) noexcept; ///@} diff --git a/include/xo/type/typevar/DTypeVarRef.hpp b/include/xo/type/typevar/DTypeVarRef.hpp index 4ce9a667..f59f3f72 100644 --- a/include/xo/type/typevar/DTypeVarRef.hpp +++ b/include/xo/type/typevar/DTypeVarRef.hpp @@ -54,7 +54,7 @@ namespace xo { /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ std::size_t shallow_size() const noexcept; - DTypeVarRef * shallow_move(obj mm) noexcept; + DTypeVarRef * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp index d0250871..e491cc35 100644 --- a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DTypeVarRef & self, obj mm) noexcept; + static Opaque shallow_move(DTypeVarRef & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DTypeVarRef & self, obj gc) noexcept; ///@} diff --git a/src/type/DArrayType.cpp b/src/type/DArrayType.cpp index b7c628af..52d25f5a 100644 --- a/src/type/DArrayType.cpp +++ b/src/type/DArrayType.cpp @@ -83,9 +83,9 @@ namespace xo { } DArrayType * - DArrayType::shallow_move(obj mm) noexcept + DArrayType::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/type/DAtomicType.cpp b/src/type/DAtomicType.cpp index f25a159e..d4f0b166 100644 --- a/src/type/DAtomicType.cpp +++ b/src/type/DAtomicType.cpp @@ -61,9 +61,9 @@ namespace xo { } DAtomicType * - DAtomicType::shallow_move(obj mm) noexcept + DAtomicType::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/type/DFunctionType.cpp b/src/type/DFunctionType.cpp index f9ac920e..8cb9001b 100644 --- a/src/type/DFunctionType.cpp +++ b/src/type/DFunctionType.cpp @@ -94,9 +94,9 @@ namespace xo { } DFunctionType * - DFunctionType::shallow_move(obj mm) noexcept + DFunctionType::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/type/DListType.cpp b/src/type/DListType.cpp index 2906053d..487cc5fe 100644 --- a/src/type/DListType.cpp +++ b/src/type/DListType.cpp @@ -88,9 +88,9 @@ namespace xo { } DListType * - DListType::shallow_move(obj mm) noexcept + DListType::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/type/DTypeVarRef.cpp b/src/type/DTypeVarRef.cpp index d618a2f2..a712174f 100644 --- a/src/type/DTypeVarRef.cpp +++ b/src/type/DTypeVarRef.cpp @@ -82,9 +82,9 @@ namespace xo { } DTypeVarRef * - DTypeVarRef::shallow_move(obj mm) noexcept + DTypeVarRef::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/type/IGCObject_DArrayType.cpp b/src/type/IGCObject_DArrayType.cpp index c9375805..34319c27 100644 --- a/src/type/IGCObject_DArrayType.cpp +++ b/src/type/IGCObject_DArrayType.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DArrayType::shallow_move(DArrayType & self, obj mm) noexcept -> Opaque + IGCObject_DArrayType::shallow_move(DArrayType & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DArrayType::forward_children(DArrayType & self, obj gc) noexcept -> size_type diff --git a/src/type/IGCObject_DAtomicType.cpp b/src/type/IGCObject_DAtomicType.cpp index 3916d761..a0a92816 100644 --- a/src/type/IGCObject_DAtomicType.cpp +++ b/src/type/IGCObject_DAtomicType.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DAtomicType::shallow_move(DAtomicType & self, obj mm) noexcept -> Opaque + IGCObject_DAtomicType::shallow_move(DAtomicType & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DAtomicType::forward_children(DAtomicType & self, obj gc) noexcept -> size_type diff --git a/src/type/IGCObject_DFunctionType.cpp b/src/type/IGCObject_DFunctionType.cpp index 4c7c7c13..04e57607 100644 --- a/src/type/IGCObject_DFunctionType.cpp +++ b/src/type/IGCObject_DFunctionType.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DFunctionType::shallow_move(DFunctionType & self, obj mm) noexcept -> Opaque + IGCObject_DFunctionType::shallow_move(DFunctionType & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DFunctionType::forward_children(DFunctionType & self, obj gc) noexcept -> size_type diff --git a/src/type/IGCObject_DListType.cpp b/src/type/IGCObject_DListType.cpp index ff3820d0..fe721a34 100644 --- a/src/type/IGCObject_DListType.cpp +++ b/src/type/IGCObject_DListType.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DListType::shallow_move(DListType & self, obj mm) noexcept -> Opaque + IGCObject_DListType::shallow_move(DListType & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DListType::forward_children(DListType & self, obj gc) noexcept -> size_type diff --git a/src/type/IGCObject_DTypeVarRef.cpp b/src/type/IGCObject_DTypeVarRef.cpp index 9dc58dc0..f4f5d595 100644 --- a/src/type/IGCObject_DTypeVarRef.cpp +++ b/src/type/IGCObject_DTypeVarRef.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DTypeVarRef::shallow_move(DTypeVarRef & self, obj mm) noexcept -> Opaque + IGCObject_DTypeVarRef::shallow_move(DTypeVarRef & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DTypeVarRef::forward_children(DTypeVarRef & self, obj gc) noexcept -> size_type From 499ff68ef0af303b28f967dd97b4a9ef82195d83 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:37:17 -0400 Subject: [PATCH 22/31] refactor: rename RCollector.std_copy_for -> std_move_for --- src/type/DArrayType.cpp | 2 +- src/type/DAtomicType.cpp | 2 +- src/type/DFunctionType.cpp | 2 +- src/type/DListType.cpp | 2 +- src/type/DTypeVarRef.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/type/DArrayType.cpp b/src/type/DArrayType.cpp index 52d25f5a..46bad06c 100644 --- a/src/type/DArrayType.cpp +++ b/src/type/DArrayType.cpp @@ -85,7 +85,7 @@ namespace xo { DArrayType * DArrayType::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/type/DAtomicType.cpp b/src/type/DAtomicType.cpp index d4f0b166..c5d30330 100644 --- a/src/type/DAtomicType.cpp +++ b/src/type/DAtomicType.cpp @@ -63,7 +63,7 @@ namespace xo { DAtomicType * DAtomicType::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/type/DFunctionType.cpp b/src/type/DFunctionType.cpp index 8cb9001b..83462b8d 100644 --- a/src/type/DFunctionType.cpp +++ b/src/type/DFunctionType.cpp @@ -96,7 +96,7 @@ namespace xo { DFunctionType * DFunctionType::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/type/DListType.cpp b/src/type/DListType.cpp index 487cc5fe..49557777 100644 --- a/src/type/DListType.cpp +++ b/src/type/DListType.cpp @@ -90,7 +90,7 @@ namespace xo { DListType * DListType::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/type/DTypeVarRef.cpp b/src/type/DTypeVarRef.cpp index a712174f..e9119d17 100644 --- a/src/type/DTypeVarRef.cpp +++ b/src/type/DTypeVarRef.cpp @@ -84,7 +84,7 @@ namespace xo { DTypeVarRef * DTypeVarRef::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t From 064d30de84ca005e2c9ab58acf6efa29c2cbd82b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:54:46 -0400 Subject: [PATCH 23/31] refactor: void return type for Collector.forward_children() --- include/xo/type/array/IGCObject_DArrayType.hpp | 2 +- include/xo/type/atomic/IGCObject_DAtomicType.hpp | 2 +- include/xo/type/function/IGCObject_DFunctionType.hpp | 2 +- include/xo/type/list/IGCObject_DListType.hpp | 2 +- include/xo/type/typevar/IGCObject_DTypeVarRef.hpp | 2 +- src/type/IGCObject_DArrayType.cpp | 4 ++-- src/type/IGCObject_DAtomicType.cpp | 4 ++-- src/type/IGCObject_DFunctionType.cpp | 4 ++-- src/type/IGCObject_DListType.cpp | 4 ++-- src/type/IGCObject_DTypeVarRef.cpp | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/xo/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp index 55c58b55..28f0dcca 100644 --- a/include/xo/type/array/IGCObject_DArrayType.hpp +++ b/include/xo/type/array/IGCObject_DArrayType.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DArrayType & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DArrayType & self, obj gc) noexcept; + static void forward_children(DArrayType & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp index 6907e7cb..e5652bf6 100644 --- a/include/xo/type/atomic/IGCObject_DAtomicType.hpp +++ b/include/xo/type/atomic/IGCObject_DAtomicType.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DAtomicType & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DAtomicType & self, obj gc) noexcept; + static void forward_children(DAtomicType & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp index f43b41ee..0c77e475 100644 --- a/include/xo/type/function/IGCObject_DFunctionType.hpp +++ b/include/xo/type/function/IGCObject_DFunctionType.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DFunctionType & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DFunctionType & self, obj gc) noexcept; + static void forward_children(DFunctionType & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp index 296779e9..322fc2da 100644 --- a/include/xo/type/list/IGCObject_DListType.hpp +++ b/include/xo/type/list/IGCObject_DListType.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DListType & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DListType & self, obj gc) noexcept; + static void forward_children(DListType & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp index e491cc35..94be0f90 100644 --- a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DTypeVarRef & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DTypeVarRef & self, obj gc) noexcept; + static void forward_children(DTypeVarRef & self, obj gc) noexcept; ///@} }; diff --git a/src/type/IGCObject_DArrayType.cpp b/src/type/IGCObject_DArrayType.cpp index 34319c27..31867406 100644 --- a/src/type/IGCObject_DArrayType.cpp +++ b/src/type/IGCObject_DArrayType.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DArrayType::forward_children(DArrayType & self, obj gc) noexcept -> size_type + IGCObject_DArrayType::forward_children(DArrayType & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DAtomicType.cpp b/src/type/IGCObject_DAtomicType.cpp index a0a92816..533f017e 100644 --- a/src/type/IGCObject_DAtomicType.cpp +++ b/src/type/IGCObject_DAtomicType.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DAtomicType::forward_children(DAtomicType & self, obj gc) noexcept -> size_type + IGCObject_DAtomicType::forward_children(DAtomicType & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DFunctionType.cpp b/src/type/IGCObject_DFunctionType.cpp index 04e57607..4a44fd3b 100644 --- a/src/type/IGCObject_DFunctionType.cpp +++ b/src/type/IGCObject_DFunctionType.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DFunctionType::forward_children(DFunctionType & self, obj gc) noexcept -> size_type + IGCObject_DFunctionType::forward_children(DFunctionType & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DListType.cpp b/src/type/IGCObject_DListType.cpp index fe721a34..7cabe586 100644 --- a/src/type/IGCObject_DListType.cpp +++ b/src/type/IGCObject_DListType.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DListType::forward_children(DListType & self, obj gc) noexcept -> size_type + IGCObject_DListType::forward_children(DListType & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DTypeVarRef.cpp b/src/type/IGCObject_DTypeVarRef.cpp index f4f5d595..0dc4469c 100644 --- a/src/type/IGCObject_DTypeVarRef.cpp +++ b/src/type/IGCObject_DTypeVarRef.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DTypeVarRef::forward_children(DTypeVarRef & self, obj gc) noexcept -> size_type + IGCObject_DTypeVarRef::forward_children(DTypeVarRef & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ From e20037660a8b2af5cfaa36de4ebde93651933c79 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 17:30:03 -0400 Subject: [PATCH 24/31] refactor: retire GCObject.shallow_size() Not needed. Rely on size stored in gc-owned object header --- include/xo/type/array/IGCObject_DArrayType.hpp | 2 -- include/xo/type/atomic/IGCObject_DAtomicType.hpp | 2 -- include/xo/type/function/IGCObject_DFunctionType.hpp | 2 -- include/xo/type/list/IGCObject_DListType.hpp | 2 -- include/xo/type/typevar/IGCObject_DTypeVarRef.hpp | 2 -- src/type/IGCObject_DArrayType.cpp | 6 ------ src/type/IGCObject_DAtomicType.cpp | 6 ------ src/type/IGCObject_DFunctionType.cpp | 6 ------ src/type/IGCObject_DListType.cpp | 6 ------ src/type/IGCObject_DTypeVarRef.cpp | 6 ------ 10 files changed, 40 deletions(-) diff --git a/include/xo/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp index 28f0dcca..fe1e8b13 100644 --- a/include/xo/type/array/IGCObject_DArrayType.hpp +++ b/include/xo/type/array/IGCObject_DArrayType.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-darraytype-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DArrayType & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp index e5652bf6..844c21cc 100644 --- a/include/xo/type/atomic/IGCObject_DAtomicType.hpp +++ b/include/xo/type/atomic/IGCObject_DAtomicType.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-datomictype-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DAtomicType & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp index 0c77e475..19c9b7da 100644 --- a/include/xo/type/function/IGCObject_DFunctionType.hpp +++ b/include/xo/type/function/IGCObject_DFunctionType.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-dfunctiontype-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DFunctionType & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp index 322fc2da..19450270 100644 --- a/include/xo/type/list/IGCObject_DListType.hpp +++ b/include/xo/type/list/IGCObject_DListType.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-dlisttype-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DListType & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp index 94be0f90..caf35660 100644 --- a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-dtypevarref-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DTypeVarRef & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/src/type/IGCObject_DArrayType.cpp b/src/type/IGCObject_DArrayType.cpp index 31867406..5f9e6c23 100644 --- a/src/type/IGCObject_DArrayType.cpp +++ b/src/type/IGCObject_DArrayType.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DArrayType::shallow_size(const DArrayType & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DArrayType::shallow_move(DArrayType & self, obj gc) noexcept -> Opaque { diff --git a/src/type/IGCObject_DAtomicType.cpp b/src/type/IGCObject_DAtomicType.cpp index 533f017e..287db903 100644 --- a/src/type/IGCObject_DAtomicType.cpp +++ b/src/type/IGCObject_DAtomicType.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DAtomicType::shallow_size(const DAtomicType & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DAtomicType::shallow_move(DAtomicType & self, obj gc) noexcept -> Opaque { diff --git a/src/type/IGCObject_DFunctionType.cpp b/src/type/IGCObject_DFunctionType.cpp index 4a44fd3b..3114a00d 100644 --- a/src/type/IGCObject_DFunctionType.cpp +++ b/src/type/IGCObject_DFunctionType.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DFunctionType::shallow_size(const DFunctionType & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DFunctionType::shallow_move(DFunctionType & self, obj gc) noexcept -> Opaque { diff --git a/src/type/IGCObject_DListType.cpp b/src/type/IGCObject_DListType.cpp index 7cabe586..bf5860f1 100644 --- a/src/type/IGCObject_DListType.cpp +++ b/src/type/IGCObject_DListType.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DListType::shallow_size(const DListType & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DListType::shallow_move(DListType & self, obj gc) noexcept -> Opaque { diff --git a/src/type/IGCObject_DTypeVarRef.cpp b/src/type/IGCObject_DTypeVarRef.cpp index 0dc4469c..910b7a9d 100644 --- a/src/type/IGCObject_DTypeVarRef.cpp +++ b/src/type/IGCObject_DTypeVarRef.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DTypeVarRef::shallow_size(const DTypeVarRef & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DTypeVarRef::shallow_move(DTypeVarRef & self, obj gc) noexcept -> Opaque { From 26a39302058b77664caba856c35c37cd40fae48a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 5 Apr 2026 23:53:02 -0400 Subject: [PATCH 25/31] refactor: + narrower interface for gc pointer forwarding add AGCObjectVisitor, instead of requiring ACollector. --- include/xo/type/DArrayType.hpp | 4 +++- include/xo/type/DAtomicType.hpp | 4 +++- include/xo/type/DFunctionType.hpp | 6 ++++-- include/xo/type/DListType.hpp | 4 +++- include/xo/type/array/IGCObject_DArrayType.hpp | 7 +++++-- .../xo/type/atomic/IGCObject_DAtomicType.hpp | 7 +++++-- .../type/function/IGCObject_DFunctionType.hpp | 7 +++++-- include/xo/type/list/IGCObject_DListType.hpp | 7 +++++-- include/xo/type/typevar/DTypeVarRef.hpp | 3 ++- .../xo/type/typevar/IGCObject_DTypeVarRef.hpp | 7 +++++-- src/type/DArrayType.cpp | 15 +++++++-------- src/type/DAtomicType.cpp | 6 +++--- src/type/DFunctionType.cpp | 17 ++++++++--------- src/type/DListType.cpp | 15 +++++++-------- src/type/DTypeVarRef.cpp | 7 +++---- src/type/IGCObject_DArrayType.cpp | 4 ++-- src/type/IGCObject_DAtomicType.cpp | 4 ++-- src/type/IGCObject_DFunctionType.cpp | 4 ++-- src/type/IGCObject_DListType.cpp | 4 ++-- src/type/IGCObject_DTypeVarRef.cpp | 4 ++-- 20 files changed, 78 insertions(+), 58 deletions(-) diff --git a/include/xo/type/DArrayType.hpp b/include/xo/type/DArrayType.hpp index db827e80..92a9ecac 100644 --- a/include/xo/type/DArrayType.hpp +++ b/include/xo/type/DArrayType.hpp @@ -9,6 +9,7 @@ #include "Metatype.hpp" #include #include +#include namespace xo { namespace scm { @@ -19,6 +20,7 @@ namespace xo { class DArrayType { public: using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -43,7 +45,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; DArrayType * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} private: diff --git a/include/xo/type/DAtomicType.hpp b/include/xo/type/DAtomicType.hpp index b9daf767..3274b882 100644 --- a/include/xo/type/DAtomicType.hpp +++ b/include/xo/type/DAtomicType.hpp @@ -8,6 +8,7 @@ #include "Type.hpp" #include "Metatype.hpp" #include +#include #include namespace xo { @@ -22,6 +23,7 @@ namespace xo { class DAtomicType { public: using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -44,7 +46,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; DAtomicType * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} private: diff --git a/include/xo/type/DFunctionType.hpp b/include/xo/type/DFunctionType.hpp index 5fbb93a7..66b92c1e 100644 --- a/include/xo/type/DFunctionType.hpp +++ b/include/xo/type/DFunctionType.hpp @@ -9,6 +9,7 @@ #include "Metatype.hpp" #include #include +#include #include namespace xo { @@ -20,8 +21,9 @@ namespace xo { class DFunctionType { public: using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; public: @@ -65,7 +67,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; DFunctionType * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} private: diff --git a/include/xo/type/DListType.hpp b/include/xo/type/DListType.hpp index b2fd196b..c6fa0309 100644 --- a/include/xo/type/DListType.hpp +++ b/include/xo/type/DListType.hpp @@ -9,6 +9,7 @@ #include "Metatype.hpp" #include #include +#include #include namespace xo { @@ -24,6 +25,7 @@ namespace xo { public: using TypeDescr = xo::reflect::TypeDescr; using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; public: @@ -51,7 +53,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; DListType * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} private: diff --git a/include/xo/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp index fe1e8b13..8e6b92d2 100644 --- a/include/xo/type/array/IGCObject_DArrayType.hpp +++ b/include/xo/type/array/IGCObject_DArrayType.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(DArrayType & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DArrayType & 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(DArrayType & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp index 844c21cc..88f607da 100644 --- a/include/xo/type/atomic/IGCObject_DAtomicType.hpp +++ b/include/xo/type/atomic/IGCObject_DAtomicType.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(DAtomicType & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DAtomicType & 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(DAtomicType & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp index 19c9b7da..2e027c35 100644 --- a/include/xo/type/function/IGCObject_DFunctionType.hpp +++ b/include/xo/type/function/IGCObject_DFunctionType.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(DFunctionType & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DFunctionType & 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(DFunctionType & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp index 19450270..bda54e7d 100644 --- a/include/xo/type/list/IGCObject_DListType.hpp +++ b/include/xo/type/list/IGCObject_DListType.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(DListType & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DListType & 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(DListType & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/type/typevar/DTypeVarRef.hpp b/include/xo/type/typevar/DTypeVarRef.hpp index f59f3f72..9e1d6b98 100644 --- a/include/xo/type/typevar/DTypeVarRef.hpp +++ b/include/xo/type/typevar/DTypeVarRef.hpp @@ -23,6 +23,7 @@ namespace xo { class DTypeVarRef { public: using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -55,7 +56,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; DTypeVarRef * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} private: diff --git a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp index caf35660..72261cb0 100644 --- a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.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(DTypeVarRef & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DTypeVarRef & 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(DTypeVarRef & self, obj fn) noexcept; ///@} }; diff --git a/src/type/DArrayType.cpp b/src/type/DArrayType.cpp index 46bad06c..4a172f92 100644 --- a/src/type/DArrayType.cpp +++ b/src/type/DArrayType.cpp @@ -88,15 +88,14 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DArrayType::forward_children(obj gc) noexcept + void + DArrayType::visit_gco_children(obj gc) noexcept { - { - auto e = FacetRegistry::instance().variant(elt_type_); - gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_)); - } - - return this->shallow_size(); + gc.visit_poly_child(&elt_type_); + //{ + // auto e = FacetRegistry::instance().variant(elt_type_); + // gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_)); + //} } } } diff --git a/src/type/DAtomicType.cpp b/src/type/DAtomicType.cpp index c5d30330..070683b0 100644 --- a/src/type/DAtomicType.cpp +++ b/src/type/DAtomicType.cpp @@ -66,10 +66,10 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DAtomicType::forward_children(obj) noexcept + void + DAtomicType::visit_gco_children(obj) noexcept { - return this->shallow_size(); + // no-op. no children } } /*namespace scm*/ diff --git a/src/type/DFunctionType.cpp b/src/type/DFunctionType.cpp index 83462b8d..b27e9ac1 100644 --- a/src/type/DFunctionType.cpp +++ b/src/type/DFunctionType.cpp @@ -99,17 +99,16 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DFunctionType::forward_children(obj gc) noexcept + void + DFunctionType::visit_gco_children(obj gc) noexcept { - { - auto e = FacetRegistry::instance().variant(return_type_); - gc.forward_inplace(e.iface(), (void **)&(return_type_.data_)); - } + gc.visit_poly_child(&return_type_); + //{ + // auto e = FacetRegistry::instance().variant(return_type_); + // gc.forward_inplace(e.iface(), (void **)&(return_type_.data_)); + //} - gc.forward_inplace(&arg_types_); - - return this->shallow_size(); + gc.visit_child(&arg_types_); } } /*namespace scm*/ diff --git a/src/type/DListType.cpp b/src/type/DListType.cpp index 49557777..0ffdf8de 100644 --- a/src/type/DListType.cpp +++ b/src/type/DListType.cpp @@ -93,15 +93,14 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DListType::forward_children(obj gc) noexcept + void + DListType::visit_gco_children(obj gc) noexcept { - { - auto e = FacetRegistry::instance().variant(elt_type_); - gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_)); - } - - return this->shallow_size(); + gc.visit_poly_child(&elt_type_); + //{ + // auto e = FacetRegistry::instance().variant(elt_type_); + // gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_)); + //} } } } diff --git a/src/type/DTypeVarRef.cpp b/src/type/DTypeVarRef.cpp index e9119d17..a540c623 100644 --- a/src/type/DTypeVarRef.cpp +++ b/src/type/DTypeVarRef.cpp @@ -87,17 +87,16 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DTypeVarRef::forward_children(obj gc) noexcept + void + DTypeVarRef::visit_gco_children(obj gc) noexcept { - gc.forward_pivot_inplace(&type_); + gc.visit_poly_child(&type_); //{ // auto e = FacetRegistry::instance().variant(type_); // gc.forward_inplace(e.iface(), (void **)&type_.data_); //} - return this->shallow_size(); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DArrayType.cpp b/src/type/IGCObject_DArrayType.cpp index 5f9e6c23..3483c40e 100644 --- a/src/type/IGCObject_DArrayType.cpp +++ b/src/type/IGCObject_DArrayType.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DArrayType::forward_children(DArrayType & self, obj gc) noexcept -> void + IGCObject_DArrayType::visit_gco_children(DArrayType & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DAtomicType.cpp b/src/type/IGCObject_DAtomicType.cpp index 287db903..2d891efb 100644 --- a/src/type/IGCObject_DAtomicType.cpp +++ b/src/type/IGCObject_DAtomicType.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DAtomicType::forward_children(DAtomicType & self, obj gc) noexcept -> void + IGCObject_DAtomicType::visit_gco_children(DAtomicType & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DFunctionType.cpp b/src/type/IGCObject_DFunctionType.cpp index 3114a00d..36d76b43 100644 --- a/src/type/IGCObject_DFunctionType.cpp +++ b/src/type/IGCObject_DFunctionType.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DFunctionType::forward_children(DFunctionType & self, obj gc) noexcept -> void + IGCObject_DFunctionType::visit_gco_children(DFunctionType & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DListType.cpp b/src/type/IGCObject_DListType.cpp index bf5860f1..68130a80 100644 --- a/src/type/IGCObject_DListType.cpp +++ b/src/type/IGCObject_DListType.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DListType::forward_children(DListType & self, obj gc) noexcept -> void + IGCObject_DListType::visit_gco_children(DListType & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DTypeVarRef.cpp b/src/type/IGCObject_DTypeVarRef.cpp index 910b7a9d..3ff82f33 100644 --- a/src/type/IGCObject_DTypeVarRef.cpp +++ b/src/type/IGCObject_DTypeVarRef.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DTypeVarRef::forward_children(DTypeVarRef & self, obj gc) noexcept -> void + IGCObject_DTypeVarRef::visit_gco_children(DTypeVarRef & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ From 4bca2b7a23cf6aaaf07ff4d795e568a9136b463c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 6 Apr 2026 00:11:08 -0400 Subject: [PATCH 26/31] refactor: make shallow_move() available from AGCObjectVisitor --- include/xo/type/array/IGCObject_DArrayType.hpp | 2 +- include/xo/type/atomic/IGCObject_DAtomicType.hpp | 2 +- include/xo/type/function/IGCObject_DFunctionType.hpp | 2 +- include/xo/type/list/IGCObject_DListType.hpp | 2 +- include/xo/type/typevar/IGCObject_DTypeVarRef.hpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/xo/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp index 8e6b92d2..af44afb8 100644 --- a/include/xo/type/array/IGCObject_DArrayType.hpp +++ b/include/xo/type/array/IGCObject_DArrayType.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DArrayType & 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/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp index 88f607da..0acce5ad 100644 --- a/include/xo/type/atomic/IGCObject_DAtomicType.hpp +++ b/include/xo/type/atomic/IGCObject_DAtomicType.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DAtomicType & 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/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp index 2e027c35..c368f573 100644 --- a/include/xo/type/function/IGCObject_DFunctionType.hpp +++ b/include/xo/type/function/IGCObject_DFunctionType.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DFunctionType & 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/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp index bda54e7d..07903f03 100644 --- a/include/xo/type/list/IGCObject_DListType.hpp +++ b/include/xo/type/list/IGCObject_DListType.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DListType & 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/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp index 72261cb0..a943a3c6 100644 --- a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DTypeVarRef & 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 3da2b9ad2b7541bca291c4af62b36bacb0a266be Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 6 Apr 2026 15:21:48 -0400 Subject: [PATCH 27/31] refactor: use GCObjectVisitor api w/ gco_shallow_move --- include/xo/type/DArrayType.hpp | 7 +++---- include/xo/type/DAtomicType.hpp | 7 +++---- include/xo/type/DFunctionType.hpp | 7 +++---- include/xo/type/DListType.hpp | 7 +++---- include/xo/type/array/IGCObject_DArrayType.hpp | 5 +++-- include/xo/type/atomic/IGCObject_DAtomicType.hpp | 5 +++-- include/xo/type/function/IGCObject_DFunctionType.hpp | 5 +++-- include/xo/type/list/IGCObject_DListType.hpp | 5 +++-- include/xo/type/typevar/DTypeVarRef.hpp | 7 +++---- include/xo/type/typevar/IGCObject_DTypeVarRef.hpp | 5 +++-- src/type/DArrayType.cpp | 8 +------- src/type/DAtomicType.cpp | 8 +------- src/type/DFunctionType.cpp | 8 +------- src/type/DListType.cpp | 8 +------- src/type/DTypeVarRef.cpp | 8 +------- src/type/IGCObject_DArrayType.cpp | 4 ++-- src/type/IGCObject_DAtomicType.cpp | 4 ++-- src/type/IGCObject_DFunctionType.cpp | 4 ++-- src/type/IGCObject_DListType.cpp | 4 ++-- src/type/IGCObject_DTypeVarRef.cpp | 4 ++-- 20 files changed, 45 insertions(+), 75 deletions(-) diff --git a/include/xo/type/DArrayType.hpp b/include/xo/type/DArrayType.hpp index 92a9ecac..0f128037 100644 --- a/include/xo/type/DArrayType.hpp +++ b/include/xo/type/DArrayType.hpp @@ -7,7 +7,7 @@ #include "Type.hpp" #include "Metatype.hpp" -#include +//#include #include #include @@ -19,7 +19,7 @@ namespace xo { **/ class DArrayType { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -43,8 +43,7 @@ namespace xo { ///@} /** @defgroup xo-scm-arraytype-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; - DArrayType * shallow_move(obj gc) noexcept; + DArrayType * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DAtomicType.hpp b/include/xo/type/DAtomicType.hpp index 3274b882..1338c1d6 100644 --- a/include/xo/type/DAtomicType.hpp +++ b/include/xo/type/DAtomicType.hpp @@ -7,7 +7,7 @@ #include "Type.hpp" #include "Metatype.hpp" -#include +//#include #include #include @@ -22,7 +22,7 @@ namespace xo { **/ class DAtomicType { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -44,8 +44,7 @@ namespace xo { ///@} /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; - DAtomicType * shallow_move(obj gc) noexcept; + DAtomicType * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DFunctionType.hpp b/include/xo/type/DFunctionType.hpp index 66b92c1e..19d8bbee 100644 --- a/include/xo/type/DFunctionType.hpp +++ b/include/xo/type/DFunctionType.hpp @@ -8,7 +8,7 @@ #include "Type.hpp" #include "Metatype.hpp" #include -#include +//#include #include #include @@ -20,7 +20,7 @@ namespace xo { **/ class DFunctionType { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; @@ -65,8 +65,7 @@ namespace xo { ///@} /** @defgroup xo-scm-arraytype-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; - DFunctionType * shallow_move(obj gc) noexcept; + DFunctionType * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/DListType.hpp b/include/xo/type/DListType.hpp index c6fa0309..7ca75176 100644 --- a/include/xo/type/DListType.hpp +++ b/include/xo/type/DListType.hpp @@ -8,7 +8,7 @@ #include "Type.hpp" #include "Metatype.hpp" #include -#include +//#include #include #include @@ -24,7 +24,7 @@ namespace xo { class DListType { public: using TypeDescr = xo::reflect::TypeDescr; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; @@ -51,8 +51,7 @@ namespace xo { ///@} /** @defgroup xo-scm-listtype-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; - DListType * shallow_move(obj gc) noexcept; + DListType * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp index af44afb8..f03e6b9a 100644 --- a/include/xo/type/array/IGCObject_DArrayType.hpp +++ b/include/xo/type/array/IGCObject_DArrayType.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DArrayType & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DArrayType & 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/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp index 0acce5ad..dbba8a3a 100644 --- a/include/xo/type/atomic/IGCObject_DAtomicType.hpp +++ b/include/xo/type/atomic/IGCObject_DAtomicType.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DAtomicType & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DAtomicType & 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/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp index c368f573..6840ffd6 100644 --- a/include/xo/type/function/IGCObject_DFunctionType.hpp +++ b/include/xo/type/function/IGCObject_DFunctionType.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DFunctionType & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DFunctionType & 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/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp index 07903f03..752bb76e 100644 --- a/include/xo/type/list/IGCObject_DListType.hpp +++ b/include/xo/type/list/IGCObject_DListType.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DListType & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DListType & 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/type/typevar/DTypeVarRef.hpp b/include/xo/type/typevar/DTypeVarRef.hpp index 9e1d6b98..d1f8258e 100644 --- a/include/xo/type/typevar/DTypeVarRef.hpp +++ b/include/xo/type/typevar/DTypeVarRef.hpp @@ -7,7 +7,7 @@ #include "Type.hpp" #include "Metatype.hpp" -#include +//#include #include #include @@ -22,7 +22,7 @@ namespace xo { **/ class DTypeVarRef { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -54,8 +54,7 @@ namespace xo { ///@} /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; - DTypeVarRef * shallow_move(obj gc) noexcept; + DTypeVarRef * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp index a943a3c6..d837afa2 100644 --- a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DTypeVarRef & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DTypeVarRef & 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/type/DArrayType.cpp b/src/type/DArrayType.cpp index 4a172f92..891a83c8 100644 --- a/src/type/DArrayType.cpp +++ b/src/type/DArrayType.cpp @@ -76,14 +76,8 @@ namespace xo { // ----- gcobject facet ----- - std::size_t - DArrayType::shallow_size() const noexcept - { - return sizeof(*this); - } - DArrayType * - DArrayType::shallow_move(obj gc) noexcept + DArrayType::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/type/DAtomicType.cpp b/src/type/DAtomicType.cpp index 070683b0..6c024344 100644 --- a/src/type/DAtomicType.cpp +++ b/src/type/DAtomicType.cpp @@ -54,14 +54,8 @@ namespace xo { // ----- GCObject facet ----- - std::size_t - DAtomicType::shallow_size() const noexcept - { - return sizeof(DAtomicType); - } - DAtomicType * - DAtomicType::shallow_move(obj gc) noexcept + DAtomicType::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/type/DFunctionType.cpp b/src/type/DFunctionType.cpp index b27e9ac1..934fae15 100644 --- a/src/type/DFunctionType.cpp +++ b/src/type/DFunctionType.cpp @@ -87,14 +87,8 @@ namespace xo { // ----- gcobject facet ----- - std::size_t - DFunctionType::shallow_size() const noexcept - { - return sizeof(*this); - } - DFunctionType * - DFunctionType::shallow_move(obj gc) noexcept + DFunctionType::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/type/DListType.cpp b/src/type/DListType.cpp index 0ffdf8de..20a69302 100644 --- a/src/type/DListType.cpp +++ b/src/type/DListType.cpp @@ -81,14 +81,8 @@ namespace xo { // ----- gcobject facet ----- - std::size_t - DListType::shallow_size() const noexcept - { - return sizeof(*this); - } - DListType * - DListType::shallow_move(obj gc) noexcept + DListType::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/type/DTypeVarRef.cpp b/src/type/DTypeVarRef.cpp index a540c623..d9f38160 100644 --- a/src/type/DTypeVarRef.cpp +++ b/src/type/DTypeVarRef.cpp @@ -75,14 +75,8 @@ namespace xo { // ----- GCObject facet ----- - std::size_t - DTypeVarRef::shallow_size() const noexcept - { - return sizeof(DTypeVarRef); - } - DTypeVarRef * - DTypeVarRef::shallow_move(obj gc) noexcept + DTypeVarRef::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/type/IGCObject_DArrayType.cpp b/src/type/IGCObject_DArrayType.cpp index 3483c40e..d778c3aa 100644 --- a/src/type/IGCObject_DArrayType.cpp +++ b/src/type/IGCObject_DArrayType.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DArrayType::shallow_move(DArrayType & self, obj gc) noexcept -> Opaque + IGCObject_DArrayType::gco_shallow_move(DArrayType & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DArrayType::visit_gco_children(DArrayType & self, obj fn) noexcept -> void diff --git a/src/type/IGCObject_DAtomicType.cpp b/src/type/IGCObject_DAtomicType.cpp index 2d891efb..13b4a83f 100644 --- a/src/type/IGCObject_DAtomicType.cpp +++ b/src/type/IGCObject_DAtomicType.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DAtomicType::shallow_move(DAtomicType & self, obj gc) noexcept -> Opaque + IGCObject_DAtomicType::gco_shallow_move(DAtomicType & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DAtomicType::visit_gco_children(DAtomicType & self, obj fn) noexcept -> void diff --git a/src/type/IGCObject_DFunctionType.cpp b/src/type/IGCObject_DFunctionType.cpp index 36d76b43..65bdd67b 100644 --- a/src/type/IGCObject_DFunctionType.cpp +++ b/src/type/IGCObject_DFunctionType.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DFunctionType::shallow_move(DFunctionType & self, obj gc) noexcept -> Opaque + IGCObject_DFunctionType::gco_shallow_move(DFunctionType & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DFunctionType::visit_gco_children(DFunctionType & self, obj fn) noexcept -> void diff --git a/src/type/IGCObject_DListType.cpp b/src/type/IGCObject_DListType.cpp index 68130a80..032a3f5d 100644 --- a/src/type/IGCObject_DListType.cpp +++ b/src/type/IGCObject_DListType.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DListType::shallow_move(DListType & self, obj gc) noexcept -> Opaque + IGCObject_DListType::gco_shallow_move(DListType & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DListType::visit_gco_children(DListType & self, obj fn) noexcept -> void diff --git a/src/type/IGCObject_DTypeVarRef.cpp b/src/type/IGCObject_DTypeVarRef.cpp index 3ff82f33..8c5422db 100644 --- a/src/type/IGCObject_DTypeVarRef.cpp +++ b/src/type/IGCObject_DTypeVarRef.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DTypeVarRef::shallow_move(DTypeVarRef & self, obj gc) noexcept -> Opaque + IGCObject_DTypeVarRef::gco_shallow_move(DTypeVarRef & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DTypeVarRef::visit_gco_children(DTypeVarRef & self, obj fn) noexcept -> void From 70c0591a9e4af2af7ba0810d64923373756ae5b2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 10 Apr 2026 01:10:03 -0400 Subject: [PATCH 28/31] 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/type/DArrayType.hpp | 3 ++- include/xo/type/DAtomicType.hpp | 3 ++- include/xo/type/DFunctionType.hpp | 5 ++--- include/xo/type/DListType.hpp | 3 ++- include/xo/type/array/IGCObject_DArrayType.hpp | 3 ++- include/xo/type/atomic/IGCObject_DAtomicType.hpp | 3 ++- include/xo/type/function/IGCObject_DFunctionType.hpp | 3 ++- include/xo/type/list/IGCObject_DListType.hpp | 3 ++- include/xo/type/typevar/DTypeVarRef.hpp | 3 ++- include/xo/type/typevar/IGCObject_DTypeVarRef.hpp | 3 ++- src/type/DArrayType.cpp | 8 ++------ src/type/DAtomicType.cpp | 2 +- src/type/DFunctionType.cpp | 11 +++-------- src/type/DListType.cpp | 5 +++-- src/type/DTypeVarRef.cpp | 4 ++-- src/type/IGCObject_DArrayType.cpp | 4 ++-- src/type/IGCObject_DAtomicType.cpp | 4 ++-- src/type/IGCObject_DFunctionType.cpp | 4 ++-- src/type/IGCObject_DListType.cpp | 4 ++-- src/type/IGCObject_DTypeVarRef.cpp | 4 ++-- 20 files changed, 41 insertions(+), 41 deletions(-) diff --git a/include/xo/type/DArrayType.hpp b/include/xo/type/DArrayType.hpp index 0f128037..e9b93aa3 100644 --- a/include/xo/type/DArrayType.hpp +++ b/include/xo/type/DArrayType.hpp @@ -21,6 +21,7 @@ namespace xo { public: //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -44,7 +45,7 @@ namespace xo { /** @defgroup xo-scm-arraytype-gcobject-facet **/ ///@{ DArrayType * 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/type/DAtomicType.hpp b/include/xo/type/DAtomicType.hpp index 1338c1d6..df09e4dc 100644 --- a/include/xo/type/DAtomicType.hpp +++ b/include/xo/type/DAtomicType.hpp @@ -24,6 +24,7 @@ namespace xo { public: //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -45,7 +46,7 @@ namespace xo { /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ DAtomicType * 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/type/DFunctionType.hpp b/include/xo/type/DFunctionType.hpp index 19d8bbee..496924b5 100644 --- a/include/xo/type/DFunctionType.hpp +++ b/include/xo/type/DFunctionType.hpp @@ -8,7 +8,6 @@ #include "Type.hpp" #include "Metatype.hpp" #include -//#include #include #include @@ -20,9 +19,9 @@ namespace xo { **/ class DFunctionType { public: - //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -66,7 +65,7 @@ namespace xo { /** @defgroup xo-scm-arraytype-gcobject-facet **/ ///@{ DFunctionType * 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/type/DListType.hpp b/include/xo/type/DListType.hpp index 7ca75176..fcb4735a 100644 --- a/include/xo/type/DListType.hpp +++ b/include/xo/type/DListType.hpp @@ -26,6 +26,7 @@ namespace xo { using TypeDescr = xo::reflect::TypeDescr; //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; public: @@ -52,7 +53,7 @@ namespace xo { /** @defgroup xo-scm-listtype-gcobject-facet **/ ///@{ DListType * 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/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp index f03e6b9a..9cbede83 100644 --- a/include/xo/type/array/IGCObject_DArrayType.hpp +++ b/include/xo/type/array/IGCObject_DArrayType.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(DArrayType & self, obj fn) noexcept; + static void visit_gco_children(DArrayType & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp index dbba8a3a..d29bd6a7 100644 --- a/include/xo/type/atomic/IGCObject_DAtomicType.hpp +++ b/include/xo/type/atomic/IGCObject_DAtomicType.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(DAtomicType & self, obj fn) noexcept; + static void visit_gco_children(DAtomicType & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp index 6840ffd6..0d544878 100644 --- a/include/xo/type/function/IGCObject_DFunctionType.hpp +++ b/include/xo/type/function/IGCObject_DFunctionType.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(DFunctionType & self, obj fn) noexcept; + static void visit_gco_children(DFunctionType & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp index 752bb76e..edb17816 100644 --- a/include/xo/type/list/IGCObject_DListType.hpp +++ b/include/xo/type/list/IGCObject_DListType.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(DListType & self, obj fn) noexcept; + static void visit_gco_children(DListType & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/type/typevar/DTypeVarRef.hpp b/include/xo/type/typevar/DTypeVarRef.hpp index d1f8258e..3c60b05a 100644 --- a/include/xo/type/typevar/DTypeVarRef.hpp +++ b/include/xo/type/typevar/DTypeVarRef.hpp @@ -24,6 +24,7 @@ namespace xo { public: //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -55,7 +56,7 @@ namespace xo { /** @defgroup xo-scm-atomictype-gcobject-facet **/ ///@{ DTypeVarRef * 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/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp index d837afa2..1ba0a87c 100644 --- a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.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(DTypeVarRef & self, obj fn) noexcept; + static void visit_gco_children(DTypeVarRef & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/src/type/DArrayType.cpp b/src/type/DArrayType.cpp index 891a83c8..a46752bc 100644 --- a/src/type/DArrayType.cpp +++ b/src/type/DArrayType.cpp @@ -83,13 +83,9 @@ namespace xo { } void - DArrayType::visit_gco_children(obj gc) noexcept + DArrayType::visit_gco_children(VisitReason reason, obj gc) noexcept { - gc.visit_poly_child(&elt_type_); - //{ - // auto e = FacetRegistry::instance().variant(elt_type_); - // gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_)); - //} + gc.visit_poly_child(reason, &elt_type_); } } } diff --git a/src/type/DAtomicType.cpp b/src/type/DAtomicType.cpp index 6c024344..833d19d1 100644 --- a/src/type/DAtomicType.cpp +++ b/src/type/DAtomicType.cpp @@ -61,7 +61,7 @@ namespace xo { } void - DAtomicType::visit_gco_children(obj) noexcept + DAtomicType::visit_gco_children(VisitReason, obj) noexcept { // no-op. no children } diff --git a/src/type/DFunctionType.cpp b/src/type/DFunctionType.cpp index 934fae15..2b4b8f7c 100644 --- a/src/type/DFunctionType.cpp +++ b/src/type/DFunctionType.cpp @@ -94,15 +94,10 @@ namespace xo { } void - DFunctionType::visit_gco_children(obj gc) noexcept + DFunctionType::visit_gco_children(VisitReason reason, obj gc) noexcept { - gc.visit_poly_child(&return_type_); - //{ - // auto e = FacetRegistry::instance().variant(return_type_); - // gc.forward_inplace(e.iface(), (void **)&(return_type_.data_)); - //} - - gc.visit_child(&arg_types_); + gc.visit_poly_child(reason, &return_type_); + gc.visit_child(reason, &arg_types_); } } /*namespace scm*/ diff --git a/src/type/DListType.cpp b/src/type/DListType.cpp index 20a69302..0647d8b2 100644 --- a/src/type/DListType.cpp +++ b/src/type/DListType.cpp @@ -88,9 +88,10 @@ namespace xo { } void - DListType::visit_gco_children(obj gc) noexcept + DListType::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_poly_child(&elt_type_); + gc.visit_poly_child(reason, &elt_type_); //{ // auto e = FacetRegistry::instance().variant(elt_type_); // gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_)); diff --git a/src/type/DTypeVarRef.cpp b/src/type/DTypeVarRef.cpp index d9f38160..86691122 100644 --- a/src/type/DTypeVarRef.cpp +++ b/src/type/DTypeVarRef.cpp @@ -82,9 +82,9 @@ namespace xo { } void - DTypeVarRef::visit_gco_children(obj gc) noexcept + DTypeVarRef::visit_gco_children(VisitReason reason, obj gc) noexcept { - gc.visit_poly_child(&type_); + gc.visit_poly_child(reason, &type_); //{ // auto e = FacetRegistry::instance().variant(type_); diff --git a/src/type/IGCObject_DArrayType.cpp b/src/type/IGCObject_DArrayType.cpp index d778c3aa..76b9c550 100644 --- a/src/type/IGCObject_DArrayType.cpp +++ b/src/type/IGCObject_DArrayType.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DArrayType::visit_gco_children(DArrayType & self, obj fn) noexcept -> void + IGCObject_DArrayType::visit_gco_children(DArrayType & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DAtomicType.cpp b/src/type/IGCObject_DAtomicType.cpp index 13b4a83f..7c4a27e0 100644 --- a/src/type/IGCObject_DAtomicType.cpp +++ b/src/type/IGCObject_DAtomicType.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DAtomicType::visit_gco_children(DAtomicType & self, obj fn) noexcept -> void + IGCObject_DAtomicType::visit_gco_children(DAtomicType & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DFunctionType.cpp b/src/type/IGCObject_DFunctionType.cpp index 65bdd67b..25e5e3a7 100644 --- a/src/type/IGCObject_DFunctionType.cpp +++ b/src/type/IGCObject_DFunctionType.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DFunctionType::visit_gco_children(DFunctionType & self, obj fn) noexcept -> void + IGCObject_DFunctionType::visit_gco_children(DFunctionType & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DListType.cpp b/src/type/IGCObject_DListType.cpp index 032a3f5d..43a02911 100644 --- a/src/type/IGCObject_DListType.cpp +++ b/src/type/IGCObject_DListType.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DListType::visit_gco_children(DListType & self, obj fn) noexcept -> void + IGCObject_DListType::visit_gco_children(DListType & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/type/IGCObject_DTypeVarRef.cpp b/src/type/IGCObject_DTypeVarRef.cpp index 8c5422db..2169b1e3 100644 --- a/src/type/IGCObject_DTypeVarRef.cpp +++ b/src/type/IGCObject_DTypeVarRef.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DTypeVarRef::visit_gco_children(DTypeVarRef & self, obj fn) noexcept -> void + IGCObject_DTypeVarRef::visit_gco_children(DTypeVarRef & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ From 4e18a2d3ff57050328a0f1559d875aec19c95c58 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 1 May 2026 19:54:26 -0400 Subject: [PATCH 29/31] refactor focusing on xo-alloc2/ xo-gc/ write-barrier ability to inform allocator of gco->gco mutation, via AAllocator i/face. --- include/xo/type/DArrayType.hpp | 2 -- include/xo/type/DAtomicType.hpp | 2 -- include/xo/type/DListType.hpp | 2 -- include/xo/type/typevar/DTypeVarRef.hpp | 2 -- src/type/DArrayType.cpp | 1 - 5 files changed, 9 deletions(-) diff --git a/include/xo/type/DArrayType.hpp b/include/xo/type/DArrayType.hpp index e9b93aa3..9ded76db 100644 --- a/include/xo/type/DArrayType.hpp +++ b/include/xo/type/DArrayType.hpp @@ -7,7 +7,6 @@ #include "Type.hpp" #include "Metatype.hpp" -//#include #include #include @@ -19,7 +18,6 @@ namespace xo { **/ class DArrayType { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; diff --git a/include/xo/type/DAtomicType.hpp b/include/xo/type/DAtomicType.hpp index df09e4dc..8dfaaaa3 100644 --- a/include/xo/type/DAtomicType.hpp +++ b/include/xo/type/DAtomicType.hpp @@ -7,7 +7,6 @@ #include "Type.hpp" #include "Metatype.hpp" -//#include #include #include @@ -22,7 +21,6 @@ namespace xo { **/ class DAtomicType { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; diff --git a/include/xo/type/DListType.hpp b/include/xo/type/DListType.hpp index fcb4735a..a34af57d 100644 --- a/include/xo/type/DListType.hpp +++ b/include/xo/type/DListType.hpp @@ -8,7 +8,6 @@ #include "Type.hpp" #include "Metatype.hpp" #include -//#include #include #include @@ -24,7 +23,6 @@ namespace xo { class DListType { public: using TypeDescr = xo::reflect::TypeDescr; - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; diff --git a/include/xo/type/typevar/DTypeVarRef.hpp b/include/xo/type/typevar/DTypeVarRef.hpp index 3c60b05a..36a86a70 100644 --- a/include/xo/type/typevar/DTypeVarRef.hpp +++ b/include/xo/type/typevar/DTypeVarRef.hpp @@ -7,7 +7,6 @@ #include "Type.hpp" #include "Metatype.hpp" -//#include #include #include @@ -22,7 +21,6 @@ namespace xo { **/ class DTypeVarRef { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; diff --git a/src/type/DArrayType.cpp b/src/type/DArrayType.cpp index a46752bc..6fad352d 100644 --- a/src/type/DArrayType.cpp +++ b/src/type/DArrayType.cpp @@ -7,7 +7,6 @@ #include "ArrayType.hpp" #include "TypeDescr.hpp" #include -#include #include #include From daf34afb27c4bc08aca3dccfe3102ed729c1b5b1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 2 May 2026 13:49:29 -0400 Subject: [PATCH 30/31] xo-gc stack: refactor + streamline. Retiring unused Collector typealiases. Fix #include topology. Fix/improve write barrier setup. --- include/xo/type/array/IGCObject_DArrayType.hpp | 1 - include/xo/type/atomic/IGCObject_DAtomicType.hpp | 1 - include/xo/type/function/IGCObject_DFunctionType.hpp | 1 - include/xo/type/list/IGCObject_DListType.hpp | 1 - include/xo/type/type/IType_Xfer.hpp | 8 ++++++++ include/xo/type/typevar/IGCObject_DTypeVarRef.hpp | 1 - 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/xo/type/array/IGCObject_DArrayType.hpp b/include/xo/type/array/IGCObject_DArrayType.hpp index 9cbede83..067608e2 100644 --- a/include/xo/type/array/IGCObject_DArrayType.hpp +++ b/include/xo/type/array/IGCObject_DArrayType.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/type/atomic/IGCObject_DAtomicType.hpp b/include/xo/type/atomic/IGCObject_DAtomicType.hpp index d29bd6a7..a4c7f1d6 100644 --- a/include/xo/type/atomic/IGCObject_DAtomicType.hpp +++ b/include/xo/type/atomic/IGCObject_DAtomicType.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/type/function/IGCObject_DFunctionType.hpp b/include/xo/type/function/IGCObject_DFunctionType.hpp index 0d544878..38d9f005 100644 --- a/include/xo/type/function/IGCObject_DFunctionType.hpp +++ b/include/xo/type/function/IGCObject_DFunctionType.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/type/list/IGCObject_DListType.hpp b/include/xo/type/list/IGCObject_DListType.hpp index edb17816..5d5c5fb8 100644 --- a/include/xo/type/list/IGCObject_DListType.hpp +++ b/include/xo/type/list/IGCObject_DListType.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/type/type/IType_Xfer.hpp b/include/xo/type/type/IType_Xfer.hpp index dbc82bc1..7e5ab5ea 100644 --- a/include/xo/type/type/IType_Xfer.hpp +++ b/include/xo/type/type/IType_Xfer.hpp @@ -9,10 +9,18 @@ * [iface_facet_any.hpp.j2] * 3. idl for facet methods * [idl/Type.json5] + * + * variables: + * {facet_hpp_fname} -> Type.hpp + * {impl_hpp_subdir} -> type + * {facet_ns1} -> xo + * {facet_detail_subdir} -> type + * {abstract_facet_fname} -> AType.hpp **/ #pragma once +#include "AType.hpp" #include #include diff --git a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp b/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp index 1ba0a87c..8b6b382b 100644 --- a/include/xo/type/typevar/IGCObject_DTypeVarRef.hpp +++ b/include/xo/type/typevar/IGCObject_DTypeVarRef.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; From 07c0a7c0f705b0f3e1699a4399a9fe25bb8bddfd Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 30 May 2026 10:17:36 -0400 Subject: [PATCH 31/31] xo-type: cleanup CMakeList.txt stale comments --- CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e61de986..f8d68c50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,6 @@ xo_add_genfacet( xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-atomictype FACET_PKG xo_type -# REPR AtomicType INPUT idl/IType_DAtomicType.json5 ) @@ -42,7 +41,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-atomictype FACET_PKG xo_alloc2 -# REPR AtomicType INPUT idl/IGCObject_DAtomicType.json5 ) @@ -52,7 +50,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-listtype FACET_PKG xo_type -# REPR ListType INPUT idl/IType_DListType.json5 ) @@ -60,7 +57,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-listtype FACET_PKG xo_alloc2 -# REPR ListType INPUT idl/IGCObject_DListType.json5 ) @@ -70,7 +66,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-arraytype FACET_PKG xo_type -# REPR ArrayType INPUT idl/IType_DArrayType.json5 ) @@ -78,7 +73,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-arraytype FACET_PKG xo_alloc2 -# REPR ArrayType INPUT idl/IGCObject_DArrayType.json5 ) @@ -88,7 +82,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-type-functiontype FACET_PKG xo_type -# REPR FunctionType INPUT idl/IType_DFunctionType.json5 ) @@ -96,7 +89,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-type-facetimpl-gcobject-functiontype FACET_PKG xo_alloc2 -# REPR FunctionType INPUT idl/IGCObject_DFunctionType.json5 )