xo-facet xo-object2: facet fixes + IPrintable_DString
This commit is contained in:
parent
aba9530a57
commit
d2d3b34ce7
21 changed files with 176 additions and 26 deletions
|
|
@ -18,4 +18,8 @@
|
|||
#include "{{impl_hpp_subdir}}/{{iface_facet_xfer_hpp_fname}}"
|
||||
#include "{{impl_hpp_subdir}}/{{router_facet_hpp_fname}}"
|
||||
|
||||
{% for include_fname in user_hpp_includes %}
|
||||
#include {{include_fname}}
|
||||
{% endfor %}
|
||||
|
||||
/* end {{facet_hpp_fname}} */
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ def gen_facet(env,
|
|||
|
||||
# extra include files (or perhaps other definitions)
|
||||
facet_includes = idl['includes']
|
||||
# extra (post) includes for user .hpp e.g. Sequence.hpp
|
||||
user_hpp_includes = idl['user_hpp_includes']
|
||||
# arbitrary text after includes, before opening namespaces
|
||||
facet_pretext = idl['pretext']
|
||||
# detail
|
||||
|
|
@ -163,6 +165,8 @@ def gen_facet(env,
|
|||
'facet_ns2': facet_ns2,
|
||||
'facet_name_lc': facet_name_lc,
|
||||
'facet_hpp_fname': facet_hpp_fname,
|
||||
#
|
||||
'user_hpp_includes': user_hpp_includes,
|
||||
#'name': facet_name,
|
||||
'idl_fname': idl_fname,
|
||||
#
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ public:
|
|||
{% endif %}
|
||||
{{router_facet}}() {}
|
||||
{{router_facet}}(Object::DataPtr data) : Object{std::move(data)} {}
|
||||
{{router_facet}}(const {{abstract_facet}} * iface, void * data)
|
||||
requires std::is_same_v<typename Object::DataType, xo::facet::DVariantPlaceholder>
|
||||
: Object(iface, data) {}
|
||||
|
||||
{% if using_dox %}
|
||||
///@}
|
||||
|
|
@ -61,7 +64,7 @@ public:
|
|||
}
|
||||
{% endfor %}
|
||||
|
||||
// non-const methods
|
||||
// non-const methods (still const in router!)
|
||||
{% for md in nonconst_methods %}
|
||||
{{md.return_type}} {{md.name}}({{md.args | argsnodata}}) {{md | staticqual}} {
|
||||
return O::iface()->{{md.name}}({{md.args | argrouting}});
|
||||
|
|
|
|||
|
|
@ -64,6 +64,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-string
|
||||
FACET_PKG xo_printable2
|
||||
FACET Printable
|
||||
REPR String
|
||||
INPUT idl/IPrintable_DString.json5
|
||||
OUTPUT_HPP_DIR include/xo/object2/string
|
||||
OUTPUT_IMPL_SUBDIR .
|
||||
OUTPUT_CPP_DIR src/object2
|
||||
)
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-object2-facetimpl-gcobject-string
|
||||
|
|
|
|||
13
xo-object2/idl/IPrintable_DString.json5
Normal file
13
xo-object2/idl/IPrintable_DString.json5
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
mode: "implementation",
|
||||
includes: [ "<xo/printable2/Printable.hpp>",
|
||||
"<xo/printable2/detail/IPrintable_Xfer.hpp>" ],
|
||||
local_types: [ ],
|
||||
namespace1: "xo",
|
||||
namespace2: "scm",
|
||||
facet_idl: "idl/Printable.json5",
|
||||
brief: "provide APrintable interface for DString",
|
||||
using_doxygen: true,
|
||||
repr: "DString",
|
||||
doc: [ "implement APrintable for DString" ],
|
||||
}
|
||||
61
xo-object2/include/xo/object2/string/IPrintable_DString.hpp
Normal file
61
xo-object2/include/xo/object2/string/IPrintable_DString.hpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/** @file IPrintable_DString.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DString.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DString.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
|
||||
#include "DString.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IPrintable_DString; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::print::APrintable,
|
||||
xo::scm::DString>
|
||||
{
|
||||
using ImplType = xo::print::IPrintable_Xfer
|
||||
<xo::scm::DString,
|
||||
xo::scm::IPrintable_DString>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IPrintable_DString
|
||||
**/
|
||||
class IPrintable_DString {
|
||||
public:
|
||||
/** @defgroup scm-printable-dstring-type-traits **/
|
||||
///@{
|
||||
using ppindentinfo = xo::print::APrintable::ppindentinfo;
|
||||
using Copaque = xo::print::APrintable::Copaque;
|
||||
using Opaque = xo::print::APrintable::Opaque;
|
||||
///@}
|
||||
/** @defgroup scm-printable-dstring-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** Pretty-printing support for this object.
|
||||
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
|
||||
static bool pretty(const DString & self, const ppindentinfo & ppii);
|
||||
|
||||
// non-const methods
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -11,6 +11,7 @@ set(SELF_SRCS
|
|||
IPrintable_DList.cpp
|
||||
IPrintable_DFloat.cpp
|
||||
IPrintable_DInteger.cpp
|
||||
IPrintable_DString.cpp
|
||||
DList.cpp
|
||||
DFloat.cpp
|
||||
DInteger.cpp
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "DInteger.hpp"
|
||||
#include <xo/indentlog/print/pretty.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::facet::typeseq;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
**/
|
||||
|
||||
#include "DList.hpp"
|
||||
#include "IPrintable_DList.hpp"
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
#include <xo/indentlog/print/pretty.hpp>
|
||||
|
|
@ -125,7 +127,9 @@ namespace xo {
|
|||
obj<APrintable> elt
|
||||
= FacetRegistry::instance().variant<APrintable, AGCObject>(l->head_);
|
||||
|
||||
assert(elt);
|
||||
|
||||
|
||||
assert(elt.data());
|
||||
|
||||
if (!pps->print_upto(elt))
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@
|
|||
**/
|
||||
|
||||
#include "DString.hpp"
|
||||
#include <xo/indentlog/print/pretty.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
namespace xo {
|
||||
using xo::facet::typeseq;
|
||||
using xo::print::ppdetail_atomic;
|
||||
|
||||
namespace scm {
|
||||
DString *
|
||||
|
|
@ -113,6 +115,12 @@ namespace xo {
|
|||
return shallow_size();
|
||||
}
|
||||
|
||||
bool
|
||||
DString::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
return ppdetail_atomic<const char *>::print_pretty(ppii, &(chars_[0]));
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
**/
|
||||
|
||||
#include "IPrintable_DList.hpp"
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
|
|
|||
28
xo-object2/src/object2/IPrintable_DString.cpp
Normal file
28
xo-object2/src/object2/IPrintable_DString.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/** @file IPrintable_DString.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DString.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DString.json5]
|
||||
**/
|
||||
|
||||
#include "string/IPrintable_DString.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IPrintable_DString::pretty(const DString & self, const ppindentinfo & ppii) -> bool
|
||||
{
|
||||
return self.pretty(ppii);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_DString.cpp */
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
#include <xo/object2/IPrintable_DList.hpp>
|
||||
#include <xo/object2/IPrintable_DFloat.hpp>
|
||||
#include <xo/object2/IPrintable_DInteger.hpp>
|
||||
#include <xo/object2/string/IPrintable_DString.hpp>
|
||||
|
||||
#include <xo/printable2/detail/APrintable.hpp>
|
||||
#include <xo/alloc2/alloc/AAllocator.hpp>
|
||||
|
|
@ -45,6 +46,7 @@ namespace xo {
|
|||
FacetRegistry::register_impl<APrintable, DInteger>();
|
||||
|
||||
FacetRegistry::register_impl<AGCObject, DString>();
|
||||
FacetRegistry::register_impl<APrintable, DString>();
|
||||
|
||||
log && log(xtag("DList.tseq", typeseq::id<DList>()));
|
||||
log && log(xtag("DFloat.tseq", typeseq::id<DFloat>()));
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ namespace ut {
|
|||
FacetRegistry::instance().dump(&std::cerr);
|
||||
|
||||
for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) {
|
||||
log && log("printable1 test:", xtag("i_tc", i_tc));
|
||||
|
||||
try {
|
||||
const testcase_pp & tc = s_testcase_v[i_tc];
|
||||
|
||||
|
|
@ -130,7 +132,7 @@ namespace ut {
|
|||
|
||||
pps.pretty(l0_po);
|
||||
|
||||
REQUIRE(ss.str() == string(tc.expected_));
|
||||
CHECK(ss.str() == string(tc.expected_));
|
||||
} catch (std::exception & ex) {
|
||||
std::cerr << "caught exception: " << ex.what() << std::endl;
|
||||
REQUIRE(false);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
{
|
||||
mode: "facet",
|
||||
includes: ["<xo/indentlog/print/ppindentinfo.hpp>"],
|
||||
// extra includes in Printable.hpp
|
||||
user_hpp_includes: ["\"detail/ppdetail_Printable.hpp\""],
|
||||
namespace1: "xo",
|
||||
namespace2: "print",
|
||||
pretext: [],
|
||||
facet: "Printable",
|
||||
detail_subdir: "detail",
|
||||
brief: "pretty-printable objects",
|
||||
|
|
@ -30,6 +33,7 @@
|
|||
args: [
|
||||
{type: "const ppindentinfo &", name: "ppii"},
|
||||
],
|
||||
const: true,
|
||||
},
|
||||
],
|
||||
nonconst_methods: [],
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Printable.json5]
|
||||
* 2. jinja2 template for facet .hpp file:
|
||||
|
|
@ -18,7 +18,6 @@
|
|||
#include "detail/IPrintable_Xfer.hpp"
|
||||
#include "detail/RPrintable.hpp"
|
||||
|
||||
// todo: additional includes in idl above
|
||||
#include "detail/ppdetail_Printable.hpp"
|
||||
|
||||
/* end Printable.hpp */
|
||||
/* end Printable.hpp */
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Printable.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/facet/typeseq.hpp>
|
||||
|
||||
|
||||
namespace xo {
|
||||
namespace print {
|
||||
|
||||
|
|
@ -35,6 +36,8 @@ public:
|
|||
// 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;
|
||||
///@}
|
||||
|
|
@ -45,9 +48,8 @@ public:
|
|||
/** 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;
|
||||
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
|
||||
virtual bool pretty(Copaque data, const ppindentinfo & ppii) const = 0;
|
||||
|
||||
// nonconst methods
|
||||
///@}
|
||||
|
|
@ -69,4 +71,4 @@ using IPrintable_ImplType = xo::facet::FacetImplType<APrintable, DRepr>;
|
|||
} /*namespace print*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* */
|
||||
/* APrintable.hpp */
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Printable.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -56,7 +56,7 @@ namespace print {
|
|||
|
||||
// const methods
|
||||
typeseq _typeseq() const noexcept override { return s_typeseq; }
|
||||
[[noreturn]] bool pretty(Copaque, const ppindentinfo &) const override { _fatal(); }
|
||||
[[noreturn]] bool pretty(Copaque, const ppindentinfo &) const override { _fatal(); }
|
||||
|
||||
// nonconst methods
|
||||
|
||||
|
|
@ -83,4 +83,4 @@ namespace print {
|
|||
} /*namespace print */
|
||||
} /*namespace xo */
|
||||
|
||||
/* IPrintable_Any.hpp */
|
||||
/* IPrintable_Any.hpp */
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Printable.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -41,7 +41,7 @@ namespace print {
|
|||
|
||||
// const methods
|
||||
typeseq _typeseq() const noexcept override { return s_typeseq; }
|
||||
bool pretty(Copaque data, const ppindentinfo & ppii) const override {
|
||||
bool pretty(Copaque data, const ppindentinfo & ppii) const override {
|
||||
return I::pretty(_dcast(data), ppii);
|
||||
}
|
||||
|
||||
|
|
@ -78,4 +78,4 @@ namespace print {
|
|||
} /*namespace print */
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_Xfer.hpp */
|
||||
/* end IPrintable_Xfer.hpp */
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Printable.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -30,8 +30,8 @@ public:
|
|||
///@{
|
||||
using ObjectType = Object;
|
||||
using DataPtr = Object::DataPtr;
|
||||
using typeseq = xo::reflect::typeseq;
|
||||
using ppindentinfo = APrintable::ppindentinfo;
|
||||
using typeseq = xo::facet::typeseq;
|
||||
///@}
|
||||
|
||||
/** @defgroup print-printable-router-ctors **/
|
||||
|
|
@ -39,8 +39,8 @@ public:
|
|||
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) {}
|
||||
requires std::is_same_v<typename Object::DataType, xo::facet::DVariantPlaceholder>
|
||||
: Object(iface, data) {}
|
||||
|
||||
///@}
|
||||
/** @defgroup print-printable-router-methods **/
|
||||
|
|
@ -48,13 +48,11 @@ public:
|
|||
|
||||
// const methods
|
||||
typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); }
|
||||
bool pretty(const ppindentinfo & ppii) const {
|
||||
bool pretty(const ppindentinfo & ppii) const {
|
||||
return O::iface()->pretty(O::data(), ppii);
|
||||
}
|
||||
|
||||
// non-const methods
|
||||
// << do something for non-const methods >>
|
||||
//
|
||||
// non-const methods (still const in router!)
|
||||
|
||||
///@}
|
||||
/** @defgroup print-printable-member-vars **/
|
||||
|
|
@ -79,4 +77,4 @@ namespace xo { namespace facet {
|
|||
};
|
||||
} }
|
||||
|
||||
/* end RPrintable.hpp */
|
||||
/* end RPrintable.hpp */
|
||||
|
|
@ -32,6 +32,9 @@ bool
|
|||
IPrintable_Any::_valid
|
||||
= valid_facet_implementation<APrintable, IPrintable_Any>();
|
||||
|
||||
// nonconst methods
|
||||
|
||||
|
||||
} /*namespace print*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue