xo-XXX -> .xo-XXX (prep subrepo)
This commit is contained in:
parent
2342dc02a2
commit
cf0bd4d975
2105 changed files with 0 additions and 0 deletions
|
|
@ -1,34 +0,0 @@
|
|||
# xo-stringtable2/src/stringtable2/CMakeLists.txt
|
||||
|
||||
set(SELF_LIB xo_stringtable2)
|
||||
set(SELF_SRCS
|
||||
init_stringtable2.cpp
|
||||
SetupStringtable2.cpp
|
||||
|
||||
StringTable.cpp
|
||||
|
||||
DString.cpp
|
||||
IGCObject_DString.cpp
|
||||
IPrintable_DString.cpp
|
||||
|
||||
DUniqueString.cpp
|
||||
IGCObject_DUniqueString.cpp
|
||||
IPrintable_DUniqueString.cpp
|
||||
|
||||
)
|
||||
|
||||
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})
|
||||
xo_install_include_tree3(include/xo/stringtable2)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# input dependencies
|
||||
#
|
||||
# NOTE: dependency set here must be kept consistent with
|
||||
# xo-stringtable2/cmake/xo_stringtable2Config.cmake.in
|
||||
|
||||
xo_dependency(${SELF_LIB} xo_alloc2)
|
||||
xo_dependency(${SELF_LIB} xo_printable2)
|
||||
xo_dependency(${SELF_LIB} subsys)
|
||||
xo_dependency(${SELF_LIB} indentlog)
|
||||
|
||||
# end src/stringtable2/CMakeLists.txt
|
||||
|
|
@ -1,191 +0,0 @@
|
|||
/** @file DString.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "DString.hpp"
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/indentlog/print/pretty.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
namespace xo {
|
||||
using xo::reflect::typeseq;
|
||||
using xo::print::ppdetail_atomic;
|
||||
|
||||
namespace scm {
|
||||
DString *
|
||||
DString::empty(obj<AAllocator> mm,
|
||||
size_type cap)
|
||||
{
|
||||
assert(cap > 0);
|
||||
|
||||
DString * result = nullptr;
|
||||
|
||||
if (cap > 0) {
|
||||
void * mem = mm.alloc(typeseq::id<DString>(),
|
||||
sizeof(DString) + cap);
|
||||
|
||||
if (mem) {
|
||||
result = new (mem) DString();
|
||||
|
||||
assert(result);
|
||||
|
||||
result->capacity_ = cap;
|
||||
result->size_ = 0;
|
||||
if (cap > 0) {
|
||||
result->chars_[0] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DString *
|
||||
DString::from_cstr(obj<AAllocator> mm,
|
||||
const char * cstr)
|
||||
{
|
||||
size_type len = std::strlen(cstr);
|
||||
size_type cap = len + 1;
|
||||
|
||||
void * mem = mm.alloc(typeseq::id<DString>(),
|
||||
sizeof(DString) + cap);
|
||||
|
||||
DString * result = nullptr;
|
||||
|
||||
if (mem) {
|
||||
result = new (mem) DString();
|
||||
result->capacity_ = cap;
|
||||
result->size_ = len;
|
||||
|
||||
std::memcpy(result->chars_, cstr, cap);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DString *
|
||||
DString::_from_view_aux(obj<AAllocator> mm,
|
||||
std::string_view sv,
|
||||
bool suballoc_flag)
|
||||
{
|
||||
size_type len = sv.size();
|
||||
size_type cap = len + 1;
|
||||
|
||||
auto tseq = typeseq::id<DString>();
|
||||
void * mem = nullptr;
|
||||
size_type mem_z = sizeof(DString) + cap;
|
||||
|
||||
if (suballoc_flag)
|
||||
mem = mm.sub_alloc(mem_z, false /*!complete_flag*/);
|
||||
else
|
||||
mem = mm.alloc(tseq, mem_z);
|
||||
|
||||
DString * result = new (mem) DString();
|
||||
|
||||
result->capacity_ = cap;
|
||||
result->size_ = len;
|
||||
std::memcpy(result->chars_, sv.data(), len);
|
||||
result->chars_[len] = '\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DString *
|
||||
DString::from_view(obj<AAllocator> mm,
|
||||
std::string_view sv)
|
||||
{
|
||||
return _from_view_aux(mm, sv, false /*!suballoc_flag*/);
|
||||
}
|
||||
|
||||
DString *
|
||||
DString::from_str(obj<AAllocator> mm,
|
||||
const std::string & str)
|
||||
{
|
||||
return _from_view_aux(mm,
|
||||
std::string_view(str),
|
||||
false /*!suballoc_flag*/);
|
||||
}
|
||||
|
||||
DString *
|
||||
DString::from_view_suballoc(obj<AAllocator> mm,
|
||||
std::string_view sv)
|
||||
{
|
||||
return _from_view_aux(mm, sv, true /*suballoc_flag*/);
|
||||
}
|
||||
|
||||
DString *
|
||||
DString::clone(obj<AAllocator> mm, const DString * src)
|
||||
{
|
||||
size_type cap = src->capacity_;
|
||||
|
||||
void * mem = mm.alloc(typeseq::id<DString>(),
|
||||
sizeof(DString) + cap);
|
||||
|
||||
DString * result = new (mem) DString();
|
||||
result->capacity_ = cap;
|
||||
result->size_ = src->size_;
|
||||
std::memcpy(result->chars_, src->chars_, cap);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DString &
|
||||
DString::assign(const DString & other)
|
||||
{
|
||||
size_type n = std::min(other.size_, capacity_ - 1);
|
||||
std::memcpy(chars_, other.chars_, n);
|
||||
chars_[n] = '\0';
|
||||
size_ = n;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
int
|
||||
DString::compare(const DString & lhs, const DString & rhs) noexcept
|
||||
{
|
||||
return ::strcmp(lhs.chars_, rhs.chars_);
|
||||
}
|
||||
|
||||
auto
|
||||
DString::fixup_size() noexcept -> size_type
|
||||
{
|
||||
this->chars_[capacity_ - 1] = '\0';
|
||||
this->size_ = ::strlen(chars_);
|
||||
return this->size_;
|
||||
}
|
||||
|
||||
DString *
|
||||
DString::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
// note: not using gc.std_move_for() here
|
||||
// b/c DString flexible array means not move-constructible
|
||||
|
||||
DString * copy = (DString *)gc.alloc_copy_for(this);
|
||||
|
||||
if (copy) {
|
||||
copy->capacity_ = capacity_;
|
||||
copy->size_ = size_;
|
||||
::memcpy(copy->chars_, chars_, capacity_);
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void
|
||||
DString::visit_gco_children(VisitReason, obj<AGCObjectVisitor>) noexcept
|
||||
{
|
||||
// no-op. no children!
|
||||
}
|
||||
|
||||
bool
|
||||
DString::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
return ppdetail_atomic<const char *>::print_pretty(ppii, &(chars_[0]));
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DString.cpp */
|
||||
|
|
@ -1,119 +0,0 @@
|
|||
/** @file DUniqueString.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "DUniqueString.hpp"
|
||||
#include "DString.hpp"
|
||||
#include <xo/arena/padding.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
#include <cstring>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::padding;
|
||||
using xo::facet::typeseq;
|
||||
|
||||
namespace scm {
|
||||
int
|
||||
DUniqueString::compare(const DUniqueString & lhs, const DUniqueString & rhs)
|
||||
{
|
||||
if (&lhs == &rhs)
|
||||
return 0;
|
||||
|
||||
return DString::compare(*(lhs._text()), *(rhs._text()));
|
||||
}
|
||||
|
||||
DString *
|
||||
DUniqueString::_text() const noexcept
|
||||
{
|
||||
// location of paired DString is chosen
|
||||
// by allocator (DArena, probably).
|
||||
//
|
||||
// In general allocator alignment more conservative
|
||||
// than C++ alignment
|
||||
//
|
||||
// Remmebr also: although DUniqueString has zero members,
|
||||
// C++ requires it to behave asif size at least 1 byte
|
||||
// for iterator consistency
|
||||
// (e.g. because c++ would support iterating over
|
||||
// std::vector<EmptyStruct>)
|
||||
//
|
||||
size_t offset = padding::with_padding(sizeof(*this));
|
||||
assert(offset > 0);
|
||||
|
||||
return (DString *)(((std::byte *)this) + offset);
|
||||
}
|
||||
|
||||
bool
|
||||
DUniqueString::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
return _text()->pretty(ppii);
|
||||
}
|
||||
|
||||
DUniqueString *
|
||||
DUniqueString::from_view(obj<AAllocator> mm,
|
||||
std::string_view sv)
|
||||
{
|
||||
scope log(XO_DEBUG(false));
|
||||
|
||||
/** fine point: choosing to allocate DUniqueString ahead of DString,
|
||||
* so it comes first in bump allocator
|
||||
**/
|
||||
|
||||
void * mem = mm.super_alloc(typeseq::id<DUniqueString>(),
|
||||
sizeof(DUniqueString));
|
||||
DUniqueString * result = new (mem) DUniqueString();
|
||||
|
||||
/** allocated in memory immediate following @p result.
|
||||
* This optimization saves us one pointer (8 bytes) in DUniqueString
|
||||
* itself, plus one allocation header (8 bytes) for 16 bytes total
|
||||
**/
|
||||
DString * text = DString::from_view_suballoc(mm, sv);
|
||||
|
||||
log && log(xtag("result", result), xtag("result.text", result->_text()), xtag("text", text));
|
||||
|
||||
assert(text);
|
||||
assert(text == result->_text());
|
||||
|
||||
/** must finish super-allocation before next alloc **/
|
||||
mm.sub_alloc(0, true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DUniqueString *
|
||||
DUniqueString::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
// well-posed, but not expected to be used.
|
||||
//
|
||||
// Not using gc.std_move_for() here because compiler doesn't know
|
||||
// actual alloc size of a DUniqueString instance
|
||||
|
||||
assert(false);
|
||||
|
||||
DUniqueString * copy = (DUniqueString *)gc.alloc_copy((std::byte *)this);
|
||||
|
||||
if (copy) {
|
||||
// Copy assignment not implemented in general
|
||||
// *copy = *this;
|
||||
// in this case *copy already has the same size as *this
|
||||
|
||||
assert(size() <= capacity());
|
||||
|
||||
strncpy(copy->_text()->data(),
|
||||
this->_text()->chars(),
|
||||
this->size());
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void
|
||||
DUniqueString::visit_gco_children(VisitReason, obj<AGCObjectVisitor>) noexcept
|
||||
{
|
||||
// no-op -- childless!
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DUniqueString.cpp */
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/** @file IGCObject_DString.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IGCObject_DString.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IGCObject_DString.json5]
|
||||
**/
|
||||
|
||||
#include "string/IGCObject_DString.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DString::gco_shallow_move(DString & self, obj<AGCObjectVisitor> gc) noexcept -> Opaque
|
||||
{
|
||||
return self.gco_shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DString::visit_gco_children(DString & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.visit_gco_children(reason, fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IGCObject_DString.cpp */
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/** @file IGCObject_DUniqueString.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IGCObject_DUniqueString.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IGCObject_DUniqueString.json5]
|
||||
**/
|
||||
|
||||
#include "uniquestring/IGCObject_DUniqueString.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DUniqueString::gco_shallow_move(DUniqueString & self, obj<AGCObjectVisitor> gc) noexcept -> Opaque
|
||||
{
|
||||
return self.gco_shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DUniqueString::visit_gco_children(DUniqueString & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.visit_gco_children(reason, fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IGCObject_DUniqueString.cpp */
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/** @file IPrintable_DString.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DString.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DString.json5]
|
||||
**/
|
||||
|
||||
#include "string/IPrintable_DString.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IPrintable_DString::pretty(const DString & self, const ppindentinfo & ppii) -> bool
|
||||
{
|
||||
return self.pretty(ppii);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_DString.cpp */
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/** @file IPrintable_DUniqueString.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DUniqueString.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DUniqueString.json5]
|
||||
**/
|
||||
|
||||
#include "uniquestring/IPrintable_DUniqueString.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IPrintable_DUniqueString::pretty(const DUniqueString & self, const ppindentinfo & ppii) -> bool
|
||||
{
|
||||
return self.pretty(ppii);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_DUniqueString.cpp */
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/** @file SetupStringtable2.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Mar 2026
|
||||
**/
|
||||
|
||||
#include "SetupStringtable2.hpp"
|
||||
|
||||
#include <xo/stringtable2/UniqueString.hpp>
|
||||
#include <xo/stringtable2/String.hpp>
|
||||
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::print::APrintable;
|
||||
using xo::mm::ACollector;
|
||||
using xo::mm::AGCObject;
|
||||
using xo::scm::DString;
|
||||
using xo::facet::FacetRegistry;
|
||||
using xo::facet::typeseq;
|
||||
using xo::facet::impl_for;
|
||||
|
||||
namespace scm {
|
||||
bool
|
||||
SetupStringtable2::register_facets()
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
FacetRegistry::register_impl<AGCObject, DUniqueString>();
|
||||
FacetRegistry::register_impl<APrintable, DUniqueString>();
|
||||
|
||||
FacetRegistry::register_impl<AGCObject, DString>();
|
||||
FacetRegistry::register_impl<APrintable, DString>();
|
||||
|
||||
log && log(xtag("DString.tseq", typeseq::id<DString>()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
SetupStringtable2::register_types(obj<ACollector> gc)
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= gc.install_type(impl_for<AGCObject, DUniqueString>());
|
||||
ok &= gc.install_type(impl_for<AGCObject, DString>());
|
||||
|
||||
return ok;
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end SetupStringtable2.cpp */
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
/** @file StringTable.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "StringTable.hpp"
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/alloc2/arena/IAllocator_DArena.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::ArenaConfig;
|
||||
using xo::mm::AAllocator;
|
||||
using xo::mm::MemorySizeInfo;
|
||||
using xo::facet::with_facet;
|
||||
using xo::facet::obj;
|
||||
|
||||
namespace scm {
|
||||
StringTable::StringTable(size_type hint_max_capacity,
|
||||
bool debug_flag)
|
||||
: strings_{DArena::map(ArenaConfig{.name_ = "strings",
|
||||
.size_ = hint_max_capacity})},
|
||||
map_{"stringkeys", hint_max_capacity}
|
||||
{
|
||||
(void)debug_flag;
|
||||
}
|
||||
|
||||
const DUniqueString *
|
||||
StringTable::lookup(std::string_view key) const
|
||||
{
|
||||
auto ix = map_.find(key);
|
||||
|
||||
if (ix != map_.end())
|
||||
return ix->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const DUniqueString *
|
||||
StringTable::intern(std::string_view key)
|
||||
{
|
||||
// 1a. lookup key in map_.
|
||||
// 1b. if present, return existing DString*
|
||||
|
||||
auto ix = map_.find(key);
|
||||
|
||||
if (ix != map_.end())
|
||||
return ix->second;
|
||||
|
||||
// 2. otherwise need to add.
|
||||
//
|
||||
// 2d. return key2 address
|
||||
|
||||
// 2a. allocate DUniqueString copy 'interned' of key in strings_
|
||||
auto mm = with_facet<AAllocator>::mkobj(&strings_);
|
||||
DUniqueString * interned = DUniqueString::from_view(mm, key);
|
||||
|
||||
assert(interned);
|
||||
if (interned) {
|
||||
// 2b. make string_view from *interned
|
||||
std::string_view interned_key = std::string_view(*interned);
|
||||
|
||||
// interned_key has same lifetime as StringTable,
|
||||
// we can use it in map_
|
||||
|
||||
// 2c. store address of 'interned' in map_
|
||||
auto & slot = this->map_[interned_key];
|
||||
|
||||
slot = interned;
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const DUniqueString *
|
||||
StringTable::gensym(std::string_view prefix)
|
||||
{
|
||||
static std::size_t s_counter = 0;
|
||||
|
||||
while (true) {
|
||||
++s_counter;
|
||||
|
||||
char buf[80];
|
||||
assert(prefix.size() + 20 < sizeof(buf));
|
||||
|
||||
int n = snprintf(buf, sizeof(buf),
|
||||
"%s:%lu",
|
||||
prefix.data(), s_counter);
|
||||
|
||||
if ((0 < n) && (std::size_t(n) < sizeof(buf)))
|
||||
buf[n] = '\0';
|
||||
else
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
|
||||
std::string_view sv(buf);
|
||||
const DUniqueString * retval = this->lookup(sv);
|
||||
if (!retval) {
|
||||
/* not already in string view -> we have viable candidate */
|
||||
retval = this->intern(sv);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
StringTable::verify_ok(verify_policy policy) const
|
||||
{
|
||||
using xo::scope;
|
||||
using xo::xtag;
|
||||
|
||||
constexpr const char * c_self = "StringTable::verify_ok";
|
||||
scope log(XO_DEBUG(false));
|
||||
|
||||
/* ST1: underlying hash map passes its invariants */
|
||||
if (!map_.verify_ok(policy)) {
|
||||
return policy.report_error(log,
|
||||
c_self, ": map_.verify_ok failed");
|
||||
}
|
||||
|
||||
/* ST2: for each entry, key points to value's string data */
|
||||
for (const auto & kv : map_) {
|
||||
const std::string_view & key = kv.first;
|
||||
const DUniqueString * value = kv.second;
|
||||
|
||||
/* ST2.1: value is not null */
|
||||
if (value == nullptr) {
|
||||
return policy.report_error(log,
|
||||
c_self, ": null value in map",
|
||||
xtag("key", key));
|
||||
}
|
||||
|
||||
/* ST2.2: value lies within strings_ arena */
|
||||
if (!strings_.contains(value)) {
|
||||
return policy.report_error(log,
|
||||
c_self, ": value not in strings_ arena",
|
||||
xtag("key", key),
|
||||
xtag("value", (void*)value));
|
||||
}
|
||||
|
||||
/* ST2.3: key.data() points to value's chars */
|
||||
if (key.data() != value->chars()) {
|
||||
return policy.report_error(log,
|
||||
c_self, ": key.data() != value->chars()",
|
||||
xtag("key", key),
|
||||
xtag("key.data()", (void*)key.data()),
|
||||
xtag("value->chars()", (void*)value->chars()));
|
||||
}
|
||||
|
||||
/* ST2.4: key.size() == value->size() */
|
||||
if (key.size() != value->size()) {
|
||||
return policy.report_error(log,
|
||||
c_self, ": key.size() != value->size()",
|
||||
xtag("key", key),
|
||||
xtag("key.size()", key.size()),
|
||||
xtag("value->size()", value->size()));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
StringTable::visit_pools(const MemorySizeVisitor & visitor) const
|
||||
{
|
||||
strings_.visit_pools(visitor);
|
||||
map_.visit_pools(visitor);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end StringTable.cpp */
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/** @file init_stringtable2.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "init_stringtable2.hpp"
|
||||
#include "SetupStringtable2.hpp"
|
||||
#include <xo/stringtable2/init_stringtable2.hpp>
|
||||
#include <xo/alloc2/CollectorTypeRegistry.hpp>
|
||||
#include <xo/alloc2/init_alloc2.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::scm::SetupStringtable2;
|
||||
using xo::mm::CollectorTypeRegistry;
|
||||
|
||||
void
|
||||
InitSubsys<S_stringtable2_tag>::init()
|
||||
{
|
||||
SetupStringtable2::register_facets();
|
||||
|
||||
CollectorTypeRegistry::instance().register_types(&SetupStringtable2::register_types);
|
||||
}
|
||||
|
||||
InitEvidence
|
||||
InitSubsys<S_stringtable2_tag>::require()
|
||||
{
|
||||
InitEvidence retval;
|
||||
|
||||
/* direct subsystem deps for xo-stringtable2/ */
|
||||
retval ^= InitSubsys<S_alloc2_tag>::require();
|
||||
//retval ^= InitSubsys<S_printable_tag>::require();
|
||||
|
||||
/* xo-expression2/'s own initialization code */
|
||||
retval ^= Subsystem::provide<S_stringtable2_tag>("stringtable2", &init);
|
||||
|
||||
return retval;
|
||||
}
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end init_stringtable2.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue