From e625a362a68d7ba96f155d759210b3692c60a89f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 00:05:48 -0500 Subject: [PATCH] xo-facet xo-object2 : tidy: ISequence_DList -> list/ subdir --- xo-facet/codegen/genfacet | 3 +-- xo-facet/codegen/iface_facet_repr.cpp.j2 | 2 +- xo-facet/codegen/iface_facet_repr.hpp.j2 | 3 ++- xo-object2/CMakeLists.txt | 2 +- xo-object2/idl/ISequence_DList.json5 | 1 + xo-object2/idl/Sequence.json5 | 4 ++++ xo-object2/include/xo/object2/Sequence.hpp | 7 +++--- .../xo/object2/{ => list}/ISequence_DList.hpp | 12 ++++++---- .../include/xo/object2/sequence/ASequence.hpp | 18 +++++++++------ .../xo/object2/sequence/ISequence_Any.hpp | 18 +++++++-------- .../xo/object2/sequence/ISequence_Xfer.hpp | 19 +++++++++------- .../include/xo/object2/sequence/RSequence.hpp | 22 ++++++++++--------- xo-object2/src/object2/ISequence_Any.cpp | 5 ++++- xo-object2/src/object2/ISequence_DList.cpp | 5 ++--- xo-printable2/idl/Printable.json5 | 3 ++- 15 files changed, 73 insertions(+), 51 deletions(-) rename xo-object2/include/xo/object2/{ => list}/ISequence_DList.hpp (80%) diff --git a/xo-facet/codegen/genfacet b/xo-facet/codegen/genfacet index 4d4f3fe5..ddea77e6 100755 --- a/xo-facet/codegen/genfacet +++ b/xo-facet/codegen/genfacet @@ -504,7 +504,6 @@ def main(): idl_fname=idl_fname, idl=idl, output_hpp_dir=output_hpp_dir, - #output_impl_hpp_dir=output_impl_hpp_dir, output_cpp_dir=output_cpp_dir) elif idl['mode'] == 'implementation': # idl: json5 for (iface, data) combination @@ -517,7 +516,7 @@ def main(): idl_fname=idl_fname, idl=idl, facet_idl=facet_idl, - output_hpp_dir=output_hpp_dir, + output_hpp_dir=output_impl_hpp_dir, output_impl_hpp_subdir=output_impl_hpp_subdir, output_cpp_dir=output_cpp_dir) diff --git a/xo-facet/codegen/iface_facet_repr.cpp.j2 b/xo-facet/codegen/iface_facet_repr.cpp.j2 index 52499295..4815d047 100644 --- a/xo-facet/codegen/iface_facet_repr.cpp.j2 +++ b/xo-facet/codegen/iface_facet_repr.cpp.j2 @@ -11,7 +11,7 @@ * [{{ idl_fname }}] **/ -#include "{{iface_facet_repr_hpp_fname}}" +#include "{{impl_hpp_subdir}}/{{iface_facet_repr_hpp_fname}}" namespace {{repr_ns1}} { namespace {{repr_ns2}} { diff --git a/xo-facet/codegen/iface_facet_repr.hpp.j2 b/xo-facet/codegen/iface_facet_repr.hpp.j2 index 221d6799..f97ff84f 100644 --- a/xo-facet/codegen/iface_facet_repr.hpp.j2 +++ b/xo-facet/codegen/iface_facet_repr.hpp.j2 @@ -6,13 +6,14 @@ * arguments: * --input [{{genfacet_input}}] * 2. jinja2 template for abstract facet .hpp file: - * [{{ iface_facet_any_hpp_j2 }}] + * [{{ iface_facet_repr_hpp_j2 }}] * 3. idl for facet methods * [{{ idl_fname }}] **/ #pragma once +#include "{{facet_hpp_fname}}" {% for include_fname in facet_includes %} #include {{include_fname}} {% endfor %} diff --git a/xo-object2/CMakeLists.txt b/xo-object2/CMakeLists.txt index 19a59363..b0141c62 100644 --- a/xo-object2/CMakeLists.txt +++ b/xo-object2/CMakeLists.txt @@ -36,7 +36,7 @@ xo_add_genfacetimpl( REPR List INPUT idl/ISequence_DList.json5 OUTPUT_HPP_DIR include/xo/object2 - OUTPUT_IMPL_SUBDIR sequence + OUTPUT_IMPL_SUBDIR list OUTPUT_CPP_DIR src/object2 ) diff --git a/xo-object2/idl/ISequence_DList.json5 b/xo-object2/idl/ISequence_DList.json5 index 999fb482..8edbd16a 100644 --- a/xo-object2/idl/ISequence_DList.json5 +++ b/xo-object2/idl/ISequence_DList.json5 @@ -1,6 +1,7 @@ { mode: "implementation", includes: [ "" ], + local_types: [ ], namespace1: "xo", namespace2: "scm", facet_idl: "idl/Sequence.json5", diff --git a/xo-object2/idl/Sequence.json5 b/xo-object2/idl/Sequence.json5 index 2ee1a204..9ceda9ea 100644 --- a/xo-object2/idl/Sequence.json5 +++ b/xo-object2/idl/Sequence.json5 @@ -1,8 +1,12 @@ { mode: "facet", includes: [""], + // extra includes in Sequence.hpp, if any + user_hpp_includes: [], namespace1: "xo", namespace2: "scm", + // text after includes, before ASequence + pretext: [ "// {pretext} here" ], facet: "Sequence", detail_subdir: "sequence", brief: "an ordered collection of variants", diff --git a/xo-object2/include/xo/object2/Sequence.hpp b/xo-object2/include/xo/object2/Sequence.hpp index 22f67397..fc934084 100644 --- a/xo-object2/include/xo/object2/Sequence.hpp +++ b/xo-object2/include/xo/object2/Sequence.hpp @@ -2,13 +2,13 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: - * --input [./idl/Sequence.json5] + * --input [idl/Sequence.json5] * 2. jinja2 template for facet .hpp file: * [facet.hpp.j2] * 3. idl for facet methods - * [./idl/Sequence.json5] + * [idl/Sequence.json5] **/ #pragma once @@ -18,4 +18,5 @@ #include "sequence/ISequence_Xfer.hpp" #include "sequence/RSequence.hpp" + /* end Sequence.hpp */ \ No newline at end of file diff --git a/xo-object2/include/xo/object2/ISequence_DList.hpp b/xo-object2/include/xo/object2/list/ISequence_DList.hpp similarity index 80% rename from xo-object2/include/xo/object2/ISequence_DList.hpp rename to xo-object2/include/xo/object2/list/ISequence_DList.hpp index 5f67a3ff..81289db9 100644 --- a/xo-object2/include/xo/object2/ISequence_DList.hpp +++ b/xo-object2/include/xo/object2/list/ISequence_DList.hpp @@ -6,7 +6,7 @@ * arguments: * --input [idl/ISequence_DList.json5] * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] + * [iface_facet_repr.hpp.j2] * 3. idl for facet methods * [idl/ISequence_DList.json5] **/ @@ -14,7 +14,7 @@ #pragma once #include "Sequence.hpp" -#include "sequence/ISequence_Xfer.hpp" +#include #include "DList.hpp" namespace xo { namespace scm { class ISequence_DList; } } @@ -40,11 +40,14 @@ namespace xo { public: /** @defgroup scm-sequence-dlist-type-traits **/ ///@{ - using size_type = ASequence::size_type; - using AGCObject = ASequence::AGCObject; + using size_type = xo::scm::ASequence::size_type; + using AGCObject = xo::scm::ASequence::AGCObject; + using Copaque = xo::scm::ASequence::Copaque; + using Opaque = xo::scm::ASequence::Opaque; ///@} /** @defgroup scm-sequence-dlist-methods **/ ///@{ + // const methods /** true iff sequence is empty **/ static bool is_empty(const DList & self) noexcept; /** true iff sequence is finite **/ @@ -52,6 +55,7 @@ namespace xo { /** return element @p index of this sequence **/ static obj at(const DList & self, size_type index); + // non-const methods ///@} }; diff --git a/xo-object2/include/xo/object2/sequence/ASequence.hpp b/xo-object2/include/xo/object2/sequence/ASequence.hpp index 301d5be8..99687473 100644 --- a/xo-object2/include/xo/object2/sequence/ASequence.hpp +++ b/xo-object2/include/xo/object2/sequence/ASequence.hpp @@ -2,13 +2,13 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: - * --input [./idl/Sequence.json5] + * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: * [abstract_facet.hpp.j2] * 3. idl for facet methods - * [./idl/Sequence.json5] + * [idl/Sequence.json5] **/ #pragma once @@ -19,6 +19,8 @@ #include #include +// {pretext} here + namespace xo { namespace scm { @@ -36,6 +38,8 @@ public: // types /** integer identifying a type **/ using typeseq = xo::facet::typeseq; + using Copaque = const void *; + using Opaque = void *; /** type for length of a sequence **/ using size_type = std::size_t; /** facet for types with GC support **/ @@ -48,11 +52,11 @@ public: /** RTTI: unique id# for actual runtime data representation **/ virtual typeseq _typeseq() const noexcept = 0; /** true iff sequence is empty **/ - virtual bool is_empty(Copaque data) const noexcept = 0; + virtual bool is_empty(Copaque data) const noexcept = 0; /** true iff sequence is finite **/ - virtual bool is_finite(Copaque data) const noexcept = 0; + virtual bool is_finite(Copaque data) const noexcept = 0; /** return element @p index of this sequence **/ - virtual obj at(Copaque data, size_type index) const = 0; + virtual obj at(Copaque data, size_type index) const = 0; // nonconst methods ///@} @@ -74,4 +78,4 @@ using ISequence_ImplType = xo::facet::FacetImplType; } /*namespace scm*/ } /*namespace xo*/ -/* */ +/* ASequence.hpp */ \ No newline at end of file diff --git a/xo-object2/include/xo/object2/sequence/ISequence_Any.hpp b/xo-object2/include/xo/object2/sequence/ISequence_Any.hpp index dc9d73fc..9f5901f2 100644 --- a/xo-object2/include/xo/object2/sequence/ISequence_Any.hpp +++ b/xo-object2/include/xo/object2/sequence/ISequence_Any.hpp @@ -2,19 +2,18 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: - * --input [./idl/Sequence.json5] + * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: * [iface_facet_any.hpp.j2] * 3. idl for facet methods - * [./idl/Sequence.json5] + * [idl/Sequence.json5] **/ #pragma once #include "ASequence.hpp" -#include #include namespace xo { namespace scm { class ISequence_Any; } } @@ -43,6 +42,7 @@ namespace scm { /** @defgroup scm-sequence-any-type-traits **/ ///@{ + /** integer identifying a type **/ using typeseq = xo::facet::typeseq; using size_type = ASequence::size_type; using AGCObject = ASequence::AGCObject; @@ -57,16 +57,16 @@ namespace scm { // const methods typeseq _typeseq() const noexcept override { return s_typeseq; } - [[noreturn]] bool is_empty(Copaque) const noexcept override { _fatal(); } - [[noreturn]] bool is_finite(Copaque) const noexcept override { _fatal(); } - [[noreturn]] obj at(Copaque, size_type) const override { _fatal(); } + [[noreturn]] bool is_empty(Copaque) const noexcept override { _fatal(); } + [[noreturn]] bool is_finite(Copaque) const noexcept override { _fatal(); } + [[noreturn]] obj at(Copaque, size_type) const override { _fatal(); } // nonconst methods ///@} private: - /** @defgroup scm-sequence-any-private-methods **/ + /** @defgraoup scm-sequence-any-private-methods **/ ///@{ [[noreturn]] static void _fatal(); @@ -86,4 +86,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo */ -/* ISequence_Any.hpp */ +/* ISequence_Any.hpp */ \ No newline at end of file diff --git a/xo-object2/include/xo/object2/sequence/ISequence_Xfer.hpp b/xo-object2/include/xo/object2/sequence/ISequence_Xfer.hpp index 3bcad3d8..60abc5aa 100644 --- a/xo-object2/include/xo/object2/sequence/ISequence_Xfer.hpp +++ b/xo-object2/include/xo/object2/sequence/ISequence_Xfer.hpp @@ -2,18 +2,18 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: - * --input [./idl/Sequence.json5] + * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: * [iface_facet_any.hpp.j2] * 3. idl for facet methods - * [./idl/Sequence.json5] + * [idl/Sequence.json5] **/ #pragma once -#include "ASequence.hpp" +#include namespace xo { namespace scm { @@ -24,7 +24,10 @@ namespace scm { public: /** @defgroup scm-sequence-xfer-type-traits **/ ///@{ + /** actual implementation (not generated; often delegates to DRepr) **/ using Impl = ISequence_DRepr; + /** integer identifying a type **/ + using typeseq = ASequence::typeseq; using size_type = ASequence::size_type; using AGCObject = ASequence::AGCObject; ///@} @@ -39,13 +42,13 @@ namespace scm { // const methods typeseq _typeseq() const noexcept override { return s_typeseq; } - bool is_empty(Copaque data) const noexcept override { + bool is_empty(Copaque data) const noexcept override { return I::is_empty(_dcast(data)); } - bool is_finite(Copaque data) const noexcept override { + bool is_finite(Copaque data) const noexcept override { return I::is_finite(_dcast(data)); } - obj at(Copaque data, size_type index) const override { + obj at(Copaque data, size_type index) const override { return I::at(_dcast(data), index); } @@ -82,4 +85,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo*/ -/* end ISequence_Xfer.hpp */ +/* end ISequence_Xfer.hpp */ \ No newline at end of file diff --git a/xo-object2/include/xo/object2/sequence/RSequence.hpp b/xo-object2/include/xo/object2/sequence/RSequence.hpp index a63ca8a0..26ec1735 100644 --- a/xo-object2/include/xo/object2/sequence/RSequence.hpp +++ b/xo-object2/include/xo/object2/sequence/RSequence.hpp @@ -2,13 +2,13 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-object2/../xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: - * --input [./idl/Sequence.json5] + * --input [idl/Sequence.json5] * 2. jinja2 template for abstract facet .hpp file: * [iface_facet_any.hpp.j2] * 3. idl for facet methods - * [./idl/Sequence.json5] + * [idl/Sequence.json5] **/ #pragma once @@ -30,6 +30,7 @@ public: ///@{ using ObjectType = Object; using DataPtr = Object::DataPtr; + using typeseq = xo::reflect::typeseq; using size_type = ASequence::size_type; using AGCObject = ASequence::AGCObject; ///@} @@ -38,26 +39,27 @@ public: ///@{ RSequence() {} RSequence(Object::DataPtr data) : Object{std::move(data)} {} + RSequence(const ASequence * iface, void * data) + requires std::is_same_v + : Object(iface, data) {} ///@} /** @defgroup scm-sequence-router-methods **/ ///@{ // const methods - int32_t _typeseq() const noexcept { return O::iface()->_typeseq(); } - bool is_empty() const noexcept override { + typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + bool is_empty() const noexcept { return O::iface()->is_empty(O::data()); } - bool is_finite() const noexcept override { + bool is_finite() const noexcept { return O::iface()->is_finite(O::data()); } - obj at(size_type index) const override { + obj at(size_type index) const { return O::iface()->at(O::data(), index); } - // non-const methods - // << do something for non-const methods >> - // + // non-const methods (still const in router!) ///@} /** @defgroup scm-sequence-member-vars **/ diff --git a/xo-object2/src/object2/ISequence_Any.cpp b/xo-object2/src/object2/ISequence_Any.cpp index a7781e97..8461d750 100644 --- a/xo-object2/src/object2/ISequence_Any.cpp +++ b/xo-object2/src/object2/ISequence_Any.cpp @@ -32,7 +32,10 @@ bool ISequence_Any::_valid = valid_facet_implementation(); +// nonconst methods + + } /*namespace scm*/ } /*namespace xo*/ -/* end ISequence_Any.cpp */ +/* end ISequence_Any.cpp */ \ No newline at end of file diff --git a/xo-object2/src/object2/ISequence_DList.cpp b/xo-object2/src/object2/ISequence_DList.cpp index 71dcf744..b216b7e5 100644 --- a/xo-object2/src/object2/ISequence_DList.cpp +++ b/xo-object2/src/object2/ISequence_DList.cpp @@ -11,8 +11,7 @@ * [idl/ISequence_DList.json5] **/ -#include "IGCObject_DList.hpp" // apparently need this with clang 15 -#include "ISequence_DList.hpp" +#include "list/ISequence_DList.hpp" namespace xo { namespace scm { @@ -38,4 +37,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end ISequence_DList.cpp */ +/* end ISequence_DList.cpp */ \ No newline at end of file diff --git a/xo-printable2/idl/Printable.json5 b/xo-printable2/idl/Printable.json5 index 1cf52da6..ada9d4ca 100644 --- a/xo-printable2/idl/Printable.json5 +++ b/xo-printable2/idl/Printable.json5 @@ -5,7 +5,8 @@ user_hpp_includes: ["\"detail/ppdetail_Printable.hpp\""], namespace1: "xo", namespace2: "print", - pretext: [], + // text after includes, before APrintable + pretext: [ "// {pretext} here" ], facet: "Printable", detail_subdir: "detail", brief: "pretty-printable objects",