xo-object2: type registration + gc fixes
This commit is contained in:
parent
4af2cd0401
commit
99108b8dbb
16 changed files with 285 additions and 17 deletions
|
|
@ -8,6 +8,7 @@ set(SELF_SRCS
|
|||
ISequence_Any.cpp
|
||||
ISequence_DList.cpp
|
||||
DList.cpp
|
||||
object2_register_types.cpp
|
||||
)
|
||||
|
||||
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})
|
||||
|
|
|
|||
|
|
@ -7,7 +7,42 @@
|
|||
#include <xo/indentlog/print/tag.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::AGCObject;
|
||||
|
||||
namespace scm {
|
||||
static DList s_null(obj<AGCObject>(), nullptr);
|
||||
|
||||
DList *
|
||||
DList::null()
|
||||
{
|
||||
return &s_null;
|
||||
}
|
||||
|
||||
DList *
|
||||
DList::list(obj<AAllocator> mm,
|
||||
obj<AGCObject> h1)
|
||||
{
|
||||
void * mem = mm.alloc(sizeof(DList));
|
||||
|
||||
return new (mem) DList(h1, DList::null());
|
||||
}
|
||||
|
||||
DList *
|
||||
DList::list(obj<AAllocator> mm,
|
||||
obj<AGCObject> h1,
|
||||
obj<AGCObject> h2)
|
||||
{
|
||||
void * mem = mm.alloc(sizeof(DList));
|
||||
|
||||
return new (mem) DList(h1, DList::list(mm, h2));
|
||||
}
|
||||
|
||||
bool
|
||||
DList::is_empty() const noexcept
|
||||
{
|
||||
return this != &s_null;
|
||||
}
|
||||
|
||||
auto
|
||||
DList::size() const noexcept -> size_type
|
||||
{
|
||||
|
|
@ -15,7 +50,7 @@ namespace xo {
|
|||
|
||||
size_type z = 0;
|
||||
|
||||
while (l) {
|
||||
while (l && l != &s_null) {
|
||||
++z;
|
||||
l = l->rest_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@ namespace xo {
|
|||
}
|
||||
|
||||
size_t
|
||||
IGCObject_DFloat::forward_children(DFloat &) noexcept
|
||||
IGCObject_DFloat::forward_children(DFloat & src,
|
||||
obj<ACollector>) noexcept
|
||||
{
|
||||
return sizeof(DFloat);
|
||||
return shallow_size(src);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@ namespace xo {
|
|||
}
|
||||
|
||||
size_t
|
||||
IGCObject_DInteger::forward_children(DInteger &) noexcept
|
||||
IGCObject_DInteger::forward_children(DInteger & src,
|
||||
obj<ACollector>) noexcept
|
||||
{
|
||||
return sizeof(DInteger);
|
||||
return shallow_size(src);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ namespace xo {
|
|||
{
|
||||
gc.forward_inplace(src.head_.iface(), (void **)&(src.head_.data_));
|
||||
|
||||
//auto rest = with_facet<AGCObject>::mkobj(src.rest_);
|
||||
xo::facet::FacetImplementation<xo::mm::AGCObject, DList>::ImplType iface;
|
||||
auto iface = xo::facet::impl_for<AGCObject, DList>();
|
||||
gc.forward_inplace(&iface, (void **)(&src.rest_));
|
||||
|
||||
return shallow_size(src);
|
||||
|
|
|
|||
34
src/object2/object2_register_types.cpp
Normal file
34
src/object2/object2_register_types.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/** @file object2_register_types.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#include "object2_register_types.hpp"
|
||||
#include "IGCObject_DList.hpp"
|
||||
#include "IGCObject_DFloat.hpp"
|
||||
#include "IGCObject_DInteger.hpp"
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::ACollector;
|
||||
using xo::mm::AGCObject;
|
||||
using xo::mm::IGCObject_Any;
|
||||
using xo::facet::impl_for;
|
||||
using xo::facet::typeseq;
|
||||
|
||||
namespace scm {
|
||||
|
||||
bool
|
||||
object2_register_types(obj<ACollector> gc)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
ok &= gc.install_type(impl_for<AGCObject, DList>());
|
||||
|
||||
ok &= gc.install_type(impl_for<AGCObject, DFloat>());
|
||||
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end object2_register_types.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue