From c8a76d23bd664ea156119375b6a82a8d3e23ee92 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Mar 2026 22:26:31 +1100 Subject: [PATCH] xo-gc xo-alloc2: move Collector faceet gc/ -> alloc2/ for levelling --- include/xo/object2/DArray.hpp | 4 +-- include/xo/object2/DBoolean.hpp | 2 +- include/xo/object2/DDictionary.hpp | 4 +-- include/xo/object2/DFloat.hpp | 2 +- include/xo/object2/DInteger.hpp | 2 +- include/xo/object2/DList.hpp | 2 +- include/xo/object2/DString.hpp | 35 +++++++++++++------ include/xo/object2/String.hpp | 2 ++ include/xo/object2/array/IGCObject_DArray.hpp | 4 +-- .../xo/object2/boolean/IGCObject_DBoolean.hpp | 4 +-- .../dictionary/IGCObject_DDictionary.hpp | 4 +-- .../xo/object2/number/IGCObject_DFloat.hpp | 4 +-- .../xo/object2/number/IGCObject_DInteger.hpp | 4 +-- .../xo/object2/object2_register_facets.hpp | 2 +- include/xo/object2/object2_register_types.hpp | 2 +- include/xo/object2/sequence/ASequence.hpp | 2 +- .../xo/object2/sequence/ISequence_Xfer.hpp | 2 +- .../xo/object2/string/IGCObject_DString.hpp | 4 +-- src/object2/DList.cpp | 2 +- src/object2/DString.cpp | 3 +- utest/DString.test.cpp | 1 + utest/Printable.test.cpp | 2 +- utest/X1Collector.test.cpp | 2 +- 23 files changed, 57 insertions(+), 38 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 879bb76..55d5e06 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -5,8 +5,8 @@ #pragma once -#include -#include +#include +#include #include #include #include diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index 69dd1c1..ee9fe3b 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include #include #include #include diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 1f02843..f584408 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -7,8 +7,8 @@ #include "DArray.hpp" #include "DString.hpp" -#include -#include +#include +#include #include #include #include diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index a46a990..4e4be86 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index b03693b..3fd1367 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include #include #include #include diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 39e0b58..50ab8dd 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include #include #include diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index a6cedb0..bb57e3d 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include #include @@ -15,6 +15,8 @@ //#include namespace xo { + namespace mm { class ACollector; } + namespace scm { /** @class DString * @brief String implementation with gc hooks @@ -111,14 +113,7 @@ namespace xo { static DString * printf(obj mm, size_type cap, const char * fmt, - Args&&... args) - { - DString * result = DString::empty(mm, cap); - if (result) { - result->sprintf(fmt, std::forward(args)...); - } - return result; - } + Args&&... args); ///@} /** @defgroup dstring-access access methods **/ @@ -252,8 +247,10 @@ namespace xo { /** clone string, using memory from allocator @p mm **/ DString * shallow_copy(obj mm) const noexcept; - /** fixup child pointers (trivial for DString, no children) **/ size_type forward_children(obj gc) noexcept; + /** fixup child pointers (trivial for DString, no children) + * note: cref so we can use forward decl + **/ ///@} @@ -285,6 +282,24 @@ namespace xo { ///@} }; + /** create string using printf-style formatting. + * Use memory from allocator @p mm with capacity @p cap. + * Truncates if result exceeds capacity. + * @return pointer to newly created DString + **/ + template + DString * DString::printf(obj mm, + size_type cap, + const char * fmt, + Args&&... args) + { + DString * result = DString::empty(mm, cap); + if (result) { + result->sprintf(fmt, std::forward(args)...); + } + return result; + } + inline std::ostream & operator<<(std::ostream & os, const DString * x) { if (x) { os << std::string_view(*x); diff --git a/include/xo/object2/String.hpp b/include/xo/object2/String.hpp index 111b04f..f3d0527 100644 --- a/include/xo/object2/String.hpp +++ b/include/xo/object2/String.hpp @@ -9,4 +9,6 @@ #include "string/IGCObject_DString.hpp" #include "string/IPrintable_DString.hpp" +#include + /* end String.hpp */ diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index 9af6d3c..08f78aa 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DArray.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 1d90b60..358aad1 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DBoolean.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 7f2e0ad..7fe1bc5 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DDictionary.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index 9a1dcbd..b8e15b7 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -15,7 +15,7 @@ #include "GCObject.hpp" #include -#include +#include #include #include "DFloat.hpp" @@ -65,4 +65,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index 1136b57..fd2ea64 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DInteger.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/object2/object2_register_facets.hpp b/include/xo/object2/object2_register_facets.hpp index e419b79..7f42d5a 100644 --- a/include/xo/object2/object2_register_facets.hpp +++ b/include/xo/object2/object2_register_facets.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include namespace xo { namespace scm { diff --git a/include/xo/object2/object2_register_types.hpp b/include/xo/object2/object2_register_types.hpp index 5c61692..5663b08 100644 --- a/include/xo/object2/object2_register_types.hpp +++ b/include/xo/object2/object2_register_types.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include namespace xo { namespace scm { diff --git a/include/xo/object2/sequence/ASequence.hpp b/include/xo/object2/sequence/ASequence.hpp index 53d112e..44f1d1c 100644 --- a/include/xo/object2/sequence/ASequence.hpp +++ b/include/xo/object2/sequence/ASequence.hpp @@ -14,7 +14,7 @@ #pragma once // includes (via {facet_includes}) -#include +#include #include #include #include diff --git a/include/xo/object2/sequence/ISequence_Xfer.hpp b/include/xo/object2/sequence/ISequence_Xfer.hpp index 42d6cb1..e0511e4 100644 --- a/include/xo/object2/sequence/ISequence_Xfer.hpp +++ b/include/xo/object2/sequence/ISequence_Xfer.hpp @@ -13,7 +13,7 @@ #pragma once -#include +#include namespace xo { namespace scm { diff --git a/include/xo/object2/string/IGCObject_DString.hpp b/include/xo/object2/string/IGCObject_DString.hpp index 159b9e4..2a907f3 100644 --- a/include/xo/object2/string/IGCObject_DString.hpp +++ b/include/xo/object2/string/IGCObject_DString.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DString.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index 01d01d6..25770d0 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -6,7 +6,7 @@ #include "DList.hpp" #include "list/IPrintable_DList.hpp" #include "list/IGCObject_DList.hpp" -#include +#include #include #include #include diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index 69baa5d..230fa4a 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -4,12 +4,13 @@ **/ #include "DString.hpp" +#include #include #include #include namespace xo { - using xo::facet::typeseq; + using xo::reflect::typeseq; using xo::print::ppdetail_atomic; namespace scm { diff --git a/utest/DString.test.cpp b/utest/DString.test.cpp index 39dffef..53db8e7 100644 --- a/utest/DString.test.cpp +++ b/utest/DString.test.cpp @@ -5,6 +5,7 @@ #include "init_object2.hpp" #include "StringOps.hpp" +#include #include #include #include diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index 64736d2..2ca792f 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 90122c2..a2a2dec 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -16,7 +16,7 @@ #include "list/IGCObject_DList.hpp" #include -#include +#include #include #include