diff --git a/CMakeLists.txt b/CMakeLists.txt index 678e5eca..3de04758 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,8 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-variable @@ -68,6 +70,20 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-variable + FACET_PKG xo_printable2 + FACET Printable + REPR Variable + INPUT idl/IPrintable_DVariable.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-defineexpr @@ -80,6 +96,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-defineexpr + FACET_PKG xo_printable2 + FACET Printable + REPR DefineExpr + INPUT idl/IPrintable_DDefineExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # ---------------------------------------------------------------- # note: manual target; generated code committed to git diff --git a/idl/IPrintable_DDefineExpr.json5 b/idl/IPrintable_DDefineExpr.json5 new file mode 100644 index 00000000..351f8caf --- /dev/null +++ b/idl/IPrintable_DDefineExpr.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DDefineExpr", + using_doxygen: true, + repr: "DDefineExpr", + doc: [ "implement APrintable for DDefineExpr" ], +} diff --git a/idl/IPrintable_DVariable.json5 b/idl/IPrintable_DVariable.json5 new file mode 100644 index 00000000..52c301b2 --- /dev/null +++ b/idl/IPrintable_DVariable.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVariable", + using_doxygen: true, + repr: "DVariable", + doc: [ "implement APrintable for DVariable" ], +} diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 618e4161..59826aa2 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -8,6 +8,7 @@ #include "Expression.hpp" #include "DVariable.hpp" #include +#include namespace xo { namespace scm { @@ -21,6 +22,7 @@ namespace xo { **/ class DDefineExpr { public: + using ppindentinfo = xo::print::ppindentinfo; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -62,6 +64,12 @@ namespace xo { void assign_valuetype(TypeDescr td) noexcept; ///@} + /** @defgroup scm-defineexpr-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} private: /** @defgrouop scm-defineexpr-instance-vars **/ diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 2208852e..ae362bf1 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -10,6 +10,7 @@ #include "TypeRef.hpp" #include "exprtype.hpp" #include +#include namespace xo { namespace scm { @@ -19,6 +20,7 @@ namespace xo { **/ class DVariable { public: + using ppindentinfo = xo::print::ppindentinfo; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -46,7 +48,7 @@ namespace xo { void assign_name(const DUniqueString * name) { this->name_ = name; } - /** @defgroup scm-variable-expression-facet**/ + /** @defgroup scm-variable-expression-facet **/ ///@{ exprtype extype() const noexcept { return exprtype::variable; } @@ -55,6 +57,12 @@ namespace xo { void assign_valuetype(TypeDescr td) noexcept; ///@} + /** @defgroup scm-variable-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} private: /** symbol name **/ diff --git a/include/xo/expression2/detail/IExpression_DVariable.hpp b/include/xo/expression2/detail/IExpression_DVariable.hpp index 95b1becb..b4186f55 100644 --- a/include/xo/expression2/detail/IExpression_DVariable.hpp +++ b/include/xo/expression2/detail/IExpression_DVariable.hpp @@ -55,7 +55,7 @@ namespace xo { static TypeDescr valuetype(const DVariable & self) noexcept; // non-const methods - /** assing to valuetype member. Useful when scaffolding expressions **/ + /** assign to valuetype member. Useful when scaffolding expressions **/ static void assign_valuetype(DVariable & self, TypeDescr td) noexcept; ///@} }; @@ -63,4 +63,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp b/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp new file mode 100644 index 00000000..6d727d86 --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DDefineExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DDefineExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DDefineExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DDefineExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DDefineExpr + **/ + class IPrintable_DDefineExpr { + public: + /** @defgroup scm-printable-ddefineexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-ddefineexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DDefineExpr & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IPrintable_DVariable.hpp b/include/xo/expression2/detail/IPrintable_DVariable.hpp new file mode 100644 index 00000000..6e97451b --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DVariable.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVariable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVariable.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVariable.hpp" + +namespace xo { namespace scm { class IPrintable_DVariable; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVariable + **/ + class IPrintable_DVariable { + public: + /** @defgroup scm-printable-dvariable-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvariable-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVariable & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 0fcd6541..f2dfe7e7 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -12,8 +12,12 @@ set(SELF_SRCS IExpression_Any.cpp IExpression_DConstant.cpp + IExpression_DVariable.cpp + IPrintable_DVariable.cpp + IExpression_DDefineExpr.cpp + IPrintable_DDefineExpr.cpp DLocalSymtab.cpp DGlobalSymtab.cpp diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index a5609246..8afb90fe 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -4,9 +4,14 @@ **/ #include "DDefineExpr.hpp" +#include "detail/IPrintable_DVariable.hpp" +#include +#include #include namespace xo { + using xo::print::APrintable; + using xo::facet::FacetRegistry; using xo::facet::typeseq; namespace scm { @@ -60,6 +65,30 @@ namespace xo { { lhs_var_->assign_valuetype(td); } + + bool + DDefineExpr::pretty(const ppindentinfo & ppii) const + { + auto lhs = obj(lhs_var_); + auto rhs = FacetRegistry::instance().try_variant(rhs_); + + if (rhs_) { + assert(rhs); + + return ppii.pps()->pretty_struct + (ppii, + "DDefineExpr", + refrtag("lhs", lhs), + refrtag("rhs", rhs)); + } else { + return ppii.pps()->pretty_struct + (ppii, + "DDefineExpr", + refrtag("lhs", lhs)); + } + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index d27c71ef..4adbe841 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -35,6 +35,19 @@ namespace xo { typeref_.resolve(td); } + bool + DVariable::pretty(const ppindentinfo & ppii) const + { + auto name = (name_ + ? std::string_view(*name_) + : std::string_view("")); + + return ppii.pps()->pretty_struct + (ppii, + "DVariable", + refrtag("name", name)); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/IPrintable_DDefineExpr.cpp b/src/expression2/IPrintable_DDefineExpr.cpp new file mode 100644 index 00000000..e8c6a799 --- /dev/null +++ b/src/expression2/IPrintable_DDefineExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DDefineExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DDefineExpr.json5] +**/ + +#include "detail/IPrintable_DDefineExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DDefineExpr::pretty(const DDefineExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DDefineExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/IPrintable_DVariable.cpp b/src/expression2/IPrintable_DVariable.cpp new file mode 100644 index 00000000..75e673ae --- /dev/null +++ b/src/expression2/IPrintable_DVariable.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVariable.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVariable.json5] +**/ + +#include "detail/IPrintable_DVariable.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVariable::pretty(const DVariable & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVariable.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 2d728bd3..e6715769 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -8,6 +8,10 @@ #include #include +#include + +#include + #include #include #include @@ -28,7 +32,15 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + log && log(xtag("DUniqueString.tseq", typeseq::id())); + log && log(xtag("DDefineExpr.tseq", typeseq::id())); + log && log(xtag("DVariable.tseq", typeseq::id())); + + log && log(xtag("AExpression.tqseq", typeseq::id())); return true; }