xo-object2: tidy IGCObject_DInteger + codegen

This commit is contained in:
Roland Conybeare 2026-01-15 00:58:55 -05:00
commit 5e6db993ee
10 changed files with 152 additions and 77 deletions

View file

@ -5,6 +5,7 @@
#pragma once
#include <xo/gc/Collector.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/indentlog/print/ppindentinfo.hpp>
#include <xo/facet/obj.hpp>
@ -14,6 +15,7 @@ namespace xo {
namespace scm {
struct DInteger {
using AAllocator = xo::mm::AAllocator;
using ACollector = xo::mm::ACollector;
using ppindentinfo = xo::print::ppindentinfo;
using value_type = long;
@ -32,6 +34,12 @@ namespace xo {
operator long() const noexcept { return value_; }
// GCObject facet
std::size_t shallow_size() const noexcept;
DInteger * shallow_copy(obj<AAllocator> mm) const noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
private:
/** boxed integer value **/
long value_;

View file

@ -1,45 +0,0 @@
/** @file IGCObject_DInteger.hpp
*
* @author Roland Conybeare, Dec 2025
**/
#pragma once
#include <xo/gc/Collector.hpp>
#include "xo/alloc2/alloc/AAllocator.hpp"
#include <xo/gc/detail/AGCObject.hpp>
#include <xo/gc/detail/IGCObject_Xfer.hpp>
#include "DInteger.hpp"
namespace xo {
namespace scm { struct IGCObject_DInteger; }
namespace facet {
template <>
struct FacetImplementation<xo::mm::AGCObject,
xo::scm::DInteger>
{
using ImplType = xo::mm::IGCObject_Xfer
<xo::scm::DInteger,
xo::scm::IGCObject_DInteger>;
};
}
namespace scm {
/* changes here coordinate with:
* IGCObject_Xfer
*/
struct IGCObject_DInteger {
public:
using AAllocator = xo::mm::AAllocator;
using ACollector = xo::mm::ACollector;
using size_type = std::size_t;
static size_type shallow_size(const DInteger & d) noexcept;
static DInteger * shallow_copy(const DInteger & d, obj<AAllocator> mm) noexcept;
static size_type forward_children(DInteger & d, obj<ACollector> gc) noexcept;
};
} /*namespace scm*/
} /*namespace xo*/
/* end IGCObject_DInteger.hpp */

View file

@ -0,0 +1,67 @@
/** @file IGCObject_DInteger.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IGCObject_DInteger.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DInteger.json5]
**/
#pragma once
#include "GCObject.hpp"
#include <xo/gc/GCObject.hpp>
#include <xo/alloc2/Allocator.hpp>
#include "DInteger.hpp"
namespace xo { namespace scm { class IGCObject_DInteger; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::mm::AGCObject,
xo::scm::DInteger>
{
using ImplType = xo::mm::IGCObject_Xfer
<xo::scm::DInteger,
xo::scm::IGCObject_DInteger>;
};
}
}
namespace xo {
namespace scm {
/** @class IGCObject_DInteger
**/
class IGCObject_DInteger {
public:
/** @defgroup scm-gcobject-dinteger-type-traits **/
///@{
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
/** @defgroup scm-gcobject-dinteger-methods **/
///@{
// const methods
/** memory consumption for this instance **/
static size_type shallow_size(const DInteger & self) noexcept;
/** copy instance using allocator **/
static Opaque shallow_copy(const DInteger & self, obj<AAllocator> mm) noexcept;
// non-const methods
/** during GC: forward immdiate children **/
static size_type forward_children(DInteger & self, obj<ACollector> gc) noexcept;
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */