git subrepo clone (merge) git@github.com:Rconybea/xo-printable2.git xo-printable2

subrepo:
  subdir:   "xo-printable2"
  merged:   "48f6dfaa"
upstream:
  origin:   "git@github.com:Rconybea/xo-printable2.git"
  branch:   "main"
  commit:   "48f6dfaa"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"
This commit is contained in:
Roland Conybeare 2026-06-06 21:44:20 -04:00
commit c19bb856c1
14 changed files with 573 additions and 0 deletions

12
xo-printable2/.gitrepo Normal file
View file

@ -0,0 +1,12 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme
;
[subrepo]
remote = git@github.com:Rconybea/xo-printable2.git
branch = main
commit = 48f6dfaa20ac6eab44425324d7c10a5480c6bec0
parent = 6fc83036026aed83cae0421fa3f3272ca182ab3a
method = merge
cmdver = 0.4.9

View file

@ -0,0 +1,46 @@
# xo-printable2/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(xo_printable2 VERSION 0.1)
include(GNUInstallDirs)
include(cmake/xo-bootstrap-macros.cmake)
xo_cxx_toplevel_options3()
# ----------------------------------------------------------------
# c++ settings
set(PROJECT_CXX_FLAGS "")
#set(PROJECT_CXX_FLAGS "-fconcepts-diagnostics-depth=2") # gcc-only!
add_definitions(${PROJECT_CXX_FLAGS})
# ----------------------------------------------------------------
xo_add_genfacet(
TARGET xo-printable2-facet-printable
FACET Printable
INPUT idl/Printable.json5
OUTPUT_HPP_DIR include/xo/printable2
OUTPUT_IMPL_SUBDIR detail
)
# ----------------------------------------------------------------
add_subdirectory(src/printable2)
#add_subdirectory(utest)
install(DIRECTORY idl/
DESTINATION share/${PROJECT_NAME}/idl
FILES_MATCHING PATTERN "*.json5")
xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets)
# ----------------------------------------------------------------
# docs targets depend on other library/utest/exec targets above,
# --> must come after them.
#
#add_subdirectory(docs)
# end CMakeLists.txt

1
xo-printable2/README.md Normal file
View file

@ -0,0 +1 @@
# xo-printable2

View file

@ -0,0 +1,41 @@
# ----------------------------------------------------------------
# for example:
# $ PREFIX=/usr/local # for example
# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build
#
# will get
# CMAKE_MODULE_PATH
# from xo-cmake-config --cmake-module-path
#
# and expect .cmake macros in
# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake
# ----------------------------------------------------------------
find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED)
if ("${XO_CMAKE_CONFIG_EXECUTABLE}" STREQUAL "XO_CMAKE_CONFIG_EXECUTABLE-NOT_FOUND")
message(FATAL "could not find xo-cmake-config executable")
endif()
message(STATUS "XO_CMAKE_CONFIG_EXECUTABLE=${XO_CMAKE_CONFIG_EXECUTABLE}")
if (XO_SUBMODULE_BUILD)
if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix))
# local version of xo-cmake macros
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/xo-cmake/cmake")
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
endif()
else()
if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix))
# default to typical install location for xo-project-macros
execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH)
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
endif()
endif()
# needs to have been installed somewhere on CMAKE_MODULE_PATH,
# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX)
#
include(xo_macros/xo_cxx)
xo_cxx_bootstrap_message()

View file

@ -0,0 +1,8 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(indentlog)
find_dependency(xo_facet)
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Share.cmake")
check_required_components("@PROJECT_NAME@")

View file

@ -0,0 +1,45 @@
{
mode: "facet",
output_cpp_dir: "src/printable2",
output_hpp_dir: "include/xo/printable2",
output_impl_subdir: "detail",
includes: ["<xo/indentlog/print/ppindentinfo.hpp>"],
// extra includes in Printable.hpp
user_hpp_includes: ["\"detail/ppdetail_Printable.hpp\""],
namespace1: "xo",
namespace2: "print",
// text after includes, before APrintable
pretext: [ "// {pretext} here" ],
facet: "Printable",
detail_subdir: "detail",
brief: "pretty-printable objects",
using_doxygen: true,
doc: [
"Trait for data types that support pretty-printing"
],
types: [
// using ppindentinfo = xo::print::ppindentinfo
{
name: "ppindentinfo",
doc: ["dynamic pretty-printing state during layout"],
definition: "xo::print::ppindentinfo",
},
],
const_methods: [
// bool pretty(const ppindentinfo & ppii) const
{
name: "pretty",
doc: [
"Pretty-printing support for this object.",
"See [xo-indentlog/xo/indentlog/pretty.hpp]",
],
return_type: "bool",
args: [
{type: "const ppindentinfo &", name: "ppii"},
],
const: true,
},
],
nonconst_methods: [],
router_facet_explicit_content: [],
}

View file

@ -0,0 +1,25 @@
/** @file Printable.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/Printable.json5]
* 2. jinja2 template for facet .hpp file:
* [facet.hpp.j2]
* 3. idl for facet methods
* [idl/Printable.json5]
**/
#pragma once
#include "detail/APrintable.hpp"
#include "detail/IPrintable_Any.hpp"
#include "detail/IPrintable_Xfer.hpp"
#include "detail/RPrintable.hpp"
#include "detail/ppdetail_Printable.hpp"
#include <xo/alloc2/Allocator.hpp>
/* end Printable.hpp */

View file

@ -0,0 +1,74 @@
/** @file APrintable.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/Printable.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [abstract_facet.hpp.j2]
* 3. idl for facet methods
* [idl/Printable.json5]
**/
#pragma once
// includes (via {facet_includes})
#include <xo/indentlog/print/ppindentinfo.hpp>
#include <xo/facet/obj.hpp>
#include <xo/facet/facet_implementation.hpp>
#include <xo/facet/typeseq.hpp>
namespace xo {
namespace print {
using Copaque = const void *;
using Opaque = void *;
/**
Trait for data types that support pretty-printing
**/
class APrintable {
public:
/** @defgroup print-printable-type-traits **/
///@{
// types
/** integer identifying a type **/
using typeseq = xo::facet::typeseq;
using Copaque = const void *;
using Opaque = void *;
/** dynamic pretty-printing state during layout **/
using ppindentinfo = xo::print::ppindentinfo;
///@}
/** @defgroup print-printable-methods **/
///@{
// const methods
/** RTTI: unique id# for actual runtime data representation **/
virtual typeseq _typeseq() const noexcept = 0;
/** Pretty-printing support for this object.
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
virtual bool pretty(Copaque data, const ppindentinfo & ppii) const = 0;
// nonconst methods
///@}
}; /*APrintable*/
/** Implementation IPrintable_DRepr of APrintable for state DRepr
* should provide a specialization:
*
* template <>
* struct xo::facet::FacetImplementation<APrintable, DRepr> {
* using Impltype = IPrintable_DRepr;
* };
*
* then IPrintable_ImplType<DRepr> --> IPrintable_DRepr
**/
template <typename DRepr>
using IPrintable_ImplType = xo::facet::FacetImplType<APrintable, DRepr>;
} /*namespace print*/
} /*namespace xo*/
/* APrintable.hpp */

View file

@ -0,0 +1,86 @@
/** @file IPrintable_Any.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/Printable.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/Printable.json5]
**/
#pragma once
#include "APrintable.hpp"
#include <xo/facet/obj.hpp>
namespace xo { namespace print { class IPrintable_Any; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::print::APrintable,
DVariantPlaceholder>
{
using ImplType = xo::print::IPrintable_Any;
};
}
}
namespace xo {
namespace print {
/** @class IPrintable_Any
* @brief APrintable implementation for empty variant instance
**/
class IPrintable_Any : public APrintable {
public:
/** @defgroup print-printable-any-type-traits **/
///@{
/** integer identifying a type **/
using typeseq = xo::facet::typeseq;
using ppindentinfo = APrintable::ppindentinfo;
///@}
/** @defgroup print-printable-any-methods **/
///@{
const APrintable * iface() const { return std::launder(this); }
// from APrintable
// const methods
typeseq _typeseq() const noexcept override { return s_typeseq; }
[[noreturn]] bool pretty(Copaque, const ppindentinfo &) const override { _fatal(); }
// nonconst methods
///@}
private:
/** @defgraoup print-printable-any-private-methods **/
///@{
[[noreturn]] static void _fatal();
///@}
public:
/** @defgroup print-printable-any-member-vars **/
///@{
static typeseq s_typeseq;
static bool _valid;
///@}
};
} /*namespace print */
} /*namespace xo */
/* IPrintable_Any.hpp */

View file

@ -0,0 +1,81 @@
/** @file IPrintable_Xfer.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/Printable.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/Printable.json5]
**/
#pragma once
#include <xo/indentlog/print/ppindentinfo.hpp>
namespace xo {
namespace print {
/** @class IPrintable_Xfer
**/
template <typename DRepr, typename IPrintable_DRepr>
class IPrintable_Xfer : public APrintable {
public:
/** @defgroup print-printable-xfer-type-traits **/
///@{
/** actual implementation (not generated; often delegates to DRepr) **/
using Impl = IPrintable_DRepr;
/** integer identifying a type **/
using typeseq = APrintable::typeseq;
using ppindentinfo = APrintable::ppindentinfo;
///@}
/** @defgroup print-printable-xfer-methods **/
///@{
static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; }
static DRepr & _dcast(Opaque d) { return *(DRepr *)d; }
// from APrintable
// const methods
typeseq _typeseq() const noexcept override { return s_typeseq; }
bool pretty(Copaque data, const ppindentinfo & ppii) const override {
return I::pretty(_dcast(data), ppii);
}
// non-const methods
///@}
private:
using I = Impl;
public:
/** @defgroup print-printable-xfer-member-vars **/
///@{
/** typeseq for template parameter DRepr **/
static typeseq s_typeseq;
/** true iff satisfies facet implementation **/
static bool _valid;
///@}
};
template <typename DRepr, typename IPrintable_DRepr>
xo::facet::typeseq
IPrintable_Xfer<DRepr, IPrintable_DRepr>::s_typeseq
= xo::facet::typeseq::id<DRepr>();
template <typename DRepr, typename IPrintable_DRepr>
bool
IPrintable_Xfer<DRepr, IPrintable_DRepr>::_valid
= xo::facet::valid_facet_implementation<APrintable,
IPrintable_Xfer>();
} /*namespace print */
} /*namespace xo*/
/* end IPrintable_Xfer.hpp */

View file

@ -0,0 +1,80 @@
/** @file RPrintable.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
* arguments:
* --input [idl/Printable.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/Printable.json5]
**/
#pragma once
#include "APrintable.hpp"
namespace xo {
namespace print {
/** @class RPrintable
**/
template <typename Object>
class RPrintable : public Object {
private:
using O = Object;
public:
/** @defgroup print-printable-router-type-traits **/
///@{
using ObjectType = Object;
using DataPtr = Object::DataPtr;
using typeseq = xo::reflect::typeseq;
using ppindentinfo = APrintable::ppindentinfo;
///@}
/** @defgroup print-printable-router-ctors **/
///@{
RPrintable() {}
RPrintable(Object::DataPtr data) : Object{std::move(data)} {}
RPrintable(const APrintable * iface, void * data)
requires std::is_same_v<typename Object::DataType, xo::facet::DVariantPlaceholder>
: Object(iface, data) {}
///@}
/** @defgroup print-printable-router-methods **/
///@{
// const methods
typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); }
bool pretty(const ppindentinfo & ppii) const {
return O::iface()->pretty(O::data(), ppii);
}
// non-const methods (still const in router!)
///@}
/** @defgroup print-printable-member-vars **/
///@{
static bool _valid;
///@}
};
template <typename Object>
bool
RPrintable<Object>::_valid = xo::facet::valid_object_router<Object>();
} /*namespace print*/
} /*namespace xo*/
namespace xo { namespace facet {
template <typename Object>
struct RoutingFor<xo::print::APrintable, Object> {
using RoutingType = xo::print::RPrintable<Object>;
};
} }
/* end RPrintable.hpp */

View file

@ -0,0 +1,21 @@
/** @file ppdetail_Printable.hpp
*
* @author Roland Conybeare, Jan 2026
**/
#include <xo/indentlog/print/pretty.hpp>
#include "Printable.hpp"
namespace xo {
namespace print {
template <typename DRepr>
struct ppdetail<xo::facet::obj<APrintable, DRepr>> {
static bool print_pretty(const ppindentinfo & ppii,
const xo::facet::obj<APrintable, DRepr> & x) {
return x.pretty(ppii);
}
};
}
} /*namespace xo*/
/* end ppdetail_Printable.hpp */

View file

@ -0,0 +1,11 @@
# printable2/CMakeLists.txt
set(SELF_LIB xo_printable2)
set(SELF_SRCS
IPrintable_Any.cpp
)
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})
# note: deps here must coord with cmake/xo_printable2Config.cmake.in
xo_dependency(${SELF_LIB} indentlog)
xo_dependency(${SELF_LIB} xo_facet)

View file

@ -0,0 +1,42 @@
/** @file IPrintable_Any.cpp
*
**/
#include "detail/IPrintable_Any.hpp"
#include <iostream>
#include <exception>
namespace xo {
namespace print {
using xo::facet::DVariantPlaceholder;
using xo::facet::typeseq;
using xo::facet::valid_facet_implementation;
void
IPrintable_Any::_fatal()
{
/* control here on uninitialized IAllocator_Any.
* Initialized instance will have specific implementation type
*/
std::cerr << "fatal"
<< ": attempt to call uninitialized"
<< " IPrintable_Any method"
<< std::endl;
std::terminate();
}
typeseq
IPrintable_Any::s_typeseq = typeseq::id<DVariantPlaceholder>();
bool
IPrintable_Any::_valid
= valid_facet_implementation<APrintable, IPrintable_Any>();
// nonconst methods
} /*namespace print*/
} /*namespace xo*/
/* end IPrintable_Any.cpp */