diff --git a/CMakeLists.txt b/CMakeLists.txt index a0e0b1df..592bf697 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/xo-procedure2/CMakeLists.txt b/xo-procedure2/CMakeLists.txt index acb0bad9..be7909a5 100644 --- a/xo-procedure2/CMakeLists.txt +++ b/xo-procedure2/CMakeLists.txt @@ -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) diff --git a/xo-procedure2/cmake/xo_procedure2Config.cmake.in b/xo-procedure2/cmake/xo_procedure2Config.cmake.in index 0229c033..867a3535 100644 --- a/xo-procedure2/cmake/xo_procedure2Config.cmake.in +++ b/xo-procedure2/cmake/xo_procedure2Config.cmake.in @@ -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) diff --git a/xo-procedure2/idl/IGCObject_DPrimitive_gco_2_gco_gco.json5 b/xo-procedure2/idl/IGCObject_DPrimitive_gco_2_gco_gco.json5 new file mode 100644 index 00000000..b2fb4014 --- /dev/null +++ b/xo-procedure2/idl/IGCObject_DPrimitive_gco_2_gco_gco.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + includes: [ + // + "", + "", + ], + 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" ], +} diff --git a/xo-procedure2/include/xo/procedure2/DPrimitive.hpp b/xo-procedure2/include/xo/procedure2/DPrimitive.hpp index afd2ada2..c225246d 100644 --- a/xo-procedure2/include/xo/procedure2/DPrimitive.hpp +++ b/xo-procedure2/include/xo/procedure2/DPrimitive.hpp @@ -58,6 +58,7 @@ namespace xo { template 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{}); } + /** @defgroup scm-primitive-gcobject-facet **/ + ///@{ + std::size_t shallow_size() const noexcept; + Primitive * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} + private: template obj _apply_nocheck(obj rcx, @@ -103,6 +111,31 @@ namespace xo { Fn fn_; }; /*Primitive*/ + template + std::size_t + Primitive::shallow_size() const noexcept { + return sizeof(*this); + } + + template + Primitive * + Primitive::shallow_copy(obj mm) const noexcept { + void * mem = mm.alloc_copy((std::byte *)this); + + if (mem) { + return new (mem) Primitive(*this); + } + + return nullptr; + } + + template + std::size_t + Primitive::forward_children(obj) noexcept { + // Primitive holds no GC refs (just string_view + function pointer) + return this->shallow_size(); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/xo-procedure2/include/xo/procedure2/detail/IGCObject_DPrimitive_gco_2_gco_gco.hpp b/xo-procedure2/include/xo/procedure2/detail/IGCObject_DPrimitive_gco_2_gco_gco.hpp new file mode 100644 index 00000000..344aa6c1 --- /dev/null +++ b/xo-procedure2/include/xo/procedure2/detail/IGCObject_DPrimitive_gco_2_gco_gco.hpp @@ -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 +#include +#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 + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +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 mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DPrimitive_gco_2_gco_gco & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-procedure2/include/xo/procedure2/init_primitives.hpp b/xo-procedure2/include/xo/procedure2/init_primitives.hpp index 5e2d08e8..48b733df 100644 --- a/xo-procedure2/include/xo/procedure2/init_primitives.hpp +++ b/xo-procedure2/include/xo/procedure2/init_primitives.hpp @@ -7,12 +7,19 @@ namespace xo { namespace scm { +/** TODO: move this into xo-reader2 ? **/ + #ifdef NOT_YET using Primitive_f64_1_f64 = Primitive; using Primitive_f64_2_f64_f64 = Primitive; #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 diff --git a/xo-procedure2/src/procedure2/CMakeLists.txt b/xo-procedure2/src/procedure2/CMakeLists.txt index 11a9c305..c127b760 100644 --- a/xo-procedure2/src/procedure2/CMakeLists.txt +++ b/xo-procedure2/src/procedure2/CMakeLists.txt @@ -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 diff --git a/xo-procedure2/src/procedure2/IGCObject_DPrimitive_gco_2_gco_gco.cpp b/xo-procedure2/src/procedure2/IGCObject_DPrimitive_gco_2_gco_gco.cpp new file mode 100644 index 00000000..bd88e9ff --- /dev/null +++ b/xo-procedure2/src/procedure2/IGCObject_DPrimitive_gco_2_gco_gco.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 mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DPrimitive_gco_2_gco_gco::forward_children(DPrimitive_gco_2_gco_gco & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DPrimitive_gco_2_gco_gco.cpp */ \ No newline at end of file