diff --git a/CMakeLists.txt b/CMakeLists.txt index fc15ebf..629d549 100644 --- a/CMakeLists.txt +++ b/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/cmake/xo_object2Config.cmake.in b/cmake/xo_object2Config.cmake.in index c32a836..45104c2 100644 --- a/cmake/xo_object2Config.cmake.in +++ b/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/idl/IPrintable_DFloat.json5 b/idl/IPrintable_DFloat.json5 index 31d10dd..ef51cf7 100644 --- a/idl/IPrintable_DFloat.json5 +++ b/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/idl/ISequence_DList.json5 b/idl/ISequence_DList.json5 index 30c0b26..999fb48 100644 --- a/idl/ISequence_DList.json5 +++ b/idl/ISequence_DList.json5 @@ -1,6 +1,6 @@ { mode: "implementation", - includes: [], + includes: [ "" ], namespace1: "xo", namespace2: "scm", facet_idl: "idl/Sequence.json5", diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index 821e31d..3df8f74 100644 --- a/include/xo/object2/DFloat.hpp +++ b/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/include/xo/object2/IPrintable_DFloat.hpp b/include/xo/object2/IPrintable_DFloat.hpp new file mode 100644 index 0000000..a7140cd --- /dev/null +++ b/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/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index f1359f3..9ef4c63 100644 --- a/src/object2/CMakeLists.txt +++ b/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/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index 1ef8fa5..a9f7150 100644 --- a/src/object2/DFloat.cpp +++ b/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/src/object2/IPrintable_DFloat.cpp b/src/object2/IPrintable_DFloat.cpp new file mode 100644 index 0000000..9886626 --- /dev/null +++ b/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