refactor: + xo-stringtable2 w/ DString impl
This commit is contained in:
parent
e33ab0ae98
commit
ee982276c9
5 changed files with 215 additions and 0 deletions
|
|
@ -6,6 +6,11 @@ set(SELF_SRCS
|
|||
init_alloc2.cpp
|
||||
alloc2_register_facets.cpp
|
||||
|
||||
CollectorTypeRegistry.cpp
|
||||
|
||||
ICollector_Any.cpp
|
||||
IGCObject_Any.cpp
|
||||
|
||||
AAllocator.cpp
|
||||
IAllocator_Any.cpp
|
||||
IAllocator_DArena.cpp
|
||||
|
|
|
|||
48
src/alloc2/CollectorTypeRegistry.cpp
Normal file
48
src/alloc2/CollectorTypeRegistry.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/** @file CollectorTypeRegistry.cpp
|
||||
**/
|
||||
|
||||
#include "CollectorTypeRegistry.hpp"
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace mm {
|
||||
CollectorTypeRegistry &
|
||||
CollectorTypeRegistry::instance()
|
||||
{
|
||||
static CollectorTypeRegistry s_instance;
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
void
|
||||
CollectorTypeRegistry::register_types(init_function_type fn)
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
init_seq_v_.push_back(fn);
|
||||
}
|
||||
|
||||
bool
|
||||
CollectorTypeRegistry::install_types(obj<ACollector> gc)
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
bool ok = true;
|
||||
|
||||
size_t i = 0;
|
||||
size_t n = init_seq_v_.size();
|
||||
log && log("run n init steps", xtag("n", n));
|
||||
|
||||
for (const auto & fn : init_seq_v_) {
|
||||
log && log("do install fn (", i+1, "/", n, ")");
|
||||
|
||||
ok = ok & fn(gc);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end CollectorTypeRegistry.cpp */
|
||||
40
src/alloc2/ICollector_Any.cpp
Normal file
40
src/alloc2/ICollector_Any.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/** @file ICollector_Any.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#include "gc/ICollector_Any.hpp"
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
namespace xo {
|
||||
using xo::facet::DVariantPlaceholder;
|
||||
using xo::facet::typeseq;
|
||||
using xo::facet::valid_facet_implementation;
|
||||
|
||||
namespace mm {
|
||||
|
||||
void
|
||||
ICollector_Any::_fatal() {
|
||||
/* control here on uninitialized ICollector_Any.
|
||||
* Initialized instance will have specific implementation type
|
||||
* e.g. ICollector_Xfer<DCollector>
|
||||
*/
|
||||
|
||||
std::cerr << "fatal"
|
||||
<< ": attempt to call uninitialized"
|
||||
<< " ICollector_Any method"
|
||||
<< std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
typeseq
|
||||
ICollector_Any::s_typeseq = typeseq::id<DVariantPlaceholder>();
|
||||
|
||||
bool
|
||||
ICollector_Any::_valid = valid_facet_implementation<ACollector, ICollector_Any>();
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end ICollector_Any.cpp */
|
||||
48
src/alloc2/IGCObject_Any.cpp
Normal file
48
src/alloc2/IGCObject_Any.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/** @file IGCObject_Any.cpp
|
||||
*
|
||||
**/
|
||||
|
||||
#include "gc/IGCObject_Any.hpp"
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
namespace xo {
|
||||
namespace mm {
|
||||
|
||||
using xo::facet::DVariantPlaceholder;
|
||||
using xo::facet::typeseq;
|
||||
using xo::facet::valid_facet_implementation;
|
||||
|
||||
void
|
||||
IGCObject_Any::_fatal()
|
||||
{
|
||||
/* control here on uninitialized IAllocator_Any.
|
||||
* Initialized instance will have specific implementation type
|
||||
*/
|
||||
std::cerr << "fatal"
|
||||
<< ": attempt to call uninitialized"
|
||||
<< " IGCObject_Any method"
|
||||
<< std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
typeseq
|
||||
IGCObject_Any::s_typeseq = typeseq::id<DVariantPlaceholder>();
|
||||
|
||||
bool
|
||||
IGCObject_Any::_valid
|
||||
= valid_facet_implementation<AGCObject, IGCObject_Any>();
|
||||
|
||||
// nonconst methods
|
||||
|
||||
auto
|
||||
IGCObject_Any::forward_children(Opaque, obj<ACollector>) const noexcept -> size_type
|
||||
{
|
||||
_fatal();
|
||||
}
|
||||
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IGCObject_Any.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue