xo-gc xo-object2 xo-facet: builds w/ ISequence,Dlist

This commit is contained in:
Roland Conybeare 2025-12-29 14:32:52 -05:00
commit afc44e71fa
26 changed files with 717 additions and 75 deletions

View file

@ -6,9 +6,12 @@ set(SELF_SRCS
IGCObject_DInteger.cpp
IGCObject_DList.cpp
ISequence_Any.cpp
ISequence_DList.cpp
DList.cpp
)
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})
# note: deps here must also appear in cmake/xo_alloc2Config.cmake.in
xo_dependency(${SELF_LIB} xo_gc)
#xo_dependency(${SELF_LIB} indentlog)
#add_dependencies(${SELF_LIB} xo-object2-facetimpl-sequence-list)

View file

@ -0,0 +1,54 @@
/** @file DList.cpp
*
* @author Roland Conybeare, Dec 2025
**/
#include "DList.hpp"
#include <xo/indentlog/print/tag.hpp>
namespace xo {
namespace scm {
auto
DList::size() const noexcept -> size_type
{
const DList * l = this;
size_type z = 0;
while (l) {
++z;
l = l->rest_;
}
return z;
}
auto
DList::at(size_type index) const -> obj<AGCObject>
{
size_type ix = index;
const DList * l = this;
while (l->rest_ && (ix > 0)) {
--ix;
l = l->rest_;
}
if (ix > 0) {
assert(l == nullptr);
throw std::runtime_error
(tostr("DList::at: out-of-range index where [0..z) expected",
xtag("index", index),
xtag("z", this->size())));
}
assert(l);
return l->head_;
}
} /*namespace scm*/
} /*namespace xo*/
/* end DList.cpp */

View file

@ -6,7 +6,9 @@
#include "IGCObject_DList.hpp"
namespace xo {
using xo::mm::AGCObject;
using xo::mm::AAllocator;
using xo::facet::with_facet;
using xo::facet::obj;
using std::size_t;
@ -33,8 +35,11 @@ namespace xo {
IGCObject_DList::forward_children(DList & src,
obj<ACollector> gc) noexcept
{
gc.forward_inplace(&src.head_);
gc.forward_inplace(&src.rest_);
gc.forward_inplace(src.head_.iface(), (void **)&(src.head_.data_));
//auto rest = with_facet<AGCObject>::mkobj(src.rest_);
xo::facet::FacetImplementation<xo::mm::AGCObject, DList>::ImplType iface;
gc.forward_inplace(&iface, (void **)(&src.rest_));
return shallow_size(src);
}

View file

@ -0,0 +1,40 @@
/** @file ISequence_DList.cpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/ISequence_DList.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/ISequence_DList.json5]
**/
#include "ISequence_DList.hpp"
namespace xo {
namespace scm {
auto
ISequence_DList::is_empty(const DList & self) noexcept -> bool
{
return self.is_empty();
}
auto
ISequence_DList::is_finite(const DList & self) noexcept -> bool
{
return self.is_finite();
}
auto
ISequence_DList::at(const DList & self, size_type index) -> obj<AGCObject>
{
return self.at(index);
}
} /*namespace scm*/
} /*namespace xo*/
/* end ISequence_DList.cpp */