From b12555067c67483443e04a763038dd6b7ef871ae Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 23 Jan 2026 15:44:13 -0500 Subject: [PATCH] xo-object2: + DBoolean w/ AGCObject, APrintable facets --- xo-object2/CMakeLists.txt | 36 ++++++++++ xo-object2/idl/IGCObject_DBoolean.json5 | 15 +++++ xo-object2/idl/IPrintable_DBoolean.json5 | 13 ++++ xo-object2/include/xo/object2/DBoolean.hpp | 57 ++++++++++++++++ .../xo/object2/boolean/IGCObject_DBoolean.hpp | 67 +++++++++++++++++++ .../object2/boolean/IPrintable_DBoolean.hpp | 62 +++++++++++++++++ xo-object2/src/object2/CMakeLists.txt | 3 + xo-object2/src/object2/DBoolean.cpp | 57 ++++++++++++++++ xo-object2/src/object2/IGCObject_DBoolean.cpp | 39 +++++++++++ .../src/object2/IPrintable_DBoolean.cpp | 28 ++++++++ .../src/object2/object2_register_facets.cpp | 10 +++ .../src/object2/object2_register_types.cpp | 3 + 12 files changed, 390 insertions(+) create mode 100644 xo-object2/idl/IGCObject_DBoolean.json5 create mode 100644 xo-object2/idl/IPrintable_DBoolean.json5 create mode 100644 xo-object2/include/xo/object2/DBoolean.hpp create mode 100644 xo-object2/include/xo/object2/boolean/IGCObject_DBoolean.hpp create mode 100644 xo-object2/include/xo/object2/boolean/IPrintable_DBoolean.hpp create mode 100644 xo-object2/src/object2/DBoolean.cpp create mode 100644 xo-object2/src/object2/IGCObject_DBoolean.cpp create mode 100644 xo-object2/src/object2/IPrintable_DBoolean.cpp diff --git a/xo-object2/CMakeLists.txt b/xo-object2/CMakeLists.txt index ee93bf7e..261b59df 100644 --- a/xo-object2/CMakeLists.txt +++ b/xo-object2/CMakeLists.txt @@ -28,6 +28,8 @@ xo_add_genfacet( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-list @@ -64,6 +66,34 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-boolean + FACET_PKG xo_printable2 + FACET Printable + REPR Boolean + INPUT idl/IPrintable_DBoolean.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR boolean + OUTPUT_CPP_DIR src/object2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-gcobject-boolean + FACET_PKG xo_gc + FACET GCObject + REPR Boolean + INPUT idl/IGCObject_DBoolean.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR boolean + OUTPUT_CPP_DIR src/object2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-float @@ -88,6 +118,8 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-integer @@ -112,6 +144,8 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-string @@ -136,6 +170,8 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-sequence-array diff --git a/xo-object2/idl/IGCObject_DBoolean.json5 b/xo-object2/idl/IGCObject_DBoolean.json5 new file mode 100644 index 00000000..de3663c4 --- /dev/null +++ b/xo-object2/idl/IGCObject_DBoolean.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DBoolean", + using_doxygen: true, + repr: "DBoolean", + doc: [ "implement AGCObject for DBoolean" ], +} diff --git a/xo-object2/idl/IPrintable_DBoolean.json5 b/xo-object2/idl/IPrintable_DBoolean.json5 new file mode 100644 index 00000000..599a1923 --- /dev/null +++ b/xo-object2/idl/IPrintable_DBoolean.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DBoolean", + using_doxygen: true, + repr: "DBoolean", + doc: [ "implement APrintable for DBoolean" ], +} diff --git a/xo-object2/include/xo/object2/DBoolean.hpp b/xo-object2/include/xo/object2/DBoolean.hpp new file mode 100644 index 00000000..e951cfba --- /dev/null +++ b/xo-object2/include/xo/object2/DBoolean.hpp @@ -0,0 +1,57 @@ +/** @file DBoolean.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include +#include +#include +#include +#include + +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 + static obj box(obj mm, bool x); + + /** allocate boxed value @p x using memory from @p mm **/ + static DBoolean * _box(obj 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 mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + private: + /** boxed boolean value **/ + bool value_; + }; + + template + obj + DBoolean::box(obj mm, bool x) { + return obj(_box(mm, x)); + } + + } /*nmaespace obj*/ +} /*namespace xo*/ + +/* end DBoolean.hpp */ diff --git a/xo-object2/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/xo-object2/include/xo/object2/boolean/IGCObject_DBoolean.hpp new file mode 100644 index 00000000..e075874c --- /dev/null +++ b/xo-object2/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -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 +#include +#include "DBoolean.hpp" + +namespace xo { namespace scm { class IGCObject_DBoolean; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +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 mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DBoolean & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-object2/include/xo/object2/boolean/IPrintable_DBoolean.hpp b/xo-object2/include/xo/object2/boolean/IPrintable_DBoolean.hpp new file mode 100644 index 00000000..e17f169a --- /dev/null +++ b/xo-object2/include/xo/object2/boolean/IPrintable_DBoolean.hpp @@ -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 +#include +#include "DBoolean.hpp" + +namespace xo { namespace scm { class IPrintable_DBoolean; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +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 */ \ No newline at end of file diff --git a/xo-object2/src/object2/CMakeLists.txt b/xo-object2/src/object2/CMakeLists.txt index a87c349b..430e50c2 100644 --- a/xo-object2/src/object2/CMakeLists.txt +++ b/xo-object2/src/object2/CMakeLists.txt @@ -4,6 +4,7 @@ set(SELF_LIB xo_object2) set(SELF_SRCS IGCObject_DArray.cpp IGCObject_DFloat.cpp + IGCObject_DBoolean.cpp IGCObject_DInteger.cpp IGCObject_DList.cpp IGCObject_DString.cpp @@ -11,6 +12,7 @@ set(SELF_SRCS ISequence_DArray.cpp ISequence_DList.cpp IPrintable_DList.cpp + IPrintable_DBoolean.cpp IPrintable_DFloat.cpp IPrintable_DInteger.cpp IPrintable_DString.cpp @@ -18,6 +20,7 @@ set(SELF_SRCS DList.cpp DFloat.cpp DInteger.cpp + DBoolean.cpp DString.cpp init_object2.cpp object2_register_types.cpp diff --git a/xo-object2/src/object2/DBoolean.cpp b/xo-object2/src/object2/DBoolean.cpp new file mode 100644 index 00000000..341e656d --- /dev/null +++ b/xo-object2/src/object2/DBoolean.cpp @@ -0,0 +1,57 @@ +/** @file DBoolean.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DBoolean.hpp" +#include +#include + +namespace xo { + using xo::facet::typeseq; + using xo::print::ppdetail_atomic; + + namespace scm { + DBoolean * + DBoolean::_box(obj mm, bool x) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DBoolean)); + + return new (mem) DBoolean(x); + } + + bool + DBoolean::pretty(const ppindentinfo & ppii) const + { + return ppdetail_atomic::print_pretty(ppii, value_); + } + + size_t + DBoolean::shallow_size() const noexcept + { + return sizeof(DBoolean); + } + + DBoolean * + DBoolean::shallow_copy(obj mm) const noexcept + { + DBoolean * copy = (DBoolean *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + size_t + DBoolean::forward_children(obj) noexcept + { + return shallow_size(); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DBoolean.cpp */ diff --git a/xo-object2/src/object2/IGCObject_DBoolean.cpp b/xo-object2/src/object2/IGCObject_DBoolean.cpp new file mode 100644 index 00000000..72aa0b1b --- /dev/null +++ b/xo-object2/src/object2/IGCObject_DBoolean.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DBoolean.cpp + * + * 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_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DBoolean.json5] +**/ + +#include "boolean/IGCObject_DBoolean.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DBoolean::shallow_size(const DBoolean & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DBoolean::shallow_copy(const DBoolean & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DBoolean::forward_children(DBoolean & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DBoolean.cpp */ \ No newline at end of file diff --git a/xo-object2/src/object2/IPrintable_DBoolean.cpp b/xo-object2/src/object2/IPrintable_DBoolean.cpp new file mode 100644 index 00000000..d8fddd87 --- /dev/null +++ b/xo-object2/src/object2/IPrintable_DBoolean.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DBoolean.cpp + * + * 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_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DBoolean.json5] +**/ + +#include "boolean/IPrintable_DBoolean.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DBoolean::pretty(const DBoolean & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DBoolean.cpp */ \ No newline at end of file diff --git a/xo-object2/src/object2/object2_register_facets.cpp b/xo-object2/src/object2/object2_register_facets.cpp index 93438600..ebf320c4 100644 --- a/xo-object2/src/object2/object2_register_facets.cpp +++ b/xo-object2/src/object2/object2_register_facets.cpp @@ -7,11 +7,13 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -29,9 +31,11 @@ namespace xo { using xo::mm::AAllocator; using xo::mm::AGCObject; using xo::scm::DList; + using xo::scm::DBoolean; using xo::scm::DFloat; using xo::scm::DString; using xo::scm::DArray; + using xo::facet::DVariantPlaceholder; using xo::facet::FacetRegistry; using xo::facet::typeseq; @@ -45,6 +49,9 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -57,7 +64,10 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + log && log(xtag("DVariantPlaceholder.tseq", typeseq::id())); + log && log(xtag("DList.tseq", typeseq::id())); + log && log(xtag("DBoolean.tseq", typeseq::id())); log && log(xtag("DFloat.tseq", typeseq::id())); log && log(xtag("DInteger.tseq", typeseq::id())); log && log(xtag("DString.tseq", typeseq::id())); diff --git a/xo-object2/src/object2/object2_register_types.cpp b/xo-object2/src/object2/object2_register_types.cpp index c2079a40..275995f8 100644 --- a/xo-object2/src/object2/object2_register_types.cpp +++ b/xo-object2/src/object2/object2_register_types.cpp @@ -5,6 +5,7 @@ #include "object2_register_types.hpp" +#include "boolean/IGCObject_DBoolean.hpp" #include "number/IGCObject_DFloat.hpp" #include "number/IGCObject_DInteger.hpp" #include "string/IGCObject_DString.hpp" @@ -33,6 +34,8 @@ namespace xo { bool ok = true; + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for());