xo-objectd2 xo-printable xo-facet: pp working for List(Integer)
Also streamline facet switching
This commit is contained in:
parent
9ce465e84f
commit
09ee3a20ac
23 changed files with 508 additions and 27 deletions
|
|
@ -7,10 +7,12 @@ set(SELF_SRCS
|
|||
IGCObject_DList.cpp
|
||||
ISequence_Any.cpp
|
||||
ISequence_DList.cpp
|
||||
IPrintable_DFloat.cpp
|
||||
IPrintable_DList.cpp
|
||||
IPrintable_DFloat.cpp
|
||||
IPrintable_DInteger.cpp
|
||||
DList.cpp
|
||||
DFloat.cpp
|
||||
DInteger.cpp
|
||||
object2_register_types.cpp
|
||||
)
|
||||
|
||||
|
|
|
|||
32
xo-object2/src/object2/DInteger.cpp
Normal file
32
xo-object2/src/object2/DInteger.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/** @file DInteger.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#include "DInteger.hpp"
|
||||
#include <xo/indentlog/print/pretty.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::facet::typeseq;
|
||||
using xo::print::ppdetail_atomic;
|
||||
|
||||
namespace scm {
|
||||
DInteger *
|
||||
DInteger::make(obj<AAllocator> mm,
|
||||
long x)
|
||||
{
|
||||
void * mem = mm.alloc(typeseq::id<DInteger>(),
|
||||
sizeof(DInteger));
|
||||
|
||||
return new (mem) DInteger(x);
|
||||
}
|
||||
|
||||
bool
|
||||
DInteger::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
return ppdetail_atomic<long>::print_pretty(ppii, value_);
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end DInteger.cpp */
|
||||
|
|
@ -19,18 +19,28 @@ namespace xo {
|
|||
static DList s_null(obj<AGCObject>(), nullptr);
|
||||
|
||||
DList *
|
||||
DList::null()
|
||||
DList::_nil()
|
||||
{
|
||||
return &s_null;
|
||||
}
|
||||
|
||||
DList *
|
||||
DList::_cons(obj<AAllocator> mm,
|
||||
obj<AGCObject> car,
|
||||
DList * cdr)
|
||||
{
|
||||
void * mem = mm.alloc(typeseq::id<DList>(), sizeof(DList));
|
||||
|
||||
return new (mem) DList(car, cdr);
|
||||
}
|
||||
|
||||
DList *
|
||||
DList::list(obj<AAllocator> mm,
|
||||
obj<AGCObject> h1)
|
||||
{
|
||||
void * mem = mm.alloc(typeseq::id<DList>(), sizeof(DList));
|
||||
|
||||
return new (mem) DList(h1, DList::null());
|
||||
return new (mem) DList(h1, DList::_nil());
|
||||
}
|
||||
|
||||
DList *
|
||||
|
|
@ -112,7 +122,8 @@ namespace xo {
|
|||
|
||||
obj<APrintable> elt
|
||||
= FacetRegistry::instance().variant<APrintable, AGCObject>(l->head_);
|
||||
// what if no converter registered ?
|
||||
|
||||
assert(elt);
|
||||
|
||||
if (!pps->print_upto(elt))
|
||||
return false;
|
||||
|
|
|
|||
28
xo-object2/src/object2/IPrintable_DInteger.cpp
Normal file
28
xo-object2/src/object2/IPrintable_DInteger.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/** @file IPrintable_DInteger.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IPrintable_DInteger.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IPrintable_DInteger.json5]
|
||||
**/
|
||||
|
||||
#include "IPrintable_DInteger.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IPrintable_DInteger::pretty(const DInteger & self, const ppindentinfo & ppii) -> bool
|
||||
{
|
||||
return self.pretty(ppii);
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_DInteger.cpp */
|
||||
|
|
@ -4,22 +4,36 @@
|
|||
**/
|
||||
|
||||
#include "object2_register_types.hpp"
|
||||
|
||||
#include "IGCObject_DList.hpp"
|
||||
#include "IGCObject_DFloat.hpp"
|
||||
#include "IGCObject_DInteger.hpp"
|
||||
|
||||
#include "IPrintable_DList.hpp"
|
||||
//#include "IPrintable_DFloat.hpp"
|
||||
#include "IPrintable_DInteger.hpp"
|
||||
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::print::APrintable;
|
||||
using xo::mm::AAllocator;
|
||||
using xo::mm::ACollector;
|
||||
using xo::mm::AGCObject;
|
||||
using xo::mm::IGCObject_Any;
|
||||
using xo::facet::FacetRegistry;
|
||||
using xo::facet::impl_for;
|
||||
using xo::facet::typeseq;
|
||||
using xo::scope;
|
||||
|
||||
namespace scm {
|
||||
|
||||
bool
|
||||
object2_register_types(obj<ACollector> gc)
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= gc.install_type(impl_for<AGCObject, DList>());
|
||||
|
|
@ -28,6 +42,31 @@ namespace xo {
|
|||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
object2_register_facets()
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
FacetRegistry::register_impl<AGCObject, DList>();
|
||||
FacetRegistry::register_impl<APrintable, DList>();
|
||||
|
||||
FacetRegistry::register_impl<AGCObject, DFloat>();
|
||||
// FacetRegistry::register_impl<APrintable, DFloat>();
|
||||
|
||||
FacetRegistry::register_impl<AGCObject, DInteger>();
|
||||
FacetRegistry::register_impl<APrintable, DInteger>();
|
||||
|
||||
log && log(xtag("DList.tseq", typeseq::id<DList>()));
|
||||
log && log(xtag("DFloat.tseq", typeseq::id<DFloat>()));
|
||||
log && log(xtag("DInteger.tseq", typeseq::id<DInteger>()));
|
||||
|
||||
log && log(xtag("AAllocator.tseq", typeseq::id<AAllocator>()));
|
||||
log && log(xtag("APrintable.tseq", typeseq::id<APrintable>()));
|
||||
log && log(xtag("AGCObject.tseq", typeseq::id<AGCObject>()));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue