diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index 2592147..d125fc4 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -7,6 +7,7 @@ #include #include +#include #include 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 + static obj box(obj mm, long x); + /** allocate boxed value @p x using memory from @p mm **/ - static DInteger * make(obj mm, - long x); + static DInteger * _box(obj mm, long x); double value() const noexcept { return value_; } @@ -31,6 +35,13 @@ namespace xo { /** boxed integer value **/ long value_; }; + + template + obj + DInteger::box(obj mm, long x) { + return obj(_box(mm, x)); + } + } /*nmaespace obj*/ } /*namespace xo*/ diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 1aa3efb..8e1b959 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -12,8 +12,7 @@ namespace xo { namespace scm { DInteger * - DInteger::make(obj mm, - long x) + DInteger::_box(obj mm, long x) { void * mem = mm.alloc(typeseq::id(), sizeof(DInteger)); diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index d385a8e..e84d52a 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -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::mkobj(xi); + auto xi_o = DInteger::box(gc_o, tc.list_[ip1 - 1]); l0_o = DList::cons(gc_o, xi_o, l0_o); }