From a26b7811019f97a887bd04fd21e4f2080c3c55fd Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 29 Jan 2026 10:16:13 -0500 Subject: [PATCH] xo-expression2: AGCObject support for DVariable --- CMakeLists.txt | 12 ++++ idl/IGCObject_DVariable.json5 | 15 +++++ include/xo/expression2/DVariable.hpp | 9 +++ .../detail/IGCObject_DVariable.hpp | 67 +++++++++++++++++++ src/expression2/CMakeLists.txt | 1 + src/expression2/DVariable.cpp | 31 +++++++++ src/expression2/IGCObject_DVariable.cpp | 39 +++++++++++ .../expression2_register_facets.cpp | 2 + 8 files changed, 176 insertions(+) create mode 100644 idl/IGCObject_DVariable.json5 create mode 100644 include/xo/expression2/detail/IGCObject_DVariable.hpp create mode 100644 src/expression2/IGCObject_DVariable.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eaff32c..63ff9fad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-variable + FACET_PKG xo_gc + FACET GCObject + REPR Variable + INPUT idl/IGCObject_DVariable.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-variable diff --git a/idl/IGCObject_DVariable.json5 b/idl/IGCObject_DVariable.json5 new file mode 100644 index 00000000..7327507f --- /dev/null +++ b/idl/IGCObject_DVariable.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVariable", + using_doxygen: true, + repr: "DVariable", + doc: [ "implement AGCObject for DVariable" ], +} diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index af2eddd5..3c89cc58 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -21,6 +21,7 @@ namespace xo { class DVariable { public: using ppindentinfo = xo::print::ppindentinfo; + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -56,6 +57,14 @@ namespace xo { TypeDescr valuetype() const noexcept { return typeref_.td(); }; void assign_valuetype(TypeDescr td) noexcept; + ///@} + /** @defgroup scm-variable-gcobject-facet **/ + ///@{ + + size_t shallow_size() const noexcept; + DVariable * shallow_copy(obj mm) const noexcept; + size_t forward_children(obj gc) noexcept; + ///@} /** @defgroup scm-variable-printable-facet **/ ///@{ diff --git a/include/xo/expression2/detail/IGCObject_DVariable.hpp b/include/xo/expression2/detail/IGCObject_DVariable.hpp new file mode 100644 index 00000000..aee612ea --- /dev/null +++ b/include/xo/expression2/detail/IGCObject_DVariable.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DVariable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVariable.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVariable.hpp" + +namespace xo { namespace scm { class IGCObject_DVariable; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVariable + **/ + class IGCObject_DVariable { + public: + /** @defgroup scm-gcobject-dvariable-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-dvariable-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DVariable & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DVariable & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DVariable & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 0aa357b9..03bd8230 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -19,6 +19,7 @@ set(SELF_SRCS IPrintable_DConstant.cpp IExpression_DVariable.cpp + IGCObject_DVariable.cpp IPrintable_DVariable.cpp IExpression_DDefineExpr.cpp diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index af47de00..ac051387 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -5,9 +5,11 @@ #include "DVariable.hpp" #include "exprtype.hpp" +#include #include namespace xo { + using xo::mm::ACollector; using xo::facet::typeseq; namespace scm { @@ -36,6 +38,35 @@ namespace xo { typeref_.resolve(td); } + size_t + DVariable::shallow_size() const noexcept + { + return sizeof(DVariable); + } + + DVariable * + DVariable::shallow_copy(obj mm) const noexcept + { + DVariable * copy = (DVariable *)mm.alloc_copy((std::byte *)this); + + if (copy) { + *copy = *this; + } + + return copy; + } + + size_t + DVariable::forward_children(obj) noexcept + { + // nothing to collect. + // - DUniqueString never in GC space + // - TypeDescr not in GC space + // - path only integers + + return shallow_size(); + } + bool DVariable::pretty(const ppindentinfo & ppii) const { diff --git a/src/expression2/IGCObject_DVariable.cpp b/src/expression2/IGCObject_DVariable.cpp new file mode 100644 index 00000000..8735b286 --- /dev/null +++ b/src/expression2/IGCObject_DVariable.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DVariable.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVariable.json5] +**/ + +#include "detail/IGCObject_DVariable.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVariable::shallow_size(const DVariable & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DVariable::shallow_copy(const DVariable & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DVariable::forward_children(DVariable & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVariable.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 8e10e9a4..a6bd50e5 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -58,6 +59,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl();