xo-object2: tidy IGCObject_DList
This commit is contained in:
parent
a3b4853f55
commit
51126ae718
12 changed files with 159 additions and 89 deletions
|
|
@ -52,6 +52,18 @@ xo_add_genfacetimpl(
|
||||||
OUTPUT_CPP_DIR src/object2
|
OUTPUT_CPP_DIR src/object2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# note: manual target; generated code committed to git
|
||||||
|
xo_add_genfacetimpl(
|
||||||
|
TARGET xo-object2-facetimpl-gcobject-list
|
||||||
|
FACET_PKG xo_gc
|
||||||
|
FACET GCObject
|
||||||
|
REPR List
|
||||||
|
INPUT idl/IGCObject_DList.json5
|
||||||
|
OUTPUT_HPP_DIR include/xo/object2
|
||||||
|
OUTPUT_IMPL_SUBDIR list
|
||||||
|
OUTPUT_CPP_DIR src/object2
|
||||||
|
)
|
||||||
|
|
||||||
# note: manual target; generated code committed to git
|
# note: manual target; generated code committed to git
|
||||||
xo_add_genfacetimpl(
|
xo_add_genfacetimpl(
|
||||||
TARGET xo-object2-facetimpl-printable-float
|
TARGET xo-object2-facetimpl-printable-float
|
||||||
|
|
|
||||||
15
xo-object2/idl/IGCObject_DList.json5
Normal file
15
xo-object2/idl/IGCObject_DList.json5
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
mode: "implementation",
|
||||||
|
includes: [
|
||||||
|
// "<xo/gc/GCObject.hpp>",
|
||||||
|
// "<xo/alloc2/Allocator.hpp>"
|
||||||
|
],
|
||||||
|
local_types: [ ],
|
||||||
|
namespace1: "xo",
|
||||||
|
namespace2: "scm",
|
||||||
|
facet_idl: "idl/GCObject.json5",
|
||||||
|
brief: "provide AGCObject interface for DList",
|
||||||
|
using_doxygen: true,
|
||||||
|
repr: "DList",
|
||||||
|
doc: [ "implement AGCObject for DList" ],
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,7 @@ namespace xo {
|
||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
using AGCObject = xo::mm::AGCObject;
|
using AGCObject = xo::mm::AGCObject;
|
||||||
using AAllocator = xo::mm::AAllocator;
|
using AAllocator = xo::mm::AAllocator;
|
||||||
|
using ACollector = xo::mm::ACollector;
|
||||||
using ppindentinfo = xo::print::ppindentinfo;
|
using ppindentinfo = xo::print::ppindentinfo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -51,6 +52,12 @@ namespace xo {
|
||||||
/** pretty-printing driver; combine layout+printing **/
|
/** pretty-printing driver; combine layout+printing **/
|
||||||
bool pretty(const ppindentinfo & ppii) const;
|
bool pretty(const ppindentinfo & ppii) const;
|
||||||
|
|
||||||
|
// GCObject facet
|
||||||
|
|
||||||
|
size_type shallow_size() const noexcept;
|
||||||
|
DList * shallow_copy(obj<AAllocator> mm) const noexcept;
|
||||||
|
size_type forward_children(obj<ACollector> gc) noexcept;
|
||||||
|
|
||||||
/** first member of list **/
|
/** first member of list **/
|
||||||
obj<AGCObject> head_;
|
obj<AGCObject> head_;
|
||||||
/** remainder of list **/
|
/** remainder of list **/
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
/** @file IGCObject_DList.hpp
|
|
||||||
*
|
|
||||||
* @author Roland Conybeare, Dec 2025
|
|
||||||
**/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <xo/alloc2/Allocator.hpp>
|
|
||||||
#include <xo/gc/Collector.hpp>
|
|
||||||
#include <xo/gc/detail/AGCObject.hpp>
|
|
||||||
#include <xo/gc/detail/IGCObject_Xfer.hpp>
|
|
||||||
//#include "DList.hpp" // circular
|
|
||||||
|
|
||||||
namespace xo {
|
|
||||||
namespace scm { struct IGCObject_DList; }
|
|
||||||
namespace scm { struct DList; }
|
|
||||||
|
|
||||||
namespace facet {
|
|
||||||
template <>
|
|
||||||
struct FacetImplementation<xo::mm::AGCObject,
|
|
||||||
xo::scm::DList>
|
|
||||||
{
|
|
||||||
using ImplType = xo::mm::IGCObject_Xfer
|
|
||||||
<xo::scm::DList,
|
|
||||||
xo::scm::IGCObject_DList>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace scm {
|
|
||||||
/* changes here coordinate with:
|
|
||||||
* IGCObject_XFer
|
|
||||||
*/
|
|
||||||
struct IGCObject_DList {
|
|
||||||
public:
|
|
||||||
using AAllocator = xo::mm::AAllocator;
|
|
||||||
using ACollector = xo::mm::ACollector;
|
|
||||||
using size_type = std::size_t;
|
|
||||||
|
|
||||||
static size_type shallow_size(const DList & d) noexcept;
|
|
||||||
static DList * shallow_copy(const DList & d, obj<AAllocator> mm) noexcept;
|
|
||||||
static size_type forward_children(DList & d, obj<ACollector> gc) noexcept;
|
|
||||||
};
|
|
||||||
|
|
||||||
} /*namespace scm*/
|
|
||||||
} /*namespace xo*/
|
|
||||||
|
|
||||||
/* end IGCObject_DList.hpp */
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "IGCObject_DList.hpp"
|
#include "list/IGCObject_DList.hpp"
|
||||||
#include "DList.hpp"
|
#include "DList.hpp"
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
|
||||||
65
xo-object2/include/xo/object2/list/IGCObject_DList.hpp
Normal file
65
xo-object2/include/xo/object2/list/IGCObject_DList.hpp
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
/** @file IGCObject_DList.hpp
|
||||||
|
*
|
||||||
|
* Generated automagically from ingredients:
|
||||||
|
* 1. code generator:
|
||||||
|
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||||
|
* arguments:
|
||||||
|
* --input [idl/IGCObject_DList.json5]
|
||||||
|
* 2. jinja2 template for abstract facet .hpp file:
|
||||||
|
* [iface_facet_repr.hpp.j2]
|
||||||
|
* 3. idl for facet methods
|
||||||
|
* [idl/IGCObject_DList.json5]
|
||||||
|
**/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GCObject.hpp"
|
||||||
|
#include "DList.hpp"
|
||||||
|
|
||||||
|
namespace xo { namespace scm { class IGCObject_DList; } }
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace facet {
|
||||||
|
template <>
|
||||||
|
struct FacetImplementation<xo::mm::AGCObject,
|
||||||
|
xo::scm::DList>
|
||||||
|
{
|
||||||
|
using ImplType = xo::mm::IGCObject_Xfer
|
||||||
|
<xo::scm::DList,
|
||||||
|
xo::scm::IGCObject_DList>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace scm {
|
||||||
|
/** @class IGCObject_DList
|
||||||
|
**/
|
||||||
|
class IGCObject_DList {
|
||||||
|
public:
|
||||||
|
/** @defgroup scm-gcobject-dlist-type-traits **/
|
||||||
|
///@{
|
||||||
|
using size_type = xo::mm::AGCObject::size_type;
|
||||||
|
using AAllocator = xo::mm::AGCObject::AAllocator;
|
||||||
|
using ACollector = xo::mm::AGCObject::ACollector;
|
||||||
|
using Copaque = xo::mm::AGCObject::Copaque;
|
||||||
|
using Opaque = xo::mm::AGCObject::Opaque;
|
||||||
|
///@}
|
||||||
|
/** @defgroup scm-gcobject-dlist-methods **/
|
||||||
|
///@{
|
||||||
|
// const methods
|
||||||
|
/** memory consumption for this instance **/
|
||||||
|
static size_type shallow_size(const DList & self) noexcept;
|
||||||
|
/** copy instance using allocator **/
|
||||||
|
static Opaque shallow_copy(const DList & self, obj<AAllocator> mm) noexcept;
|
||||||
|
|
||||||
|
// non-const methods
|
||||||
|
/** during GC: forward immdiate children **/
|
||||||
|
static size_type forward_children(DList & self, obj<ACollector> gc) noexcept;
|
||||||
|
///@}
|
||||||
|
};
|
||||||
|
|
||||||
|
} /*namespace scm*/
|
||||||
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
/* end */
|
||||||
|
|
@ -5,9 +5,11 @@
|
||||||
|
|
||||||
#include "DList.hpp"
|
#include "DList.hpp"
|
||||||
#include "list/IPrintable_DList.hpp"
|
#include "list/IPrintable_DList.hpp"
|
||||||
|
#include "list/IGCObject_DList.hpp"
|
||||||
#include <xo/gc/GCObject.hpp>
|
#include <xo/gc/GCObject.hpp>
|
||||||
#include <xo/printable2/Printable.hpp>
|
#include <xo/printable2/Printable.hpp>
|
||||||
#include <xo/facet/FacetRegistry.hpp>
|
#include <xo/facet/FacetRegistry.hpp>
|
||||||
|
#include <xo/facet/facet_implementation.hpp>
|
||||||
#include <xo/indentlog/print/pretty.hpp>
|
#include <xo/indentlog/print/pretty.hpp>
|
||||||
#include <xo/indentlog/print/tag.hpp>
|
#include <xo/indentlog/print/tag.hpp>
|
||||||
|
|
||||||
|
|
@ -145,6 +147,36 @@ namespace xo {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto
|
||||||
|
DList::shallow_size() const noexcept -> size_type
|
||||||
|
{
|
||||||
|
return sizeof(DList);
|
||||||
|
}
|
||||||
|
|
||||||
|
DList *
|
||||||
|
DList::shallow_copy(obj<AAllocator> mm) const noexcept
|
||||||
|
{
|
||||||
|
DList * copy = (DList *)mm.alloc_copy((std::byte *)this);
|
||||||
|
|
||||||
|
if (copy)
|
||||||
|
*copy = *this;
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto
|
||||||
|
DList::forward_children(obj<ACollector> gc) noexcept -> size_type
|
||||||
|
{
|
||||||
|
scope log(XO_DEBUG(true));
|
||||||
|
|
||||||
|
gc.forward_inplace(head_.iface(), (void **)&(head_.data_));
|
||||||
|
|
||||||
|
auto iface = xo::facet::impl_for<AGCObject,DList>();
|
||||||
|
gc.forward_inplace(&iface, (void **)(&rest_));
|
||||||
|
|
||||||
|
return shallow_size();
|
||||||
|
}
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,53 +1,39 @@
|
||||||
/** @file IGCObject_DList.cpp
|
/** @file IGCObject_DList.cpp
|
||||||
*
|
*
|
||||||
* @author Roland Conybeare, Dec 2025
|
* Generated automagically from ingredients:
|
||||||
**/
|
* 1. code generator:
|
||||||
|
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||||
|
* arguments:
|
||||||
|
* --input [idl/IGCObject_DList.json5]
|
||||||
|
* 2. jinja2 template for abstract facet .hpp file:
|
||||||
|
* [iface_facet_any.hpp.j2]
|
||||||
|
* 3. idl for facet methods
|
||||||
|
* [idl/IGCObject_DList.json5]
|
||||||
|
**/
|
||||||
|
|
||||||
#include "IGCObject_DList.hpp"
|
#include "list/IGCObject_DList.hpp"
|
||||||
#include "DList.hpp"
|
|
||||||
#include <xo/indentlog/scope.hpp>
|
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
using xo::mm::AGCObject;
|
|
||||||
using xo::mm::AAllocator;
|
|
||||||
//using xo::facet::with_facet;
|
|
||||||
using xo::facet::obj;
|
|
||||||
using xo::facet::typeseq;
|
|
||||||
using std::size_t;
|
|
||||||
|
|
||||||
namespace scm {
|
namespace scm {
|
||||||
size_t
|
auto
|
||||||
IGCObject_DList::shallow_size(const DList &) noexcept
|
IGCObject_DList::shallow_size(const DList & self) noexcept -> size_type
|
||||||
{
|
{
|
||||||
return sizeof(DList);
|
return self.shallow_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
DList *
|
auto
|
||||||
IGCObject_DList::shallow_copy(const DList & src,
|
IGCObject_DList::shallow_copy(const DList & self, obj<AAllocator> mm) noexcept -> Opaque
|
||||||
obj<AAllocator> mm) noexcept
|
|
||||||
{
|
{
|
||||||
DList * copy = (DList *)mm.alloc_copy((std::byte *)&src);
|
return self.shallow_copy(mm);
|
||||||
|
|
||||||
if (copy)
|
|
||||||
*copy = src;
|
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
auto
|
||||||
IGCObject_DList::forward_children(DList & src,
|
IGCObject_DList::forward_children(DList & self, obj<ACollector> gc) noexcept -> size_type
|
||||||
obj<ACollector> gc) noexcept
|
|
||||||
{
|
{
|
||||||
scope log(XO_DEBUG(true));
|
return self.forward_children(gc);
|
||||||
|
|
||||||
gc.forward_inplace(src.head_.iface(), (void **)&(src.head_.data_));
|
|
||||||
|
|
||||||
auto iface = xo::facet::impl_for<AGCObject, DList>();
|
|
||||||
gc.forward_inplace(&iface, (void **)(&src.rest_));
|
|
||||||
|
|
||||||
return shallow_size(src);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
||||||
/* end IGCObject_DList.cpp */
|
/* end IGCObject_DList.cpp */
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "object2_register_facets.hpp"
|
#include "object2_register_facets.hpp"
|
||||||
|
|
||||||
#include <xo/object2/IGCObject_DList.hpp>
|
#include <xo/object2/list/IGCObject_DList.hpp>
|
||||||
#include <xo/object2/IGCObject_DFloat.hpp>
|
#include <xo/object2/IGCObject_DFloat.hpp>
|
||||||
#include <xo/object2/IGCObject_DInteger.hpp>
|
#include <xo/object2/IGCObject_DInteger.hpp>
|
||||||
#include <xo/object2/string/IGCObject_DString.hpp>
|
#include <xo/object2/string/IGCObject_DString.hpp>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "object2_register_types.hpp"
|
#include "object2_register_types.hpp"
|
||||||
|
|
||||||
#include "IGCObject_DList.hpp"
|
#include "list/IGCObject_DList.hpp"
|
||||||
#include "IGCObject_DFloat.hpp"
|
#include "IGCObject_DFloat.hpp"
|
||||||
#include "IGCObject_DInteger.hpp"
|
#include "IGCObject_DInteger.hpp"
|
||||||
#include "string/IGCObject_DString.hpp"
|
#include "string/IGCObject_DString.hpp"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include "object2_register_facets.hpp"
|
#include "object2_register_facets.hpp"
|
||||||
|
|
||||||
#include <xo/object2/DList.hpp>
|
#include <xo/object2/DList.hpp>
|
||||||
#include <xo/object2/IGCObject_DList.hpp>
|
#include <xo/object2/list/IGCObject_DList.hpp>
|
||||||
#include <xo/object2/list/IPrintable_DList.hpp>
|
#include <xo/object2/list/IPrintable_DList.hpp>
|
||||||
|
|
||||||
#include <xo/object2/DString.hpp>
|
#include <xo/object2/DString.hpp>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include "object2_register_types.hpp"
|
#include "object2_register_types.hpp"
|
||||||
|
|
||||||
#include "IGCObject_DFloat.hpp"
|
#include "IGCObject_DFloat.hpp"
|
||||||
#include "IGCObject_DList.hpp"
|
#include "list/IGCObject_DList.hpp"
|
||||||
|
|
||||||
#include <xo/gc/Collector.hpp>
|
#include <xo/gc/Collector.hpp>
|
||||||
#include <xo/gc/DX1Collector.hpp>
|
#include <xo/gc/DX1Collector.hpp>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue