xo-object2: streamline DInteger alloc. make() -> box()

This commit is contained in:
Roland Conybeare 2026-01-09 17:54:42 -05:00
commit 59ce547db3
3 changed files with 15 additions and 7 deletions

View file

@ -7,6 +7,7 @@
#include <xo/alloc2/Allocator.hpp>
#include <xo/indentlog/print/ppindentinfo.hpp>
#include <xo/facet/obj.hpp>
#include <cstdint>
namespace xo {
@ -17,9 +18,12 @@ namespace xo {
explicit DInteger(long x) : value_{x} {}
/** will likely want this to default to ANumeric, once we have it **/
template <typename AFacet>
static obj<AFacet, DInteger> box(obj<AAllocator> mm, long x);
/** allocate boxed value @p x using memory from @p mm **/
static DInteger * make(obj<AAllocator> mm,
long x);
static DInteger * _box(obj<AAllocator> mm, long x);
double value() const noexcept { return value_; }
@ -31,6 +35,13 @@ namespace xo {
/** boxed integer value **/
long value_;
};
template <typename AFacet>
obj<AFacet, DInteger>
DInteger::box(obj<AAllocator> mm, long x) {
return obj<AFacet,DInteger>(_box(mm, x));
}
} /*nmaespace obj*/
} /*namespace xo*/

View file

@ -12,8 +12,7 @@ namespace xo {
namespace scm {
DInteger *
DInteger::make(obj<AAllocator> mm,
long x)
DInteger::_box(obj<AAllocator> mm, long x)
{
void * mem = mm.alloc(typeseq::id<DInteger>(),
sizeof(DInteger));

View file

@ -112,9 +112,7 @@ namespace ut {
c_o.add_gc_root(&l0_o);
for(int ip1 = tc.list_.size(); ip1 > 0; --ip1) {
// auto xi_o = Integer::make(g_o, ...);
DInteger * xi = DInteger::make(gc_o, tc.list_[ip1 - 1]);
auto xi_o = with_facet<AGCObject>::mkobj(xi);
auto xi_o = DInteger::box<AGCObject>(gc_o, tc.list_[ip1 - 1]);
l0_o = DList::cons(gc_o, xi_o, l0_o);
}