/** @file DConstant.cpp * * @author Roland Conybeare, Jan 2026 **/ #include "DConstant.hpp" #include "detail/IExpression_DConstant.hpp" #include "TypeDescr.hpp" #include #include #include #include #include #include #include namespace xo { using xo::scm::DFloat; using xo::scm::DInteger; using xo::print::APrintable; using xo::facet::FacetRegistry; using xo::reflect::Reflect; using xo::reflect::TypeDescr; using xo::reflect::typeseq; namespace scm { DConstant::DConstant(obj value) noexcept : //typeref_{TypeRef::resolved(td)}, value_{value} { // todo: use ObjectConverter here auto tseq = value_._typeseq(); TypeDescr td = this->_lookup_td(tseq); if (td) { typeref_ = TypeRef::resolved(td); } } obj DConstant::make(obj mm, obj value) { return obj(_make(mm, value)); } DConstant * DConstant::_make(obj mm, obj value) { void * mem = mm.alloc(typeseq::id(), sizeof(DConstant)); return new (mem) DConstant(value); } TypeDescr DConstant::_lookup_td(typeseq tseq) { if (tseq == typeseq::id()) { /* double */ return Reflect::require(); } else if (tseq == typeseq::id()) { /* long */ return Reflect::require(); } return nullptr; } bool DConstant::pretty(const ppindentinfo & ppii) const { obj value_pr = FacetRegistry::instance().variant(value_); return ppii.pps()->pretty_struct (ppii, "DConstant", refrtag("value_.tseq", value_._typeseq()), refrtag("value.tseq", value_pr._typeseq()), refrtag("value", value_pr)); } } /*namespace scm*/ } /*namespace xo*/ /* end DConstant.cpp */