xo-object2: + DBoolean w/ AGCObject, APrintable facets
This commit is contained in:
parent
fde4199422
commit
b456d7ac85
12 changed files with 390 additions and 0 deletions
57
include/xo/object2/DBoolean.hpp
Normal file
57
include/xo/object2/DBoolean.hpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/** @file DBoolean.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <xo/gc/Collector.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/indentlog/print/ppindentinfo.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <cstdint>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
struct DBoolean {
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
using value_type = long;
|
||||
|
||||
explicit DBoolean(bool x) : value_{x} {}
|
||||
|
||||
/** will likely want this to default to ANumeric, once we have it **/
|
||||
template <typename AFacet>
|
||||
static obj<AFacet, DBoolean> box(obj<AAllocator> mm, bool x);
|
||||
|
||||
/** allocate boxed value @p x using memory from @p mm **/
|
||||
static DBoolean * _box(obj<AAllocator> mm, bool x);
|
||||
|
||||
bool value() const noexcept { return value_; }
|
||||
|
||||
bool pretty(const ppindentinfo & ppii) const;
|
||||
|
||||
operator bool() const noexcept { return value_; }
|
||||
|
||||
// GCObject facet
|
||||
|
||||
std::size_t shallow_size() const noexcept;
|
||||
DBoolean * shallow_copy(obj<AAllocator> mm) const noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
|
||||
private:
|
||||
/** boxed boolean value **/
|
||||
bool value_;
|
||||
};
|
||||
|
||||
template <typename AFacet>
|
||||
obj<AFacet, DBoolean>
|
||||
DBoolean::box(obj<AAllocator> mm, bool x) {
|
||||
return obj<AFacet,DBoolean>(_box(mm, x));
|
||||
}
|
||||
|
||||
} /*nmaespace obj*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DBoolean.hpp */
|
||||
67
include/xo/object2/boolean/IGCObject_DBoolean.hpp
Normal file
67
include/xo/object2/boolean/IGCObject_DBoolean.hpp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/** @file IGCObject_DBoolean.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IGCObject_DBoolean.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IGCObject_DBoolean.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GCObject.hpp"
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include "DBoolean.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IGCObject_DBoolean; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::mm::AGCObject,
|
||||
xo::scm::DBoolean>
|
||||
{
|
||||
using ImplType = xo::mm::IGCObject_Xfer
|
||||
<xo::scm::DBoolean,
|
||||
xo::scm::IGCObject_DBoolean>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IGCObject_DBoolean
|
||||
**/
|
||||
class IGCObject_DBoolean {
|
||||
public:
|
||||
/** @defgroup scm-gcobject-dboolean-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-dboolean-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** memory consumption for this instance **/
|
||||
static size_type shallow_size(const DBoolean & self) noexcept;
|
||||
/** copy instance using allocator **/
|
||||
static Opaque shallow_copy(const DBoolean & self, obj<AAllocator> mm) noexcept;
|
||||
|
||||
// non-const methods
|
||||
/** during GC: forward immdiate children **/
|
||||
static size_type forward_children(DBoolean & self, obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
62
include/xo/object2/boolean/IPrintable_DBoolean.hpp
Normal file
62
include/xo/object2/boolean/IPrintable_DBoolean.hpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/** @file IPrintable_DBoolean.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DBoolean.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DBoolean.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Printable.hpp"
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
|
||||
#include "DBoolean.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IPrintable_DBoolean; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::print::APrintable,
|
||||
xo::scm::DBoolean>
|
||||
{
|
||||
using ImplType = xo::print::IPrintable_Xfer
|
||||
<xo::scm::DBoolean,
|
||||
xo::scm::IPrintable_DBoolean>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IPrintable_DBoolean
|
||||
**/
|
||||
class IPrintable_DBoolean {
|
||||
public:
|
||||
/** @defgroup scm-printable-dboolean-type-traits **/
|
||||
///@{
|
||||
using ppindentinfo = xo::print::APrintable::ppindentinfo;
|
||||
using Copaque = xo::print::APrintable::Copaque;
|
||||
using Opaque = xo::print::APrintable::Opaque;
|
||||
///@}
|
||||
/** @defgroup scm-printable-dboolean-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** Pretty-printing support for this object.
|
||||
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
|
||||
static bool pretty(const DBoolean & self, const ppindentinfo & ppii);
|
||||
|
||||
// non-const methods
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
Loading…
Add table
Add a link
Reference in a new issue