From 1caa002faa0ce0d8a564ba1eaffd6335f0d1724f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 14 Dec 2025 13:52:29 -0500 Subject: [PATCH] xo-alloc2 xo-object: bugfix + refactor -> IGCObject_DList builds --- include/xo/object2/DInteger.hpp | 4 ++- include/xo/object2/DList.hpp | 26 +++++++++++++++ include/xo/object2/IGCObject_DList.hpp | 36 +++++++++++++++++++++ src/object2/CMakeLists.txt | 1 + src/object2/IGCObject_DList.cpp | 45 ++++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 include/xo/object2/DList.hpp create mode 100644 include/xo/object2/IGCObject_DList.hpp create mode 100644 src/object2/IGCObject_DList.cpp diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index ded9e80..3457af7 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -5,9 +5,11 @@ #pragma once +#include + namespace xo { namespace scm { - using DInteger = double; + using DInteger = std::int64_t; } /*nmaespace obj*/ } /*namespace xo*/ diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp new file mode 100644 index 0000000..f0be1cf --- /dev/null +++ b/include/xo/object2/DList.hpp @@ -0,0 +1,26 @@ +/** @file DList.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "xo/alloc2/RGCObject.hpp" +#include "xo/alloc2/IGCObject_Any.hpp" +#include "xo/facet/obj.hpp" + +namespace xo { + namespace scm { + + struct DList { + using AGCObject = xo::mm::AGCObject; + + DList(xo::obj h, + xo::obj r) : head_{h}, rest_{r} {} + + obj head_; + obj rest_; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DList.hpp */ diff --git a/include/xo/object2/IGCObject_DList.hpp b/include/xo/object2/IGCObject_DList.hpp new file mode 100644 index 0000000..890fdd3 --- /dev/null +++ b/include/xo/object2/IGCObject_DList.hpp @@ -0,0 +1,36 @@ +/** @file IGCObject_DList.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include "DList.hpp" + +namespace xo { + namespace scm { + /* changes here coordinate with: + * IGCObject_XFer + */ + struct IGCObject_DList { + public: + using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; + using size_type = std::size_t; + + static size_type shallow_size(const DList & d) noexcept; + static DList * shallow_copy(const DList & d, obj mm) noexcept; + static size_type forward_children(DList & d, obj gc) noexcept; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DList.hpp */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 25b46ba..f3c1382 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -4,6 +4,7 @@ set(SELF_LIB xo_object2) set(SELF_SRCS IGCObject_DFloat.cpp IGCObject_DInteger.cpp + IGCObject_DList.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp new file mode 100644 index 0000000..104358e --- /dev/null +++ b/src/object2/IGCObject_DList.cpp @@ -0,0 +1,45 @@ +/** @file IGCObject_DList.cpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#include "IGCObject_DList.hpp" + +namespace xo { + using xo::mm::AAllocator; + using xo::facet::obj; + using std::size_t; + + namespace scm { + size_t + IGCObject_DList::shallow_size(const DList &) noexcept + { + return sizeof(DList); + } + + DList * + IGCObject_DList::shallow_copy(const DList & src, + obj mm) noexcept + { + DList * copy = (DList *)mm.alloc(sizeof(DList)); + + if (copy) + *copy = src; + + return copy; + } + + size_t + IGCObject_DList::forward_children(DList & src, + obj gc) noexcept + { + gc.forward_inplace(&src.head_); + gc.forward_inplace(&src.rest_); + + return shallow_size(src); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DList.cpp */