diff --git a/CMakeLists.txt b/CMakeLists.txt index 19a5936..b0141c6 100644 --- a/CMakeLists.txt +++ b/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/idl/ISequence_DList.json5 b/idl/ISequence_DList.json5 index 999fb48..8edbd16 100644 --- a/idl/ISequence_DList.json5 +++ b/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/idl/Sequence.json5 b/idl/Sequence.json5 index 2ee1a20..9ceda9e 100644 --- a/idl/Sequence.json5 +++ b/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/include/xo/object2/Sequence.hpp b/include/xo/object2/Sequence.hpp index 22f6739..fc93408 100644 --- a/include/xo/object2/Sequence.hpp +++ b/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/include/xo/object2/ISequence_DList.hpp b/include/xo/object2/list/ISequence_DList.hpp similarity index 80% rename from include/xo/object2/ISequence_DList.hpp rename to include/xo/object2/list/ISequence_DList.hpp index 5f67a3f..81289db 100644 --- a/include/xo/object2/ISequence_DList.hpp +++ b/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/include/xo/object2/sequence/ASequence.hpp b/include/xo/object2/sequence/ASequence.hpp index 301d5be..9968747 100644 --- a/include/xo/object2/sequence/ASequence.hpp +++ b/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/include/xo/object2/sequence/ISequence_Any.hpp b/include/xo/object2/sequence/ISequence_Any.hpp index dc9d73f..9f5901f 100644 --- a/include/xo/object2/sequence/ISequence_Any.hpp +++ b/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/include/xo/object2/sequence/ISequence_Xfer.hpp b/include/xo/object2/sequence/ISequence_Xfer.hpp index 3bcad3d..60abc5a 100644 --- a/include/xo/object2/sequence/ISequence_Xfer.hpp +++ b/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/include/xo/object2/sequence/RSequence.hpp b/include/xo/object2/sequence/RSequence.hpp index a63ca8a..26ec173 100644 --- a/include/xo/object2/sequence/RSequence.hpp +++ b/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/src/object2/ISequence_Any.cpp b/src/object2/ISequence_Any.cpp index a7781e9..8461d75 100644 --- a/src/object2/ISequence_Any.cpp +++ b/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/src/object2/ISequence_DList.cpp b/src/object2/ISequence_DList.cpp index 71dcf74..b216b7e 100644 --- a/src/object2/ISequence_DList.cpp +++ b/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