diff --git a/xo-cmake/cmake/xo_macros/xo_cxx.cmake b/xo-cmake/cmake/xo_macros/xo_cxx.cmake index c872c927..dd382e7f 100644 --- a/xo-cmake/cmake/xo_macros/xo_cxx.cmake +++ b/xo-cmake/cmake/xo_macros/xo_cxx.cmake @@ -65,10 +65,10 @@ macro(xo_cxx_toplevel_options2) TARGET docs_${PROJECT_NAME} PROPERTY targets "") - add_custom_target(idl_${PROJECT_NAME}) + add_custom_target(share_${PROJECT_NAME}) set_property( - TARGET idl_${PROJECT_NAME} - PROPERTY path ${PROJECT_SOURCE_DIR}/idl) + TARGET share_${PROJECT_NAME} + PROPERTY path ${PROJECT_SOURCE_DIR}) endif() endmacro() @@ -1677,9 +1677,7 @@ function(xo_add_genfacet) ${GF_OUTPUT_HPP_DIR}/${GF_OUTPUT_IMPL_SUBDIR}/R${GF_FACET}.hpp ${GF_OUTPUT_CPP_DIR}/I${GF_FACET}_Any.cpp) - message(STATUS "generatedFiles=${generatedFiles}") - - message(ERROR "epic fail") + #message(STATUS "generatedFiles=${generatedFiles}") # Build the genfacet command add_custom_command( @@ -1704,6 +1702,7 @@ function(xo_add_genfacetimpl) set(options "") set(oneValueArgs TARGET # Name for this generation target + FACET_DIR # facet directory FACET # facet name REPR # representation name INPUT # Input .json5 file @@ -1754,6 +1753,7 @@ function(xo_add_genfacetimpl) OUTPUT ${generatedFiles} COMMAND ${GENFACET_EXECUTABLE} --input ${GF_INPUT} + --facet-dir ${GF_FACET_DIR} --output-hpp ${GF_OUTPUT_HPP_DIR} --output-impl-hpp ${GF_OUTPUT_IMPL_SUBDIR} --output-cpp ${GF_OUTPUT_CPP_DIR} diff --git a/xo-facet/codegen/genfacet b/xo-facet/codegen/genfacet index 03e6cebf..dc8b98af 100755 --- a/xo-facet/codegen/genfacet +++ b/xo-facet/codegen/genfacet @@ -236,12 +236,15 @@ def gen_facet_impl(env, # facet_includes: include section for AFoo.hpp: # - facet_includes = facet_idl['includes'] + #facet_includes = facet_idl['includes'] + facet_includes = idl['includes'] + + # # sequence facet_detail_subdir = facet_idl['detail_subdir'] # xo - facet_ns1: outer namespace for facet [e.g. xo] facet_ns1 = facet_idl['namespace1'] - # scm - facet_ns2: nested namespace for facet [e.g. scm] + # facet_ns2: nested namespace for facet [print] facet_ns2 = facet_idl['namespace2'] # Sequence - facet_name: facet name @@ -431,6 +434,8 @@ def gen_facet_impl(env, def main(): parser = argparse.ArgumentParser() parser.add_argument('--input', required=True, help='input IDL JSON5 file') + # --facet-dir: only with mode=implementation + parser.add_argument('--facet-dir', required=False, help='base dir for facet json') # --output-impl-hpp: putting this in .json5, will be able to drop this. parser.add_argument('--output-impl-hpp', required=True, help='.hpp detail subdir') parser.add_argument('--output-hpp', required=True, help='.hpp output directory') @@ -485,7 +490,10 @@ def main(): #output_impl_hpp_dir=output_impl_hpp_dir, output_cpp_dir=output_cpp_dir) elif idl['mode'] == 'implementation': - facet_idl_fname = idl['facet_idl'] + # idl: json5 for (iface, data) combination + # facet: json5 for abstract iface + + facet_idl_fname = args.facet_dir + '/' + idl['facet_idl'] facet_idl = load_idl(facet_idl_fname) gen_facet_impl(env=env, @@ -493,7 +501,7 @@ def main(): idl=idl, facet_idl=facet_idl, output_hpp_dir=output_hpp_dir, - output_impl_hpp_dir=output_impl_hpp_dir, + output_impl_hpp_subdir=output_impl_hpp_subdir, output_cpp_dir=output_cpp_dir) if __name__ == '__main__': diff --git a/xo-facet/codegen/iface_facet_repr.hpp.j2 b/xo-facet/codegen/iface_facet_repr.hpp.j2 index 479fd50b..afbd717d 100644 --- a/xo-facet/codegen/iface_facet_repr.hpp.j2 +++ b/xo-facet/codegen/iface_facet_repr.hpp.j2 @@ -13,8 +13,9 @@ #pragma once -#include "{{facet_hpp_fname}}" -#include "{{facet_detail_subdir}}/{{iface_facet_xfer_hpp_fname}}" +{% for include_fname in facet_includes %} +#include {{include_fname}} +{% endfor %} #include "{{data_repr_hpp_fname}}" namespace {{repr_ns1}} { namespace {{repr_ns2}} { class {{iface_facet_repr}}; } } @@ -43,7 +44,7 @@ namespace {{repr_ns1}} { ///@{ {% endif %} {% for ty in types %} - using {{ty.name}} = {{abstract_facet}}::{{ty.name}}; + using {{ty.name}} = {{facet_ns1}}::{{facet_ns2}}::{{abstract_facet}}::{{ty.name}}; {% endfor %} {% if using_dox %} ///@} diff --git a/xo-facet/codegen/iface_facet_xfer.hpp.j2 b/xo-facet/codegen/iface_facet_xfer.hpp.j2 index ad65907b..c0f02814 100644 --- a/xo-facet/codegen/iface_facet_xfer.hpp.j2 +++ b/xo-facet/codegen/iface_facet_xfer.hpp.j2 @@ -13,7 +13,9 @@ #pragma once -#include "{{abstract_facet_fname}}" +{% for include_fname in facet_includes %} +#include {{include_fname}} +{% endfor %} namespace {{facet_ns1}} { namespace {{facet_ns2}} { @@ -26,7 +28,10 @@ namespace {{facet_ns2}} { /** @defgroup {{facet_ns2}}-{{facet_name_lc}}-xfer-type-traits **/ ///@{ {% endif %} + /** actual implementation (not generated; often delegates to DRepr) **/ using Impl = {{iface_facet}}_DRepr; + /** integer identifying a type **/ + using typeseq = {{abstract_facet}}::typeseq; {% for ty in types %} using {{ty.name}} = {{abstract_facet}}::{{ty.name}}; {% endfor %} @@ -45,7 +50,7 @@ namespace {{facet_ns2}} { // from {{abstract_facet}} // const methods - int32_t _typeseq() const noexcept override { return s_typeseq; } + typeseq _typeseq() const noexcept override { return s_typeseq; } {% for md in const_methods %} {{md.return_type}} {{md.name}}({{md.args | args}}) {{md | qualifiers}} override { return I::{{md.name}}({{md.args | argnames}}); @@ -73,7 +78,7 @@ namespace {{facet_ns2}} { {% endif %} /** typeseq for template parameter DRepr **/ - static int32_t s_typeseq; + static typeseq s_typeseq; /** true iff satisfies facet implementation **/ static bool _valid; @@ -83,7 +88,7 @@ namespace {{facet_ns2}} { }; template - int32_t + xo::facet::typeseq {{iface_facet_xfer}}::s_typeseq = xo::facet::typeseq::id(); diff --git a/xo-indentlog/include/xo/indentlog/print/ppdetail_atomic.hpp b/xo-indentlog/include/xo/indentlog/print/ppdetail_atomic.hpp index cc50770a..8c7261d9 100644 --- a/xo-indentlog/include/xo/indentlog/print/ppdetail_atomic.hpp +++ b/xo-indentlog/include/xo/indentlog/print/ppdetail_atomic.hpp @@ -94,10 +94,10 @@ namespace xo { PPDETAIL_ATOMIC(bool); PPDETAIL_ATOMIC(char); -#ifdef __APPLE__ +# ifdef __APPLE__ // unsigned long != std::uint64_t. PPDETAIL_ATOMIC(unsigned long); -#endif +# endif PPDETAIL_ATOMIC(std::int64_t); PPDETAIL_ATOMIC(std::uint64_t); PPDETAIL_ATOMIC(std::int32_t); diff --git a/xo-object2/CMakeLists.txt b/xo-object2/CMakeLists.txt index fc15ebf9..629d5491 100644 --- a/xo-object2/CMakeLists.txt +++ b/xo-object2/CMakeLists.txt @@ -37,11 +37,12 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) -get_target_property(xo_printable2_src_dir xo-printable2 xo_srcdir) -message(STATUS "xo_printable2_src_dir=${xo_printable_src_dir}") +get_target_property(xo_printable2_dir share_xo_printable2 path) +message(STATUS "xo_printable2_dir=${xo_printable2_dir}") xo_add_genfacetimpl( TARGET xo-object2-facetimpl-printable-float + FACET_DIR ${xo_printable2_dir} FACET Printable REPR Float INPUT idl/IPrintable_DFloat.json5 diff --git a/xo-object2/cmake/xo_object2Config.cmake.in b/xo-object2/cmake/xo_object2Config.cmake.in index c32a8368..45104c22 100644 --- a/xo-object2/cmake/xo_object2Config.cmake.in +++ b/xo-object2/cmake/xo_object2Config.cmake.in @@ -1,7 +1,8 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) -#find_dependency(indentlog) -find_dependency(xo_alloc2) +find_dependency(xo_gc) +find_dependency(xo_printable2) +find_dependency(indentlog) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") check_required_components("@PROJECT_NAME@") diff --git a/xo-object2/idl/IPrintable_DFloat.json5 b/xo-object2/idl/IPrintable_DFloat.json5 index 31d10dd5..ef51cf70 100644 --- a/xo-object2/idl/IPrintable_DFloat.json5 +++ b/xo-object2/idl/IPrintable_DFloat.json5 @@ -1,8 +1,9 @@ { mode: "implementation", - includes: [], + includes: [ "", + "" ], namespace1: "xo", - namespace2: "print", + namespace2: "scm", facet_idl: "idl/Printable.json5", brief: "provide APrintable interface for DFloat", using_doxygen: true, diff --git a/xo-object2/idl/ISequence_DList.json5 b/xo-object2/idl/ISequence_DList.json5 index 30c0b262..999fb482 100644 --- a/xo-object2/idl/ISequence_DList.json5 +++ b/xo-object2/idl/ISequence_DList.json5 @@ -1,6 +1,6 @@ { mode: "implementation", - includes: [], + includes: [ "" ], namespace1: "xo", namespace2: "scm", facet_idl: "idl/Sequence.json5", diff --git a/xo-object2/include/xo/object2/DFloat.hpp b/xo-object2/include/xo/object2/DFloat.hpp index 821e31d0..3df8f741 100644 --- a/xo-object2/include/xo/object2/DFloat.hpp +++ b/xo-object2/include/xo/object2/DFloat.hpp @@ -6,11 +6,13 @@ #pragma once #include +#include namespace xo { namespace scm { struct DFloat { using AAllocator = xo::mm::AAllocator; + using ppindentinfo = xo::print::ppindentinfo; explicit DFloat(double x) : value_{x} {} @@ -20,6 +22,8 @@ namespace xo { double value() const noexcept { return value_; } + bool pretty(const ppindentinfo & ppii) const; + operator double() const noexcept { return value_; } private: diff --git a/xo-object2/include/xo/object2/IPrintable_DFloat.hpp b/xo-object2/include/xo/object2/IPrintable_DFloat.hpp new file mode 100644 index 00000000..a7140cda --- /dev/null +++ b/xo-object2/include/xo/object2/IPrintable_DFloat.hpp @@ -0,0 +1,58 @@ +/** @file IPrintable_DFloat.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DFloat.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DFloat.json5] + **/ + +#pragma once + +#include +#include +#include "DFloat.hpp" + +namespace xo { namespace scm { class IPrintable_DFloat; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DFloat + **/ + class IPrintable_DFloat { + public: + /** @defgroup scm-printable-dfloat-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + ///@} + /** @defgroup scm-printable-dfloat-methods **/ + ///@{ + /** Pretty-printing support for this object. + See [xo-indentlog/xo/indentlog/pretty.hpp] + **/ + static bool pretty(const DFloat & self, const ppindentinfo & ppii); + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ diff --git a/xo-object2/src/object2/CMakeLists.txt b/xo-object2/src/object2/CMakeLists.txt index f1359f3b..9ef4c63c 100644 --- a/xo-object2/src/object2/CMakeLists.txt +++ b/xo-object2/src/object2/CMakeLists.txt @@ -7,12 +7,14 @@ set(SELF_SRCS IGCObject_DList.cpp ISequence_Any.cpp ISequence_DList.cpp + IPrintable_DFloat.cpp DList.cpp DFloat.cpp object2_register_types.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) -# note: deps here must also appear in cmake/xo_alloc2Config.cmake.in +# note: deps here must also appear in cmake/xo_object2Config.cmake.in xo_dependency(${SELF_LIB} xo_gc) -#xo_dependency(${SELF_LIB} indentlog) +xo_dependency(${SELF_LIB} xo_printable2) +xo_dependency(${SELF_LIB} indentlog) diff --git a/xo-object2/src/object2/DFloat.cpp b/xo-object2/src/object2/DFloat.cpp index 1ef8fa52..a9f7150c 100644 --- a/xo-object2/src/object2/DFloat.cpp +++ b/xo-object2/src/object2/DFloat.cpp @@ -4,9 +4,11 @@ **/ #include "DFloat.hpp" +#include namespace xo { using xo::facet::typeseq; + using xo::print::ppdetail_atomic; namespace scm { DFloat * @@ -18,6 +20,12 @@ namespace xo { return new (mem) DFloat(x); } + + bool + DFloat::pretty(const ppindentinfo & ppii) const + { + return ppdetail_atomic::print_pretty(ppii, value_); + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/xo-object2/src/object2/IPrintable_DFloat.cpp b/xo-object2/src/object2/IPrintable_DFloat.cpp new file mode 100644 index 00000000..98866266 --- /dev/null +++ b/xo-object2/src/object2/IPrintable_DFloat.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DFloat.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DFloat.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DFloat.json5] +**/ + +#include "IPrintable_DFloat.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DFloat::pretty(const DFloat & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DFloat.cpp */ \ No newline at end of file diff --git a/xo-printable2/idl/Printable.json5 b/xo-printable2/idl/Printable.json5 index ee9a1e75..e71d827c 100644 --- a/xo-printable2/idl/Printable.json5 +++ b/xo-printable2/idl/Printable.json5 @@ -10,7 +10,14 @@ doc: [ "Trait for data types that support pretty-printing" ], - types: [], + 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 { diff --git a/xo-printable2/include/xo/printable2/Printable.hpp b/xo-printable2/include/xo/printable2/Printable.hpp index b5952a7d..b077d115 100644 --- a/xo-printable2/include/xo/printable2/Printable.hpp +++ b/xo-printable2/include/xo/printable2/Printable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Printable.json5] * 2. jinja2 template for facet .hpp file: diff --git a/xo-printable2/include/xo/printable2/detail/APrintable.hpp b/xo-printable2/include/xo/printable2/detail/APrintable.hpp index 3b734816..a66eb4a2 100644 --- a/xo-printable2/include/xo/printable2/detail/APrintable.hpp +++ b/xo-printable2/include/xo/printable2/detail/APrintable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Printable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -35,6 +35,8 @@ public: // types /** integer identifying a type **/ using typeseq = xo::facet::typeseq; + /** dynamic pretty-printing state during layout **/ + using ppindentinfo = xo::print::ppindentinfo; ///@} /** @defgroup print-printable-methods **/ @@ -43,7 +45,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] **/ + See [xo-indentlog/xo/indentlog/pretty.hpp] + **/ virtual bool pretty(Copaque data, const ppindentinfo & ppii) = 0; // nonconst methods @@ -66,4 +69,4 @@ using IPrintable_ImplType = xo::facet::FacetImplType; } /*namespace print*/ } /*namespace xo*/ -/* */ \ No newline at end of file +/* */ diff --git a/xo-printable2/include/xo/printable2/detail/IPrintable_Any.hpp b/xo-printable2/include/xo/printable2/detail/IPrintable_Any.hpp index b2c29bf4..b765ae97 100644 --- a/xo-printable2/include/xo/printable2/detail/IPrintable_Any.hpp +++ b/xo-printable2/include/xo/printable2/detail/IPrintable_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Printable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -44,6 +44,7 @@ namespace print { /** integer identifying a type **/ using typeseq = xo::facet::typeseq; + using ppindentinfo = APrintable::ppindentinfo; ///@} /** @defgroup print-printable-any-methods **/ @@ -70,7 +71,7 @@ namespace print { ///@} public: - /** @defgraoup print-printable-any-member-vars **/ + /** @defgroup print-printable-any-member-vars **/ ///@{ static typeseq s_typeseq; diff --git a/xo-printable2/include/xo/printable2/detail/IPrintable_Xfer.hpp b/xo-printable2/include/xo/printable2/detail/IPrintable_Xfer.hpp index d37d8453..a9f28ac9 100644 --- a/xo-printable2/include/xo/printable2/detail/IPrintable_Xfer.hpp +++ b/xo-printable2/include/xo/printable2/detail/IPrintable_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Printable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -13,7 +13,7 @@ #pragma once -#include "APrintable.hpp" +#include namespace xo { namespace print { @@ -24,7 +24,11 @@ namespace print { 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 **/ @@ -36,7 +40,7 @@ namespace print { // from APrintable // const methods - int32_t _typeseq() const noexcept override { return s_typeseq; } + typeseq _typeseq() const noexcept override { return s_typeseq; } bool pretty(Copaque data, const ppindentinfo & ppii) override { return I::pretty(_dcast(data), ppii); } @@ -49,11 +53,11 @@ namespace print { using I = Impl; public: - /** @defgraoup print-printable-xfer-member-vars **/ + /** @defgroup print-printable-xfer-member-vars **/ ///@{ /** typeseq for template parameter DRepr **/ - static int32_t s_typeseq; + static typeseq s_typeseq; /** true iff satisfies facet implementation **/ static bool _valid; @@ -61,7 +65,7 @@ namespace print { }; template - int32_t + xo::facet::typeseq IPrintable_Xfer::s_typeseq = xo::facet::typeseq::id(); diff --git a/xo-printable2/include/xo/printable2/detail/RPrintable.hpp b/xo-printable2/include/xo/printable2/detail/RPrintable.hpp index 1d9bd237..6dafb4c7 100644 --- a/xo-printable2/include/xo/printable2/detail/RPrintable.hpp +++ b/xo-printable2/include/xo/printable2/detail/RPrintable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Printable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -30,6 +30,7 @@ public: ///@{ using ObjectType = Object; using DataPtr = Object::DataPtr; + using ppindentinfo = APrintable::ppindentinfo; ///@} /** @defgroup print-printable-router-ctors **/