xo-object2: Printable+DList [WIP]

This commit is contained in:
Roland Conybeare 2026-01-05 17:10:22 -05:00
commit 287fce9b7b
9 changed files with 142 additions and 11 deletions

View file

@ -92,7 +92,7 @@ namespace xo {
//static_assert(false && "expect specialization <AFacet,DRepr> which should provide ImplType trait");
};
/** Retrieve facet implementation for a (facet, datatype) pair **/
/** Retrieve facet implementation for a (facet, datatype) pair **/
template <typename AFacet, typename DRepr>
using FacetImplType = FacetImplementation<AFacet, DRepr>::ImplType;
@ -123,11 +123,6 @@ namespace xo {
* = valid_facet_implementation<AMyFacet, IMyFacet_Any>();
**/
struct DVariantPlaceholder {};
/** PLAN:
* expect also will need runtime version of FacetImplementation.
**/
} /*namespace facet*/
} /*namespace xo*/

View file

@ -27,6 +27,7 @@ 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
FACET_PKG xo_object2
@ -38,13 +39,10 @@ xo_add_genfacetimpl(
OUTPUT_CPP_DIR src/object2
)
#get_target_property(xo_printable2_dir share_xo_printable2 path)
#message(STATUS "xo_printable2_dir=${xo_printable2_dir}")
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-object2-facetimpl-printable-float
FACET_PKG xo_printable2
# FACET_DIR ${xo_printable2_dir}
FACET Printable
REPR Float
INPUT idl/IPrintable_DFloat.json5
@ -53,6 +51,18 @@ xo_add_genfacetimpl(
OUTPUT_CPP_DIR src/object2
)
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-object2-facetimpl-printable-list
FACET_PKG xo_printable2
FACET Printable
REPR List
INPUT idl/IPrintable_DList.json5
OUTPUT_HPP_DIR include/xo/object2
OUTPUT_IMPL_SUBDIR .
OUTPUT_CPP_DIR src/object2
)
# ----------------------------------------------------------------
# must complete definition of expression lib before configuring examples

View file

@ -8,5 +8,5 @@
brief: "provide APrintable interface for DFloat",
using_doxygen: true,
repr: "DFloat",
doc: [ "doc for something or other" ],
doc: [ "implement APrintable for DFloat" ],
}

View file

@ -0,0 +1,12 @@
{
mode: "implementation",
includes: [ "<xo/printable2/Printable.hpp>",
"<xo/printable2/detail/IPrintable_Xfer.hpp>" ],
namespace1: "xo",
namespace2: "scm",
facet_idl: "idl/Printable.json5",
brief: "provide APrintable interface for DList",
using_doxygen: true,
repr: "DList",
doc: [ "implement APrintable for DList" ],
}

View file

@ -40,6 +40,9 @@ namespace xo {
/** return element at 0-based index @p ix **/
obj<AGCObject> at(size_type ix) const;
/** pretty-printing driver; combine layout+printing **/
bool pretty(const ppindentinfo & ppii) const;
/** first member of list **/
obj<AGCObject> head_;
/** remainder of list **/

View file

@ -0,0 +1,57 @@
/** @file IPrintable_DList.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IPrintable_DList.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/IPrintable_DList.json5]
**/
#pragma once
#include <xo/printable2/Printable.hpp>
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
#include "DList.hpp"
namespace xo { namespace scm { class IPrintable_DList; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::print::APrintable,
xo::scm::DList>
{
using ImplType = xo::print::IPrintable_Xfer
<xo::scm::DList,
xo::scm::IPrintable_DList>;
};
}
}
namespace xo {
namespace scm {
/** @class IPrintable_DList
**/
class IPrintable_DList {
public:
/** @defgroup scm-printable-dlist-type-traits **/
///@{
using ppindentinfo = xo::print::APrintable::ppindentinfo;
///@}
/** @defgroup scm-printable-dlist-methods **/
///@{
/** Pretty-printing support for this object.
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
static bool pretty(const DList & self, const ppindentinfo & ppii);
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

View file

@ -8,6 +8,7 @@ set(SELF_SRCS
ISequence_Any.cpp
ISequence_DList.cpp
IPrintable_DFloat.cpp
IPrintable_DList.cpp
DList.cpp
DFloat.cpp
object2_register_types.cpp

View file

@ -84,6 +84,31 @@ namespace xo {
return l->head_;
}
#ifdef NOT_YET
bool
DList::pretty(const ppindentinfo & ppii) const
{
/* adapted from ppstate.pretty_struct(), see also */
using xo::print::ppstate;
ppstate * pps = ppii.pps();
if (ppii.upto()) {
/* perhaps print on one line */
if (!pps->print_upto("(")
return false;
/* TODO: probably use iterators here, when available */
const DList * l = this;
while (!l->is_empty()) {
obj<APrintable>(l->head_.data());
}
}
}
#endif
} /*namespace scm*/
} /*namespace xo*/

View file

@ -0,0 +1,28 @@
/** @file IPrintable_DList.cpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IPrintable_DList.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/IPrintable_DList.json5]
**/
#include "IPrintable_DList.hpp"
namespace xo {
namespace scm {
auto
IPrintable_DList::pretty(const DList & self, const ppindentinfo & ppii) -> bool
{
return self.pretty(ppii);
}
} /*namespace scm*/
} /*namespace xo*/
/* end IPrintable_DList.cpp */