diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 0dc13cd..097b9a4 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -23,7 +23,7 @@ namespace xo { * fixed at construction time, but not part of type. * Can reallocate to change **/ - struct DArray { + class DArray { public: /** @defgroup darray-types type traits **/ ///@{ diff --git a/include/xo/object2/number/GCObjectConversion_DFloat.hpp b/include/xo/object2/number/GCObjectConversion_DFloat.hpp index 8ce4b2b..959eeca 100644 --- a/include/xo/object2/number/GCObjectConversion_DFloat.hpp +++ b/include/xo/object2/number/GCObjectConversion_DFloat.hpp @@ -19,7 +19,7 @@ namespace xo { using AGCObject = xo::mm::AGCObject; using AAllocator = xo::mm::AAllocator; - static obj to_gco(obj mm, const double & x); + static obj to_gco(obj mm, double x); static double from_gco(obj mm, obj gco); }; diff --git a/include/xo/object2/number/GCObjectConversion_DInteger.hpp b/include/xo/object2/number/GCObjectConversion_DInteger.hpp new file mode 100644 index 0000000..458312c --- /dev/null +++ b/include/xo/object2/number/GCObjectConversion_DInteger.hpp @@ -0,0 +1,29 @@ +/** @file GCObjectConversion_DInteger.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "DInteger.hpp" +#include "number/IGCObject_DInteger.hpp" +#include + +namespace xo { + namespace scm { + + template <> + struct GCObjectConversion { + static_assert(std::is_same_v); + + using AGCObject = xo::mm::AGCObject; + using AAllocator = xo::mm::AAllocator; + + static obj to_gco(obj mm, long x); + static long from_gco(obj mm, obj gco); + }; + + } +} /*namespace xo*/ + +/* end GCObjectConversion_DInteger.hpp */ diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 2902a4e..2ea8a07 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -6,6 +6,7 @@ set(SELF_SRCS object2_register_types.cpp object2_register_facets.cpp GCObjectConversion_DFloat.cpp + GCObjectConversion_DInteger.cpp IGCObject_DArray.cpp IGCObject_DFloat.cpp IGCObject_DBoolean.cpp diff --git a/src/object2/GCObjectConversion_DFloat.cpp b/src/object2/GCObjectConversion_DFloat.cpp index a99c68c..794431d 100644 --- a/src/object2/GCObjectConversion_DFloat.cpp +++ b/src/object2/GCObjectConversion_DFloat.cpp @@ -13,7 +13,7 @@ namespace xo { obj GCObjectConversion::to_gco(obj mm, - const double & x) + double x) { return DFloat::box(mm, x); } diff --git a/src/object2/GCObjectConversion_DInteger.cpp b/src/object2/GCObjectConversion_DInteger.cpp new file mode 100644 index 0000000..bdaf8a1 --- /dev/null +++ b/src/object2/GCObjectConversion_DInteger.cpp @@ -0,0 +1,41 @@ +/** @file GCObjectConversion_DInteger.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "number/GCObjectConversion_DInteger.hpp" +#include + +namespace xo { + using xo::mm::AGCObject; + + namespace scm { + + obj + GCObjectConversion::to_gco(obj mm, + long x) + { + return DInteger::box(mm, x); + } + + long + GCObjectConversion::from_gco(obj mm, + obj gco) + { + (void)mm; + + auto int_obj = obj::from(gco); + + if (!int_obj) { + throw std::runtime_error + (tostr("Object obj found where Integer expected", + xtag("obj", gco))); + } + + return int_obj.data()->value(); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end GCObjectConversion_DFloat.cpp */