xo-procedure2: + GCObject support for Primitive + misc
This commit is contained in:
parent
826879c517
commit
d7e2ea79b8
9 changed files with 177 additions and 1 deletions
|
|
@ -102,9 +102,9 @@ add_subdirectory(xo-alloc2) # experiment w/ facet object model
|
|||
add_subdirectory(xo-gc)
|
||||
add_subdirectory(xo-object)
|
||||
add_subdirectory(xo-object2) # experiment w/ facet object model
|
||||
add_subdirectory(xo-procedure2) # schematika procedure abstraction + runtime context (fomo)
|
||||
add_subdirectory(xo-ordinaltree)
|
||||
#
|
||||
add_subdirectory(xo-procedure2) # schematika procedure abstraction + runtime context (fomo)
|
||||
add_subdirectory(xo-tokenizer2) # schematika tokenizer (fomo)
|
||||
add_subdirectory(xo-expression2) # schematika expressions (fomo)
|
||||
add_subdirectory(xo-reader2) # schematika expression parser (fomo)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,18 @@ xo_add_genfacetimpl(
|
|||
OUTPUT_CPP_DIR src/procedure2
|
||||
)
|
||||
|
||||
# note: manual target; generated code committed to git
|
||||
xo_add_genfacetimpl(
|
||||
TARGET xo-procedure2-facetimpl-gcobject-primitive_gco_2_gco_gco
|
||||
FACET_PKG xo_gc
|
||||
FACET GCObject
|
||||
REPR Primitive_gco_2_gco_gco
|
||||
INPUT idl/IGCObject_DPrimitive_gco_2_gco_gco.json5
|
||||
OUTPUT_HPP_DIR include/xo/procedure2
|
||||
OUTPUT_IMPL_SUBDIR detail
|
||||
OUTPUT_CPP_DIR src/procedure2
|
||||
)
|
||||
|
||||
add_subdirectory(src/procedure2)
|
||||
#add_subdirectory(utest)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ include(CMakeFindDependencyMacro)
|
|||
# must coordinate with xo_dependency() calls
|
||||
# in CMakeLists.txt
|
||||
#
|
||||
find_dependency(xo_object2)
|
||||
find_dependency(xo_gc)
|
||||
find_dependency(subsys)
|
||||
|
||||
|
|
|
|||
16
xo-procedure2/idl/IGCObject_DPrimitive_gco_2_gco_gco.json5
Normal file
16
xo-procedure2/idl/IGCObject_DPrimitive_gco_2_gco_gco.json5
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
mode: "implementation",
|
||||
includes: [
|
||||
//<xo/procedure2/GCObjectConversion_DPrimitive_gco_2_gco_gco.hpp>
|
||||
"<xo/gc/GCObject.hpp>",
|
||||
"<xo/alloc2/Allocator.hpp>",
|
||||
],
|
||||
local_types: [ ],
|
||||
namespace1: "xo",
|
||||
namespace2: "scm",
|
||||
facet_idl: "idl/GCObject.json5",
|
||||
brief: "provide AGCobject interface for Primitive (gco x gco) -> gco",
|
||||
using_doxygen: true,
|
||||
repr: "DPrimitive_gco_2_gco_gco",
|
||||
doc: [ "implement AGCObject for DPrimitive (gco x gco) -> gco" ],
|
||||
}
|
||||
|
|
@ -58,6 +58,7 @@ namespace xo {
|
|||
template <typename Fn>
|
||||
class Primitive {
|
||||
public:
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using AGCObject = xo::mm::AGCObject;
|
||||
using DArray = xo::scm::DArray;
|
||||
|
|
@ -74,6 +75,13 @@ namespace xo {
|
|||
std::make_index_sequence<Traits::n_args>{});
|
||||
}
|
||||
|
||||
/** @defgroup scm-primitive-gcobject-facet **/
|
||||
///@{
|
||||
std::size_t shallow_size() const noexcept;
|
||||
Primitive * shallow_copy(obj<AAllocator> mm) const noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
|
||||
private:
|
||||
template <std::size_t... Is>
|
||||
obj<AGCObject> _apply_nocheck(obj<ARuntimeContext> rcx,
|
||||
|
|
@ -103,6 +111,31 @@ namespace xo {
|
|||
Fn fn_;
|
||||
}; /*Primitive*/
|
||||
|
||||
template <typename Fn>
|
||||
std::size_t
|
||||
Primitive<Fn>::shallow_size() const noexcept {
|
||||
return sizeof(*this);
|
||||
}
|
||||
|
||||
template <typename Fn>
|
||||
Primitive<Fn> *
|
||||
Primitive<Fn>::shallow_copy(obj<AAllocator> mm) const noexcept {
|
||||
void * mem = mm.alloc_copy((std::byte *)this);
|
||||
|
||||
if (mem) {
|
||||
return new (mem) Primitive(*this);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename Fn>
|
||||
std::size_t
|
||||
Primitive<Fn>::forward_children(obj<ACollector>) noexcept {
|
||||
// Primitive holds no GC refs (just string_view + function pointer)
|
||||
return this->shallow_size();
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
/** @file IGCObject_DPrimitive_gco_2_gco_gco.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IGCObject_DPrimitive_gco_2_gco_gco.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_repr.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IGCObject_DPrimitive_gco_2_gco_gco.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GCObject.hpp"
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include "DPrimitive_gco_2_gco_gco.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IGCObject_DPrimitive_gco_2_gco_gco; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::mm::AGCObject,
|
||||
xo::scm::DPrimitive_gco_2_gco_gco>
|
||||
{
|
||||
using ImplType = xo::mm::IGCObject_Xfer
|
||||
<xo::scm::DPrimitive_gco_2_gco_gco,
|
||||
xo::scm::IGCObject_DPrimitive_gco_2_gco_gco>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IGCObject_DPrimitive_gco_2_gco_gco
|
||||
**/
|
||||
class IGCObject_DPrimitive_gco_2_gco_gco {
|
||||
public:
|
||||
/** @defgroup scm-gcobject-dprimitive_gco_2_gco_gco-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-dprimitive_gco_2_gco_gco-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** memory consumption for this instance **/
|
||||
static size_type shallow_size(const DPrimitive_gco_2_gco_gco & self) noexcept;
|
||||
/** copy instance using allocator **/
|
||||
static Opaque shallow_copy(const DPrimitive_gco_2_gco_gco & self, obj<AAllocator> mm) noexcept;
|
||||
|
||||
// non-const methods
|
||||
/** during GC: forward immdiate children **/
|
||||
static size_type forward_children(DPrimitive_gco_2_gco_gco & self, obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -7,12 +7,19 @@
|
|||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** TODO: move this into xo-reader2 ? **/
|
||||
|
||||
#ifdef NOT_YET
|
||||
using Primitive_f64_1_f64 = Primitive<double (*)(double)>;
|
||||
using Primitive_f64_2_f64_f64 = Primitive<double (*)(double, double)>;
|
||||
#endif
|
||||
|
||||
struct Primitives {
|
||||
/** polymorphich multiply
|
||||
*
|
||||
* TODO: this will want to move to xo-numeric/
|
||||
* so we can dispatch on vector, matrix, function types
|
||||
**/
|
||||
static DPrimitive_gco_2_gco_gco s_mul_gco_gco_pm;
|
||||
|
||||
#ifdef NOT_YET
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ set(SELF_SRCS
|
|||
DPrimitive.cpp
|
||||
IRuntimeContext_Any.cpp
|
||||
IProcedure_Any.cpp
|
||||
IGCObject_DPrimitive_gco_2_gco_gco.cpp
|
||||
IProcedure_DPrimitive_gco_2_gco_gco.cpp
|
||||
# Add source files here, e.g.:
|
||||
# procedure2.cpp
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
/** @file IGCObject_DPrimitive_gco_2_gco_gco.cpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/IGCObject_DPrimitive_gco_2_gco_gco.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/IGCObject_DPrimitive_gco_2_gco_gco.json5]
|
||||
**/
|
||||
|
||||
#include "detail/IGCObject_DPrimitive_gco_2_gco_gco.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DPrimitive_gco_2_gco_gco::shallow_size(const DPrimitive_gco_2_gco_gco & self) noexcept -> size_type
|
||||
{
|
||||
return self.shallow_size();
|
||||
}
|
||||
|
||||
auto
|
||||
IGCObject_DPrimitive_gco_2_gco_gco::shallow_copy(const DPrimitive_gco_2_gco_gco & self, obj<AAllocator> mm) noexcept -> Opaque
|
||||
{
|
||||
return self.shallow_copy(mm);
|
||||
}
|
||||
|
||||
auto
|
||||
IGCObject_DPrimitive_gco_2_gco_gco::forward_children(DPrimitive_gco_2_gco_gco & self, obj<ACollector> gc) noexcept -> size_type
|
||||
{
|
||||
return self.forward_children(gc);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IGCObject_DPrimitive_gco_2_gco_gco.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue