xo-object2: tidy IGCObject_DInteger + codegen
This commit is contained in:
parent
e5a4906ec7
commit
9da8217df0
10 changed files with 152 additions and 77 deletions
|
|
@ -88,6 +88,18 @@ xo_add_genfacetimpl(
|
|||
OUTPUT_CPP_DIR src/object2
|
||||
)
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-object2-facetimpl-gcobject-integer
|
||||
FACET_PKG xo_gc
|
||||
FACET GCObject
|
||||
REPR Integer
|
||||
INPUT idl/IGCObject_DInteger.json5
|
||||
OUTPUT_HPP_DIR include/xo/object2
|
||||
OUTPUT_IMPL_SUBDIR number
|
||||
OUTPUT_CPP_DIR src/object2
|
||||
)
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-object2-facetimpl-printable-string
|
||||
|
|
|
|||
15
xo-object2/idl/IGCObject_DInteger.json5
Normal file
15
xo-object2/idl/IGCObject_DInteger.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 DInteger",
|
||||
using_doxygen: true,
|
||||
repr: "DInteger",
|
||||
doc: [ "implement AGCObject for DInteger" ],
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <xo/gc/Collector.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/indentlog/print/ppindentinfo.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
|
|
@ -14,6 +15,7 @@ namespace xo {
|
|||
namespace scm {
|
||||
struct DInteger {
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using ppindentinfo = xo::print::ppindentinfo;
|
||||
using value_type = long;
|
||||
|
||||
|
|
@ -32,6 +34,12 @@ namespace xo {
|
|||
|
||||
operator long() const noexcept { return value_; }
|
||||
|
||||
// GCObject facet
|
||||
|
||||
std::size_t shallow_size() const noexcept;
|
||||
DInteger * shallow_copy(obj<AAllocator> mm) const noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
|
||||
private:
|
||||
/** boxed integer value **/
|
||||
long value_;
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
/** @file IGCObject_DInteger.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <xo/gc/Collector.hpp>
|
||||
#include "xo/alloc2/alloc/AAllocator.hpp"
|
||||
#include <xo/gc/detail/AGCObject.hpp>
|
||||
#include <xo/gc/detail/IGCObject_Xfer.hpp>
|
||||
#include "DInteger.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm { struct IGCObject_DInteger; }
|
||||
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::mm::AGCObject,
|
||||
xo::scm::DInteger>
|
||||
{
|
||||
using ImplType = xo::mm::IGCObject_Xfer
|
||||
<xo::scm::DInteger,
|
||||
xo::scm::IGCObject_DInteger>;
|
||||
};
|
||||
}
|
||||
|
||||
namespace scm {
|
||||
/* changes here coordinate with:
|
||||
* IGCObject_Xfer
|
||||
*/
|
||||
struct IGCObject_DInteger {
|
||||
public:
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using size_type = std::size_t;
|
||||
|
||||
static size_type shallow_size(const DInteger & d) noexcept;
|
||||
static DInteger * shallow_copy(const DInteger & d, obj<AAllocator> mm) noexcept;
|
||||
static size_type forward_children(DInteger & d, obj<ACollector> gc) noexcept;
|
||||
};
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IGCObject_DInteger.hpp */
|
||||
67
xo-object2/include/xo/object2/number/IGCObject_DInteger.hpp
Normal file
67
xo-object2/include/xo/object2/number/IGCObject_DInteger.hpp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/** @file IGCObject_DInteger.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IGCObject_DInteger.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IGCObject_DInteger.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GCObject.hpp"
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include "DInteger.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IGCObject_DInteger; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::mm::AGCObject,
|
||||
xo::scm::DInteger>
|
||||
{
|
||||
using ImplType = xo::mm::IGCObject_Xfer
|
||||
<xo::scm::DInteger,
|
||||
xo::scm::IGCObject_DInteger>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IGCObject_DInteger
|
||||
**/
|
||||
class IGCObject_DInteger {
|
||||
public:
|
||||
/** @defgroup scm-gcobject-dinteger-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-dinteger-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** memory consumption for this instance **/
|
||||
static size_type shallow_size(const DInteger & self) noexcept;
|
||||
/** copy instance using allocator **/
|
||||
static Opaque shallow_copy(const DInteger & self, obj<AAllocator> mm) noexcept;
|
||||
|
||||
// non-const methods
|
||||
/** during GC: forward immdiate children **/
|
||||
static size_type forward_children(DInteger & self, obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -26,6 +26,31 @@ namespace xo {
|
|||
{
|
||||
return ppdetail_atomic<long>::print_pretty(ppii, value_);
|
||||
}
|
||||
|
||||
size_t
|
||||
DInteger::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(DInteger);
|
||||
}
|
||||
|
||||
DInteger *
|
||||
DInteger::shallow_copy(obj<AAllocator> mm) const noexcept
|
||||
{
|
||||
DInteger * copy = (DInteger *)mm.alloc_copy((std::byte *)this);
|
||||
|
||||
if (copy)
|
||||
*copy = *this;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
size_t
|
||||
DInteger::forward_children(obj<ACollector>) noexcept
|
||||
{
|
||||
return shallow_size();
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,46 +1,39 @@
|
|||
/** @file IGCObject_DInteger.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_DInteger.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IGCObject_DInteger.json5]
|
||||
**/
|
||||
|
||||
#include "IGCObject_DInteger.hpp"
|
||||
#include "xo/alloc2/alloc/AAllocator.hpp"
|
||||
#include "xo/facet/obj.hpp"
|
||||
#include <cstddef>
|
||||
#include "number/IGCObject_DInteger.hpp"
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::AAllocator;
|
||||
using xo::facet::obj;
|
||||
using xo::facet::typeseq;
|
||||
using std::size_t;
|
||||
|
||||
namespace scm {
|
||||
size_t
|
||||
IGCObject_DInteger::shallow_size(const DInteger &) noexcept
|
||||
auto
|
||||
IGCObject_DInteger::shallow_size(const DInteger & self) noexcept -> size_type
|
||||
{
|
||||
return sizeof(DInteger);
|
||||
return self.shallow_size();
|
||||
}
|
||||
|
||||
DInteger *
|
||||
IGCObject_DInteger::shallow_copy(const DInteger & src,
|
||||
obj<AAllocator> mm) noexcept
|
||||
auto
|
||||
IGCObject_DInteger::shallow_copy(const DInteger & self, obj<AAllocator> mm) noexcept -> Opaque
|
||||
{
|
||||
DInteger * copy = (DInteger *)mm.alloc_copy((std::byte *)&src);
|
||||
|
||||
if (copy)
|
||||
*copy = src;
|
||||
|
||||
return copy;
|
||||
return self.shallow_copy(mm);
|
||||
}
|
||||
|
||||
size_t
|
||||
IGCObject_DInteger::forward_children(DInteger & src,
|
||||
obj<ACollector>) noexcept
|
||||
auto
|
||||
IGCObject_DInteger::forward_children(DInteger & self, obj<ACollector> gc) noexcept -> size_type
|
||||
{
|
||||
return shallow_size(src);
|
||||
return self.forward_children(gc);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IGCObject_DInteger.cpp */
|
||||
/* end IGCObject_DInteger.cpp */
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <xo/object2/list/IGCObject_DList.hpp>
|
||||
#include <xo/object2/number/IGCObject_DFloat.hpp>
|
||||
#include <xo/object2/IGCObject_DInteger.hpp>
|
||||
#include <xo/object2/number/IGCObject_DInteger.hpp>
|
||||
#include <xo/object2/string/IGCObject_DString.hpp>
|
||||
|
||||
#include <xo/object2/list/IPrintable_DList.hpp>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "list/IGCObject_DList.hpp"
|
||||
#include "number/IGCObject_DFloat.hpp"
|
||||
#include "IGCObject_DInteger.hpp"
|
||||
#include "number/IGCObject_DInteger.hpp"
|
||||
#include "string/IGCObject_DString.hpp"
|
||||
|
||||
#include "list/IPrintable_DList.hpp"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#include <xo/object2/string/IPrintable_DString.hpp>
|
||||
|
||||
#include <xo/object2/DInteger.hpp>
|
||||
#include <xo/object2/IGCObject_DInteger.hpp>
|
||||
#include <xo/object2/number/IGCObject_DInteger.hpp>
|
||||
|
||||
#include <xo/gc/Collector.hpp>
|
||||
#include <xo/gc/DX1Collector.hpp>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue