xo-alloc2 xo-object2 : refactor to build on osx
This commit is contained in:
parent
c7486ba674
commit
cbf6abb539
16 changed files with 182 additions and 100 deletions
|
|
@ -6,7 +6,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
//#include "xo/alloc2/gcobject/RGCObject.hpp"
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/indentlog/print/ppindentinfo.hpp>
|
||||
|
||||
|
|
@ -14,6 +13,8 @@ namespace xo {
|
|||
namespace scm {
|
||||
|
||||
// TODO: consider renaming to DCons
|
||||
// See also ListOps in ListOps.hpp
|
||||
//
|
||||
struct DList {
|
||||
using size_type = std::size_t;
|
||||
using AGCObject = xo::mm::AGCObject;
|
||||
|
|
@ -23,28 +24,6 @@ namespace xo {
|
|||
DList(xo::obj<AGCObject> h,
|
||||
DList * r) : head_{h}, rest_{r} {}
|
||||
|
||||
template <typename AConsFacet = AGCObject>
|
||||
static obj<AConsFacet,DList> nil();
|
||||
|
||||
/** shortcut for
|
||||
* cons(mm, cdr, cdr.data())
|
||||
**/
|
||||
template <typename AConsFacet = AGCObject, typename ACdrFacet = AGCObject>
|
||||
static obj<AConsFacet,DList> cons(obj<AAllocator> mm,
|
||||
obj<AGCObject> car,
|
||||
obj<ACdrFacet,DList> cdr);
|
||||
|
||||
/** list with one element @p e1, allocated from @p mm **/
|
||||
template <typename AListFacet = AGCObject>
|
||||
static obj<AListFacet,DList> list(obj<AAllocator> mm,
|
||||
obj<AGCObject> e1);
|
||||
|
||||
/** list with two element @p e1, @p e2, allocated from @p mm **/
|
||||
template <typename AListFacet = AGCObject>
|
||||
static obj<AListFacet,DList> list(obj<AAllocator> mm,
|
||||
obj<AGCObject> e1,
|
||||
obj<AGCObject> e2);
|
||||
|
||||
/** sentinel for null list **/
|
||||
static DList * _nil();
|
||||
|
||||
|
|
@ -84,39 +63,6 @@ namespace xo {
|
|||
DList * rest_ = nullptr;
|
||||
};
|
||||
|
||||
template <typename AConsFacet>
|
||||
obj<AConsFacet,DList>
|
||||
DList::nil()
|
||||
{
|
||||
return obj<AConsFacet,DList>(DList::_nil());
|
||||
}
|
||||
|
||||
template <typename AConsFacet, typename ACdrFacet>
|
||||
obj<AConsFacet,DList>
|
||||
DList::cons(obj<AAllocator> mm,
|
||||
obj<AGCObject> car,
|
||||
obj<ACdrFacet,DList> cdr)
|
||||
{
|
||||
return obj<AConsFacet,DList>(DList::_cons(mm, car, cdr.data()));
|
||||
}
|
||||
|
||||
template <typename AListFacet>
|
||||
obj<AListFacet,DList>
|
||||
DList::list(obj<AAllocator> mm,
|
||||
obj<AGCObject> e1)
|
||||
{
|
||||
return cons(mm, e1, nil());
|
||||
}
|
||||
|
||||
template <typename AListFacet>
|
||||
obj<AListFacet,DList>
|
||||
DList::list(obj<AAllocator> mm,
|
||||
obj<AGCObject> e1,
|
||||
obj<AGCObject> e2)
|
||||
{
|
||||
return cons(mm, e1, list(mm, e2));
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@
|
|||
#include <xo/gc/Collector.hpp>
|
||||
#include <xo/gc/detail/AGCObject.hpp>
|
||||
#include <xo/gc/detail/IGCObject_Xfer.hpp>
|
||||
#include "DList.hpp"
|
||||
//#include "DList.hpp" // circular
|
||||
|
||||
namespace xo {
|
||||
namespace scm { struct IGCObject_DList; }
|
||||
namespace scm { struct DList; }
|
||||
|
||||
namespace facet {
|
||||
template <>
|
||||
|
|
|
|||
84
xo-object2/include/xo/object2/ListOps.hpp
Normal file
84
xo-object2/include/xo/object2/ListOps.hpp
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/** @file ListOps.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "IGCObject_DList.hpp"
|
||||
#include "DList.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @brief list functions
|
||||
*
|
||||
* note: separate from DList, to avoid problems with deps needed
|
||||
* to compile functions that return obj<AGCObject,DList>
|
||||
**/
|
||||
struct ListOps {
|
||||
using AGCObject = xo::mm::AGCObject;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
|
||||
template <typename AConsFacet = AGCObject>
|
||||
static obj<AConsFacet,DList> nil();
|
||||
|
||||
/** shortcut for
|
||||
* cons(mm, cdr, cdr.data())
|
||||
**/
|
||||
template <typename AConsFacet = AGCObject, typename ACdrFacet = AGCObject>
|
||||
static obj<AConsFacet,DList> cons(obj<AAllocator> mm,
|
||||
obj<AGCObject> car,
|
||||
obj<ACdrFacet,DList> cdr);
|
||||
|
||||
/** list with one element @p e1, allocated from @p mm **/
|
||||
template <typename AListFacet = AGCObject>
|
||||
static obj<AListFacet,DList> list(obj<AAllocator> mm,
|
||||
obj<AGCObject> e1);
|
||||
|
||||
/** list with two element @p e1, @p e2, allocated from @p mm **/
|
||||
template <typename AListFacet = AGCObject>
|
||||
static obj<AListFacet,DList> list(obj<AAllocator> mm,
|
||||
obj<AGCObject> e1,
|
||||
obj<AGCObject> e2);
|
||||
|
||||
};
|
||||
|
||||
template <typename AConsFacet>
|
||||
obj<AConsFacet,DList>
|
||||
ListOps::nil()
|
||||
{
|
||||
return obj<AConsFacet,DList>(DList::_nil());
|
||||
}
|
||||
|
||||
template <typename AConsFacet, typename ACdrFacet>
|
||||
obj<AConsFacet,DList>
|
||||
ListOps::cons(obj<AAllocator> mm,
|
||||
obj<AGCObject> car,
|
||||
obj<ACdrFacet,DList> cdr)
|
||||
{
|
||||
return obj<AConsFacet,DList>(DList::_cons(mm, car, cdr.data()));
|
||||
}
|
||||
|
||||
template <typename AListFacet>
|
||||
obj<AListFacet,DList>
|
||||
ListOps::list(obj<AAllocator> mm,
|
||||
obj<AGCObject> e1)
|
||||
{
|
||||
// clang 15 doesn't like nil() here.
|
||||
|
||||
return cons(mm, e1, nil());
|
||||
}
|
||||
|
||||
template <typename AListFacet>
|
||||
obj<AListFacet,DList>
|
||||
ListOps::list(obj<AAllocator> mm,
|
||||
obj<AGCObject> e1,
|
||||
obj<AGCObject> e2)
|
||||
{
|
||||
return cons(mm, e1, list(mm, e2));
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end ListOps.hpp */
|
||||
17
xo-object2/include/xo/object2/object2_register_facets.hpp
Normal file
17
xo-object2/include/xo/object2/object2_register_facets.hpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/** @file object2_register_facets.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Jan 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <xo/gc/Collector.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** Register object2 (facet,impl) combinations with FacetRegistry **/
|
||||
bool object2_register_facets();
|
||||
}
|
||||
}
|
||||
|
||||
/* end object2_register_facets.hpp */
|
||||
|
|
@ -9,13 +9,8 @@
|
|||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** Register all object2/ gc-aware types with @p gc.
|
||||
* Return true iff all types register successfully.
|
||||
**/
|
||||
bool object2_register_types(obj<xo::mm::ACollector> gc);
|
||||
|
||||
/** Register object2 (facet,impl) combinations with FacetRegistry **/
|
||||
bool object2_register_facets();
|
||||
bool object2_register_types(obj<xo::mm::ACollector> gc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue