diff --git a/xo-object2/CMakeLists.txt b/xo-object2/CMakeLists.txt index 53046556..ff21115c 100644 --- a/xo-object2/CMakeLists.txt +++ b/xo-object2/CMakeLists.txt @@ -76,6 +76,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-gcobject-float + FACET_PKG xo_gc + FACET GCObject + REPR Float + INPUT idl/IGCObject_DFloat.json5 + OUTPUT_HPP_DIR include/xo/object2 + OUTPUT_IMPL_SUBDIR number + OUTPUT_CPP_DIR src/object2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-string diff --git a/xo-object2/idl/IGCObject_DFloat.json5 b/xo-object2/idl/IGCObject_DFloat.json5 new file mode 100644 index 00000000..6120808b --- /dev/null +++ b/xo-object2/idl/IGCObject_DFloat.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DFloat", + using_doxygen: true, + repr: "DFloat", + doc: [ "implement AGCObject for DFloat" ], +} diff --git a/xo-object2/include/xo/object2/DFloat.hpp b/xo-object2/include/xo/object2/DFloat.hpp index ab38d078..a46a990d 100644 --- a/xo-object2/include/xo/object2/DFloat.hpp +++ b/xo-object2/include/xo/object2/DFloat.hpp @@ -6,6 +6,7 @@ #pragma once #include +#include #include #include @@ -13,6 +14,7 @@ namespace xo { namespace scm { struct DFloat { using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; using ppindentinfo = xo::print::ppindentinfo; using value_type = double; @@ -27,9 +29,14 @@ namespace xo { double value() const noexcept { return value_; } + operator double() const noexcept { return value_; } + bool pretty(const ppindentinfo & ppii) const; - operator double() const noexcept { return value_; } + // GCObject facet + std::size_t shallow_size() const noexcept; + DFloat * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; private: diff --git a/xo-object2/include/xo/object2/IGCObject_DFloat.hpp b/xo-object2/include/xo/object2/IGCObject_DFloat.hpp deleted file mode 100644 index 58b931bc..00000000 --- a/xo-object2/include/xo/object2/IGCObject_DFloat.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/** @file IGCObject_DFloat.hpp - * - * @author Roland Conybeare, Dec 2025 - **/ - -#pragma once - -#include -#include -#include -#include -#include "DFloat.hpp" - -namespace xo { - namespace scm { struct IGCObject_DFloat; } - - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::mm::IGCObject_Xfer - ; - }; - } - - namespace scm { - /* changes here coordinate with: - * IGCObject_Xfer - */ - struct IGCObject_DFloat { - public: - using AAllocator = xo::mm::AAllocator; - using ACollector = xo::mm::ACollector; - using size_type = std::size_t; - - static size_type shallow_size(const DFloat & d) noexcept; - static DFloat * shallow_copy(const DFloat & d, obj mm) noexcept; - static size_type forward_children(DFloat & d, obj gc) noexcept; - }; - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IGCObject_DFloat.hpp */ diff --git a/xo-object2/include/xo/object2/number/IGCObject_DFloat.hpp b/xo-object2/include/xo/object2/number/IGCObject_DFloat.hpp new file mode 100644 index 00000000..c57c89ea --- /dev/null +++ b/xo-object2/include/xo/object2/number/IGCObject_DFloat.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DFloat.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DFloat.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DFloat.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DFloat.hpp" + +namespace xo { namespace scm { class IGCObject_DFloat; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DFloat + **/ + class IGCObject_DFloat { + public: + /** @defgroup scm-gcobject-dfloat-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-dfloat-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DFloat & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DFloat & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DFloat & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-object2/src/object2/DFloat.cpp b/xo-object2/src/object2/DFloat.cpp index 52940efe..7fc0bfbf 100644 --- a/xo-object2/src/object2/DFloat.cpp +++ b/xo-object2/src/object2/DFloat.cpp @@ -9,6 +9,7 @@ namespace xo { using xo::facet::typeseq; using xo::print::ppdetail_atomic; + using std::size_t; namespace scm { DFloat * @@ -25,6 +26,30 @@ namespace xo { { return ppdetail_atomic::print_pretty(ppii, value_); } + + size_t + DFloat::shallow_size() const noexcept + { + return sizeof(DFloat); + } + + DFloat * + DFloat::shallow_copy(obj mm) const noexcept + { + DFloat * copy = (DFloat *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + size_t + DFloat::forward_children(obj) noexcept + { + return shallow_size(); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/xo-object2/src/object2/IGCObject_DFloat.cpp b/xo-object2/src/object2/IGCObject_DFloat.cpp index be4849ac..ef4214a7 100644 --- a/xo-object2/src/object2/IGCObject_DFloat.cpp +++ b/xo-object2/src/object2/IGCObject_DFloat.cpp @@ -1,46 +1,39 @@ /** @file IGCObject_DFloat.cpp * - * @author Roland Conybeare, Dec 2025 - **/ + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DFloat.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DFloat.json5] +**/ -#include "IGCObject_DFloat.hpp" -#include "xo/alloc2/alloc/AAllocator.hpp" -#include "xo/facet/obj.hpp" -#include +#include "number/IGCObject_DFloat.hpp" namespace xo { - using xo::mm::AAllocator; - using xo::facet::obj; - using xo::facet::typeseq; - using std::size_t; - namespace scm { - size_t - IGCObject_DFloat::shallow_size(const DFloat &) noexcept + auto + IGCObject_DFloat::shallow_size(const DFloat & self) noexcept -> size_type { - return sizeof(DFloat); + return self.shallow_size(); } - DFloat * - IGCObject_DFloat::shallow_copy(const DFloat & src, - obj mm) noexcept + auto + IGCObject_DFloat::shallow_copy(const DFloat & self, obj mm) noexcept -> Opaque { - DFloat * copy = (DFloat *)mm.alloc_copy((std::byte *)&src); - - if (copy) - *copy = src; - - return copy; + return self.shallow_copy(mm); } - size_t - IGCObject_DFloat::forward_children(DFloat & src, - obj) noexcept + auto + IGCObject_DFloat::forward_children(DFloat & self, obj gc) noexcept -> size_type { - return shallow_size(src); + return self.forward_children(gc); } } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DFloat.cpp */ +/* end IGCObject_DFloat.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 b9a8d3ac..efbb2a08 100644 --- a/xo-object2/src/object2/object2_register_facets.cpp +++ b/xo-object2/src/object2/object2_register_facets.cpp @@ -6,7 +6,7 @@ #include "object2_register_facets.hpp" #include -#include +#include #include #include diff --git a/xo-object2/src/object2/object2_register_types.cpp b/xo-object2/src/object2/object2_register_types.cpp index a7e95da2..9c6a9196 100644 --- a/xo-object2/src/object2/object2_register_types.cpp +++ b/xo-object2/src/object2/object2_register_types.cpp @@ -6,7 +6,7 @@ #include "object2_register_types.hpp" #include "list/IGCObject_DList.hpp" -#include "IGCObject_DFloat.hpp" +#include "number/IGCObject_DFloat.hpp" #include "IGCObject_DInteger.hpp" #include "string/IGCObject_DString.hpp" diff --git a/xo-object2/utest/X1Collector.test.cpp b/xo-object2/utest/X1Collector.test.cpp index f100f38e..330db905 100644 --- a/xo-object2/utest/X1Collector.test.cpp +++ b/xo-object2/utest/X1Collector.test.cpp @@ -8,7 +8,7 @@ #include "DList.hpp" #include "object2_register_types.hpp" -#include "IGCObject_DFloat.hpp" +#include "number/IGCObject_DFloat.hpp" #include "list/IGCObject_DList.hpp" #include