xo-gc: + CollectorTypeRegistry for streamlined init

This commit is contained in:
Roland Conybeare 2026-01-16 16:10:00 -05:00
commit 013c1a4896
7 changed files with 109 additions and 3 deletions

View file

@ -3,7 +3,8 @@
* @author Roland Conybeare, Jan 2026
**/
#include <xo/object2/StringOps.hpp>
#include "init_object2.hpp"
#include "StringOps.hpp"
#include <xo/alloc2/arena/IAllocator_DArena.hpp>
#include <catch2/catch.hpp>
#include <cctype>
@ -19,6 +20,14 @@ namespace xo {
using xo::facet::obj;
namespace ut {
static InitEvidence s_init = (InitSubsys<S_object2_tag>::require());
TEST_CASE("DString-init", "[object2][DString]")
{
// real purpose: ensure s_init survives static linking
REQUIRE(s_init.evidence());
}
TEST_CASE("DString-empty", "[object2][DString]")
{
ArenaConfig cfg { .name_ = "testarena",

View file

@ -3,6 +3,7 @@
* @author Roland Conybeare, Dec 2025
**/
#include "init_object2.hpp"
#include "ListOps.hpp"
#include "DFloat.hpp"
#include "DInteger.hpp"
@ -14,6 +15,7 @@
#include "number/IGCObject_DInteger.hpp"
#include "list/IGCObject_DList.hpp"
#include <xo/gc/CollectorTypeRegistry.hpp>
#include <xo/gc/Collector.hpp>
#include <xo/gc/DX1Collector.hpp>
@ -23,18 +25,22 @@
#include <xo/arena/AllocInfo.hpp>
#include <xo/arena/padding.hpp>
#include <xo/subsys/Subsystem.hpp>
#include <xo/indentlog/scope.hpp>
#include <xo/indentlog/print/tag.hpp>
#include <catch2/catch.hpp>
namespace ut {
using xo::S_object2_tag;
using xo::scm::object2_register_types;
using xo::scm::ListOps;
using xo::scm::DList;
using xo::scm::DArray;
using xo::scm::DFloat;
using xo::scm::DInteger;
using xo::mm::CollectorTypeRegistry;
using xo::mm::AAllocator;
using xo::mm::ACollector;
using xo::mm::AllocHeader;
@ -49,6 +55,9 @@ namespace ut {
using xo::mm::padding;
using xo::facet::with_facet;
using xo::facet::typeseq;
using xo::Subsystem;
using xo::InitEvidence;
using xo::InitSubsys;
using xo::scope;
using xo::xtag;
@ -79,8 +88,13 @@ namespace ut {
};
}
static InitEvidence s_init = (InitSubsys<S_object2_tag>::require());
TEST_CASE("x1", "[gc][x1]")
{
// real purpose: ensure s_init survives static linking
REQUIRE(s_init.evidence());
/**
* This is a basic Collector test for xo-object2 data types
**/
@ -89,6 +103,8 @@ namespace ut {
scope log(XO_DEBUG(c_debug_flag));
for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) {
scope log(XO_DEBUG(true), xtag("i_tc", i_tc));
try {
const testcase_x1 & tc = s_testcase_v[i_tc];
@ -169,7 +185,7 @@ namespace ut {
auto c_o = with_facet<ACollector>::mkobj(&gc);
/* register object types */
bool ok = object2_register_types(c_o);
bool ok = CollectorTypeRegistry::instance().install_types(c_o);
REQUIRE(ok);

View file

@ -1,6 +1,24 @@
/* file object2_utest_main.cpp */
#define CATCH_CONFIG_MAIN
#include <xo/subsys/Subsystem.hpp>
#define CATCH_CONFIG_RUNNER
#include "catch2/catch.hpp"
int
main(int argc, char* argv[])
{
using xo::Subsystem;
// Your custom initialization code here
Subsystem::initialize_all();
// Run Catch2's test session
int result = Catch::Session().run(argc, argv);
// cleanup here, if any
return result;
}
/* end object2_utest_main.cpp */