/** @file DRuntimeError.cpp * * @author Roland Conybeare, Feb 2026 **/ #include "RuntimeError.hpp" namespace xo { using xo::print::APrintable; using xo::mm::AGCObject; using xo::facet::typeseq; namespace scm { obj DRuntimeError::make(obj mm, const char * src_fn, const char * error_descr) { DRuntimeError * err = DRuntimeError::_make(mm, nullptr, nullptr); // pedantic: allocate strings after allocating DRuntimeError instance DString * src = DString::from_cstr(mm, src_fn); DString * err_descr = DString::from_cstr(mm, error_descr); err->src_function_ = src; err->error_descr_ = err_descr; return obj(err); } DRuntimeError * DRuntimeError::_make(obj mm, DString * src_fn, DString * error_descr) { void * mem = mm.alloc(typeseq::id(), sizeof(DRuntimeError)); DRuntimeError * err = new (mem) DRuntimeError(src_fn, error_descr); return err; } DRuntimeError::DRuntimeError(DString * src_fn, DString * error_descr) : src_function_{src_fn}, error_descr_{error_descr} {} // ----- GCObject facet ----- std::size_t DRuntimeError::shallow_size() const noexcept { return sizeof(DRuntimeError); } DRuntimeError * DRuntimeError::shallow_move(obj mm) const noexcept { DRuntimeError * copy = (DRuntimeError *)mm.alloc_copy((std::byte *)this); if (copy) *copy = *this; return copy; } std::size_t DRuntimeError::forward_children(obj gc) noexcept { { auto iface = xo::facet::impl_for(); gc.forward_inplace(&iface, (void **)(&src_function_)); } { auto iface = xo::facet::impl_for(); gc.forward_inplace(&iface, (void **)(&error_descr_)); } return this->shallow_size(); } // ----- Printable facet ----- bool DRuntimeError::pretty(const ppindentinfo & ppii) const { return ppii.pps()->pretty_struct (ppii, "DRuntimeError", refrtag("src", obj(src_function_)), refrtag("err", obj(error_descr_))); } } /*namespace scm*/ } /*namespace xo*/ /* end DRuntimeError.cpp */