xo-object2: Printable+DList [WIP]
This commit is contained in:
parent
ca27454ce8
commit
3b2a384ab6
8 changed files with 141 additions and 5 deletions
|
|
@ -27,6 +27,7 @@ xo_add_genfacet(
|
|||
OUTPUT_CPP_DIR src/object2
|
||||
)
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-object2-facetimpl-sequence-list
|
||||
FACET_PKG xo_object2
|
||||
|
|
@ -38,13 +39,10 @@ xo_add_genfacetimpl(
|
|||
OUTPUT_CPP_DIR src/object2
|
||||
)
|
||||
|
||||
#get_target_property(xo_printable2_dir share_xo_printable2 path)
|
||||
#message(STATUS "xo_printable2_dir=${xo_printable2_dir}")
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-object2-facetimpl-printable-float
|
||||
FACET_PKG xo_printable2
|
||||
# FACET_DIR ${xo_printable2_dir}
|
||||
FACET Printable
|
||||
REPR Float
|
||||
INPUT idl/IPrintable_DFloat.json5
|
||||
|
|
@ -53,6 +51,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-list
|
||||
FACET_PKG xo_printable2
|
||||
FACET Printable
|
||||
REPR List
|
||||
INPUT idl/IPrintable_DList.json5
|
||||
OUTPUT_HPP_DIR include/xo/object2
|
||||
OUTPUT_IMPL_SUBDIR .
|
||||
OUTPUT_CPP_DIR src/object2
|
||||
)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
# must complete definition of expression lib before configuring examples
|
||||
|
|
|
|||
|
|
@ -8,5 +8,5 @@
|
|||
brief: "provide APrintable interface for DFloat",
|
||||
using_doxygen: true,
|
||||
repr: "DFloat",
|
||||
doc: [ "doc for something or other" ],
|
||||
doc: [ "implement APrintable for DFloat" ],
|
||||
}
|
||||
|
|
|
|||
12
idl/IPrintable_DList.json5
Normal file
12
idl/IPrintable_DList.json5
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
mode: "implementation",
|
||||
includes: [ "<xo/printable2/Printable.hpp>",
|
||||
"<xo/printable2/detail/IPrintable_Xfer.hpp>" ],
|
||||
namespace1: "xo",
|
||||
namespace2: "scm",
|
||||
facet_idl: "idl/Printable.json5",
|
||||
brief: "provide APrintable interface for DList",
|
||||
using_doxygen: true,
|
||||
repr: "DList",
|
||||
doc: [ "implement APrintable for DList" ],
|
||||
}
|
||||
|
|
@ -40,6 +40,9 @@ namespace xo {
|
|||
/** return element at 0-based index @p ix **/
|
||||
obj<AGCObject> at(size_type ix) const;
|
||||
|
||||
/** pretty-printing driver; combine layout+printing **/
|
||||
bool pretty(const ppindentinfo & ppii) const;
|
||||
|
||||
/** first member of list **/
|
||||
obj<AGCObject> head_;
|
||||
/** remainder of list **/
|
||||
|
|
|
|||
57
include/xo/object2/IPrintable_DList.hpp
Normal file
57
include/xo/object2/IPrintable_DList.hpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/** @file IPrintable_DList.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DList.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DList.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
|
||||
#include "DList.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IPrintable_DList; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::print::APrintable,
|
||||
xo::scm::DList>
|
||||
{
|
||||
using ImplType = xo::print::IPrintable_Xfer
|
||||
<xo::scm::DList,
|
||||
xo::scm::IPrintable_DList>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IPrintable_DList
|
||||
**/
|
||||
class IPrintable_DList {
|
||||
public:
|
||||
/** @defgroup scm-printable-dlist-type-traits **/
|
||||
///@{
|
||||
using ppindentinfo = xo::print::APrintable::ppindentinfo;
|
||||
///@}
|
||||
/** @defgroup scm-printable-dlist-methods **/
|
||||
///@{
|
||||
/** Pretty-printing support for this object.
|
||||
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
|
||||
static bool pretty(const DList & self, const ppindentinfo & ppii);
|
||||
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -8,6 +8,7 @@ set(SELF_SRCS
|
|||
ISequence_Any.cpp
|
||||
ISequence_DList.cpp
|
||||
IPrintable_DFloat.cpp
|
||||
IPrintable_DList.cpp
|
||||
DList.cpp
|
||||
DFloat.cpp
|
||||
object2_register_types.cpp
|
||||
|
|
|
|||
|
|
@ -84,6 +84,31 @@ namespace xo {
|
|||
return l->head_;
|
||||
}
|
||||
|
||||
#ifdef NOT_YET
|
||||
bool
|
||||
DList::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
/* adapted from ppstate.pretty_struct(), see also */
|
||||
|
||||
using xo::print::ppstate;
|
||||
|
||||
ppstate * pps = ppii.pps();
|
||||
|
||||
if (ppii.upto()) {
|
||||
/* perhaps print on one line */
|
||||
if (!pps->print_upto("(")
|
||||
return false;
|
||||
|
||||
/* TODO: probably use iterators here, when available */
|
||||
const DList * l = this;
|
||||
while (!l->is_empty()) {
|
||||
obj<APrintable>(l->head_.data());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
28
src/object2/IPrintable_DList.cpp
Normal file
28
src/object2/IPrintable_DList.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/** @file IPrintable_DList.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DList.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DList.json5]
|
||||
**/
|
||||
|
||||
#include "IPrintable_DList.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IPrintable_DList::pretty(const DList & self, const ppindentinfo & ppii) -> bool
|
||||
{
|
||||
return self.pretty(ppii);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_DList.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue