From f2139feafb15199c9159da04c697e8ee2c1b5a09 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 25 Jan 2026 19:07:23 -0500 Subject: [PATCH] xo-procedure2: work on Primitive.apply_nocheck() + ARuntimeContext [WIP] --- CMakeLists.txt | 27 ++++++ idl/IProcedure_DPrimitive_gco_2_gco_gco.json5 | 17 ++++ idl/Procedure.json5 | 18 ++-- idl/RuntimeContext.json5 | 43 ++++++++++ include/xo/procedure2/DPrimitive.hpp | 15 ++-- .../procedure2/DPrimitive_gco_2_gco_gco.hpp | 15 ++++ include/xo/procedure2/Procedure.hpp | 2 +- include/xo/procedure2/RuntimeContext.hpp | 22 +++++ include/xo/procedure2/detail/AProcedure.hpp | 8 +- .../xo/procedure2/detail/ARuntimeContext.hpp | 73 ++++++++++++++++ .../xo/procedure2/detail/IProcedure_Any.hpp | 4 +- .../IProcedure_DPrimitive_gco_2_gco_gco.hpp | 67 +++++++++++++++ .../xo/procedure2/detail/IProcedure_Xfer.hpp | 8 +- .../procedure2/detail/IRuntimeContext_Any.hpp | 86 +++++++++++++++++++ .../detail/IRuntimeContext_Xfer.hpp | 81 +++++++++++++++++ include/xo/procedure2/detail/RProcedure.hpp | 6 +- .../xo/procedure2/detail/RRuntimeContext.hpp | 80 +++++++++++++++++ src/procedure2/CMakeLists.txt | 3 + src/procedure2/IProcedure_Any.cpp | 2 +- .../IProcedure_DPrimitive_gco_2_gco_gco.cpp | 39 +++++++++ src/procedure2/IRuntimeContext_Any.cpp | 41 +++++++++ src/procedure2/init_primitives.cpp | 35 ++++++++ 22 files changed, 667 insertions(+), 25 deletions(-) create mode 100644 idl/IProcedure_DPrimitive_gco_2_gco_gco.json5 create mode 100644 idl/RuntimeContext.json5 create mode 100644 include/xo/procedure2/DPrimitive_gco_2_gco_gco.hpp create mode 100644 include/xo/procedure2/RuntimeContext.hpp create mode 100644 include/xo/procedure2/detail/ARuntimeContext.hpp create mode 100644 include/xo/procedure2/detail/IProcedure_DPrimitive_gco_2_gco_gco.hpp create mode 100644 include/xo/procedure2/detail/IRuntimeContext_Any.hpp create mode 100644 include/xo/procedure2/detail/IRuntimeContext_Xfer.hpp create mode 100644 include/xo/procedure2/detail/RRuntimeContext.hpp create mode 100644 src/procedure2/IProcedure_DPrimitive_gco_2_gco_gco.cpp create mode 100644 src/procedure2/IRuntimeContext_Any.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d00f31..acb0bad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,9 +30,36 @@ xo_add_genfacet( OUTPUT_CPP_DIR src/procedure2 ) +# note: manual target; generated code committed to git +xo_add_genfacet( + TARGET xo-procedure2-facet-runtimecontext + FACET RuntimeContext + INPUT idl/RuntimeContext.json5 + OUTPUT_HPP_DIR include/xo/procedure2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/procedure2 + ) + +# ---------------------------------------------------------------- + +xo_add_genfacetimpl( + TARGET xo-procedure2-facetimpl-procedure2-primitive_gco_2_gco_gco + FACET_PKG xo_procedure2 + FACET Procedure + REPR DPrimitive_gco_2_gco_gco + INPUT idl/IProcedure_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) +# ---------------------------------------------------------------- + +xo_add_genfacet_all(xo-procedure2-genfacet-all) + # ---------------------------------------------------------------- # cmake export diff --git a/idl/IProcedure_DPrimitive_gco_2_gco_gco.json5 b/idl/IProcedure_DPrimitive_gco_2_gco_gco.json5 new file mode 100644 index 0000000..fb22bad --- /dev/null +++ b/idl/IProcedure_DPrimitive_gco_2_gco_gco.json5 @@ -0,0 +1,17 @@ +{ + mode: "implementation", + includes: [ + "", + "", + "", + "", + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Procedure.json5", + brief: "provide AProcedure interface for Primitive (gco x gco) -> gco", + using_doxygen: true, + repr: "DPrimitive_gco_2_gco_gco", + doc: [ "implement AProcedure for DPrimitive (gco x gco) -> gco" ], +} diff --git a/idl/Procedure.json5 b/idl/Procedure.json5 index fb43f31..f0eac6b 100644 --- a/idl/Procedure.json5 +++ b/idl/Procedure.json5 @@ -2,14 +2,19 @@ mode: "facet", // includes in ASyntaxStateMachine.hpp includes: [ + "\"RuntimeContext.hpp\"", + "", ], - // extra includes in SyntaxStateMachine.hpp, if any + // extra includes in Procedure.hpp, if any user_hpp_includes: [ ], namespace1: "xo", namespace2: "scm", // text after includes, before ASyntaxStateMachine - pretext: [ "// {pretex} here" ], + pretext: [ + //"namespace xo { namespace scm { class ARuntimeContext; } }", + "namespace xo { namespace scm { class DArray; } }", + ], facet: "Procedure", detail_subdir: "detail", brief: "abstraction for a schematika procedure i.e. something callable", @@ -18,9 +23,10 @@ "Abstraction for a schematika procedure" ], types: [ - { name: "AGCObject", - definition: "xo::mm::AGCObject", - doc: [ "a gc-aware object" ], + { + name: "AGCObject", + definition: "xo::mm::AGCObject", + doc: [ "a gc-aware object" ], }, // { name: string, doc: [ string ], definition: string }, ], @@ -50,7 +56,7 @@ doc: ["invoke procedure; assume arguments satisfy type system" ], return_type: "obj", args: [ - {type: "obj", name: "mm"}, + {type: "obj", name: "rcx"}, {type: "const DArray *", name: "args"}, ] } diff --git a/idl/RuntimeContext.json5 b/idl/RuntimeContext.json5 new file mode 100644 index 0000000..8a1e125 --- /dev/null +++ b/idl/RuntimeContext.json5 @@ -0,0 +1,43 @@ +{ + mode: "facet", + // includes in ARuntimeContext.hpp + includes: [ + "" + ], + // extra includes in RuntimeContext.hpp, if any + user_hpp_includes: [ + ], + namespace1: "xo", + namespace2: "scm", + // text after includes, before ARuntimeContext + pretext: [ + //"namespace xo { namespace mm { class AAllocator; } }", + ], + facet: "RuntimeContext", + detail_subdir: "detail", + brief: "runtime context for application code. At minimum provides allocator", + using_doxygen: true, + doc: [ + "Runtime application context" + ], + types: [ + { + name: "AAllocator", + definition: "xo::mm::AAllocator", + doc: [ "xo memory allocator" ], + }, + ], + const_methods: [ + { + name: "allocator", + doc: [ "default allocator to use for objects" ], + return_type: "obj", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + ], + nonconst_methods: [ + ], +} diff --git a/include/xo/procedure2/DPrimitive.hpp b/include/xo/procedure2/DPrimitive.hpp index 5e5f996..106cbed 100644 --- a/include/xo/procedure2/DPrimitive.hpp +++ b/include/xo/procedure2/DPrimitive.hpp @@ -5,6 +5,7 @@ #pragma once +#include "RuntimeContext.hpp" #include #include #include @@ -61,22 +62,24 @@ namespace xo { bool is_nary() const noexcept { return false; } static constexpr std::int32_t n_args() noexcept { return Traits::n_args; } - obj apply_nocheck(obj mm, const DArray * args) { - return _apply_nocheck(mm, args, - std::make_index_sequence{}); + obj apply_nocheck(obj rcx, const DArray * args) { + return _apply_nocheck(rcx, args, + std::make_index_sequence{}); } private: template - obj _apply_nocheck(obj mm, + obj _apply_nocheck(obj rcx, const DArray * args, std::index_sequence) { using R = typename Traits::return_type; + obj mm = rcx.allocator(); + R result - = fn_(GCObjectConversion>::from_gco(mm, args->at(Is))... - ); + = fn_(rcx, + GCObjectConversion>::from_gco(mm, args->at(Is))... ); return GCObjectConversion::to_gco(mm, result); } diff --git a/include/xo/procedure2/DPrimitive_gco_2_gco_gco.hpp b/include/xo/procedure2/DPrimitive_gco_2_gco_gco.hpp new file mode 100644 index 0000000..24ad3b4 --- /dev/null +++ b/include/xo/procedure2/DPrimitive_gco_2_gco_gco.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include +#include "DPrimitive.hpp" + +namespace xo { + namespace scm { + using xo::mm::AGCObject; + using xo::facet::obj; + + using DPrimitive_gco_2_gco_gco = Primitive (*)(obj, + obj, + obj)>; + } +} diff --git a/include/xo/procedure2/Procedure.hpp b/include/xo/procedure2/Procedure.hpp index 8b2cd91..784608e 100644 --- a/include/xo/procedure2/Procedure.hpp +++ b/include/xo/procedure2/Procedure.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Procedure.json5] * 2. jinja2 template for facet .hpp file: diff --git a/include/xo/procedure2/RuntimeContext.hpp b/include/xo/procedure2/RuntimeContext.hpp new file mode 100644 index 0000000..3241451 --- /dev/null +++ b/include/xo/procedure2/RuntimeContext.hpp @@ -0,0 +1,22 @@ +/** @file RuntimeContext.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/RuntimeContext.json5] + * 2. jinja2 template for facet .hpp file: + * [facet.hpp.j2] + * 3. idl for facet methods + * [idl/RuntimeContext.json5] + **/ + +#pragma once + +#include "detail/ARuntimeContext.hpp" +#include "detail/IRuntimeContext_Any.hpp" +#include "detail/IRuntimeContext_Xfer.hpp" +#include "detail/RRuntimeContext.hpp" + + +/* end RuntimeContext.hpp */ \ No newline at end of file diff --git a/include/xo/procedure2/detail/AProcedure.hpp b/include/xo/procedure2/detail/AProcedure.hpp index c0b22f4..63a4da9 100644 --- a/include/xo/procedure2/detail/AProcedure.hpp +++ b/include/xo/procedure2/detail/AProcedure.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Procedure.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -14,11 +14,13 @@ #pragma once // includes (via {facet_includes}) +#include "RuntimeContext.hpp" +#include #include #include #include -// {pretex} here +namespace xo { namespace scm { class DArray; } } namespace xo { namespace scm { @@ -54,7 +56,7 @@ public: // nonconst methods /** invoke procedure; assume arguments satisfy type system **/ - virtual obj apply_nocheck(Opaque data, obj mm, const DArray * args) = 0; + virtual obj apply_nocheck(Opaque data, obj rcx, const DArray * args) = 0; ///@} }; /*AProcedure*/ diff --git a/include/xo/procedure2/detail/ARuntimeContext.hpp b/include/xo/procedure2/detail/ARuntimeContext.hpp new file mode 100644 index 0000000..4e96bc8 --- /dev/null +++ b/include/xo/procedure2/detail/ARuntimeContext.hpp @@ -0,0 +1,73 @@ +/** @file ARuntimeContext.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/RuntimeContext.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [idl/RuntimeContext.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include +#include +#include +#include + + +namespace xo { +namespace scm { + +using Copaque = const void *; +using Opaque = void *; + +/** +Runtime application context +**/ +class ARuntimeContext { +public: + /** @defgroup scm-runtimecontext-type-traits **/ + ///@{ + // types + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using Copaque = const void *; + using Opaque = void *; + /** xo memory allocator **/ + using AAllocator = xo::mm::AAllocator; + ///@} + + /** @defgroup scm-runtimecontext-methods **/ + ///@{ + // const methods + /** RTTI: unique id# for actual runtime data representation **/ + virtual typeseq _typeseq() const noexcept = 0; + /** default allocator to use for objects **/ + virtual obj allocator(Copaque data) const noexcept = 0; + + // nonconst methods + ///@} +}; /*ARuntimeContext*/ + +/** Implementation IRuntimeContext_DRepr of ARuntimeContext for state DRepr + * should provide a specialization: + * + * template <> + * struct xo::facet::FacetImplementation { + * using Impltype = IRuntimeContext_DRepr; + * }; + * + * then IRuntimeContext_ImplType --> IRuntimeContext_DRepr + **/ +template +using IRuntimeContext_ImplType = xo::facet::FacetImplType; + +} /*namespace scm*/ +} /*namespace xo*/ + +/* ARuntimeContext.hpp */ \ No newline at end of file diff --git a/include/xo/procedure2/detail/IProcedure_Any.hpp b/include/xo/procedure2/detail/IProcedure_Any.hpp index c1b8c9d..5d711d4 100644 --- a/include/xo/procedure2/detail/IProcedure_Any.hpp +++ b/include/xo/procedure2/detail/IProcedure_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Procedure.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -60,7 +60,7 @@ namespace scm { [[noreturn]] std::int32_t n_args(Copaque) const noexcept override { _fatal(); } // nonconst methods - [[noreturn]] obj apply_nocheck(Opaque, obj, const DArray *) override; + [[noreturn]] obj apply_nocheck(Opaque, obj, const DArray *) override; ///@} diff --git a/include/xo/procedure2/detail/IProcedure_DPrimitive_gco_2_gco_gco.hpp b/include/xo/procedure2/detail/IProcedure_DPrimitive_gco_2_gco_gco.hpp new file mode 100644 index 0000000..11f2cd6 --- /dev/null +++ b/include/xo/procedure2/detail/IProcedure_DPrimitive_gco_2_gco_gco.hpp @@ -0,0 +1,67 @@ +/** @file IProcedure_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/IProcedure_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/IProcedure_DPrimitive_gco_2_gco_gco.json5] + **/ + +#pragma once + +#include "Procedure.hpp" +#include +#include +#include +#include +#include "DPrimitive_gco_2_gco_gco.hpp" + +namespace xo { namespace scm { class IProcedure_DPrimitive_gco_2_gco_gco; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IProcedure_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IProcedure_DPrimitive_gco_2_gco_gco + **/ + class IProcedure_DPrimitive_gco_2_gco_gco { + public: + /** @defgroup scm-procedure-dprimitive_gco_2_gco_gco-type-traits **/ + ///@{ + using AGCObject = xo::scm::AProcedure::AGCObject; + using Copaque = xo::scm::AProcedure::Copaque; + using Opaque = xo::scm::AProcedure::Opaque; + ///@} + /** @defgroup scm-procedure-dprimitive_gco_2_gco_gco-methods **/ + ///@{ + // const methods + /** true iff procedure takes n arguments **/ + static bool is_nary(const DPrimitive_gco_2_gco_gco & self) noexcept; + /** number of arguments. -1 for n-ary **/ + static std::int32_t n_args(const DPrimitive_gco_2_gco_gco & self) noexcept; + + // non-const methods + /** invoke procedure; assume arguments satisfy type system **/ + static obj apply_nocheck(DPrimitive_gco_2_gco_gco & self, obj rcx, const DArray * args); + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/procedure2/detail/IProcedure_Xfer.hpp b/include/xo/procedure2/detail/IProcedure_Xfer.hpp index dfe8a55..4f84652 100644 --- a/include/xo/procedure2/detail/IProcedure_Xfer.hpp +++ b/include/xo/procedure2/detail/IProcedure_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Procedure.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -13,6 +13,8 @@ #pragma once +#include "RuntimeContext.hpp" +#include namespace xo { namespace scm { @@ -48,8 +50,8 @@ namespace scm { } // non-const methods - obj apply_nocheck(Opaque data, obj mm, const DArray * args) override { - return I::apply_nocheck(_dcast(data), mm, args); + obj apply_nocheck(Opaque data, obj rcx, const DArray * args) override { + return I::apply_nocheck(_dcast(data), rcx, args); } ///@} diff --git a/include/xo/procedure2/detail/IRuntimeContext_Any.hpp b/include/xo/procedure2/detail/IRuntimeContext_Any.hpp new file mode 100644 index 0000000..1e5f97c --- /dev/null +++ b/include/xo/procedure2/detail/IRuntimeContext_Any.hpp @@ -0,0 +1,86 @@ +/** @file IRuntimeContext_Any.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/RuntimeContext.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/RuntimeContext.json5] + **/ + +#pragma once + +#include "ARuntimeContext.hpp" +#include + +namespace xo { namespace scm { class IRuntimeContext_Any; } } + +namespace xo { +namespace facet { + +template <> +struct FacetImplementation +{ + using ImplType = xo::scm::IRuntimeContext_Any; +}; + +} +} + +namespace xo { +namespace scm { + + /** @class IRuntimeContext_Any + * @brief ARuntimeContext implementation for empty variant instance + **/ + class IRuntimeContext_Any : public ARuntimeContext { + public: + /** @defgroup scm-runtimecontext-any-type-traits **/ + ///@{ + + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using AAllocator = ARuntimeContext::AAllocator; + + ///@} + /** @defgroup scm-runtimecontext-any-methods **/ + ///@{ + + const ARuntimeContext * iface() const { return std::launder(this); } + + // from ARuntimeContext + + // const methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] obj allocator(Copaque) const noexcept override { _fatal(); } + + // nonconst methods + + ///@} + + private: + /** @defgraoup scm-runtimecontext-any-private-methods **/ + ///@{ + + [[noreturn]] static void _fatal(); + + ///@} + + public: + /** @defgroup scm-runtimecontext-any-member-vars **/ + ///@{ + + static typeseq s_typeseq; + static bool _valid; + + ///@} + }; + +} /*namespace scm */ +} /*namespace xo */ + +/* IRuntimeContext_Any.hpp */ \ No newline at end of file diff --git a/include/xo/procedure2/detail/IRuntimeContext_Xfer.hpp b/include/xo/procedure2/detail/IRuntimeContext_Xfer.hpp new file mode 100644 index 0000000..cd71b73 --- /dev/null +++ b/include/xo/procedure2/detail/IRuntimeContext_Xfer.hpp @@ -0,0 +1,81 @@ +/** @file IRuntimeContext_Xfer.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/RuntimeContext.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/RuntimeContext.json5] + **/ + +#pragma once + +#include + +namespace xo { +namespace scm { + /** @class IRuntimeContext_Xfer + **/ + template + class IRuntimeContext_Xfer : public ARuntimeContext { + public: + /** @defgroup scm-runtimecontext-xfer-type-traits **/ + ///@{ + /** actual implementation (not generated; often delegates to DRepr) **/ + using Impl = IRuntimeContext_DRepr; + /** integer identifying a type **/ + using typeseq = ARuntimeContext::typeseq; + using AAllocator = ARuntimeContext::AAllocator; + ///@} + + /** @defgroup scm-runtimecontext-xfer-methods **/ + ///@{ + + static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; } + static DRepr & _dcast(Opaque d) { return *(DRepr *)d; } + + // from ARuntimeContext + + // const methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + obj allocator(Copaque data) const noexcept override { + return I::allocator(_dcast(data)); + } + + // non-const methods + + ///@} + + private: + using I = Impl; + + public: + /** @defgroup scm-runtimecontext-xfer-member-vars **/ + ///@{ + + /** typeseq for template parameter DRepr **/ + static typeseq s_typeseq; + /** true iff satisfies facet implementation **/ + static bool _valid; + + ///@} + }; + + template + xo::facet::typeseq + IRuntimeContext_Xfer::s_typeseq + = xo::facet::typeseq::id(); + + template + bool + IRuntimeContext_Xfer::_valid + = xo::facet::valid_facet_implementation(); + +} /*namespace scm */ +} /*namespace xo*/ + +/* end IRuntimeContext_Xfer.hpp */ \ No newline at end of file diff --git a/include/xo/procedure2/detail/RProcedure.hpp b/include/xo/procedure2/detail/RProcedure.hpp index dc0f30d..93599ae 100644 --- a/include/xo/procedure2/detail/RProcedure.hpp +++ b/include/xo/procedure2/detail/RProcedure.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Procedure.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -56,8 +56,8 @@ public: } // non-const methods (still const in router!) - obj apply_nocheck(obj mm, const DArray * args) { - return O::iface()->apply_nocheck(O::data(), mm, args); + obj apply_nocheck(obj rcx, const DArray * args) { + return O::iface()->apply_nocheck(O::data(), rcx, args); } ///@} diff --git a/include/xo/procedure2/detail/RRuntimeContext.hpp b/include/xo/procedure2/detail/RRuntimeContext.hpp new file mode 100644 index 0000000..b06227c --- /dev/null +++ b/include/xo/procedure2/detail/RRuntimeContext.hpp @@ -0,0 +1,80 @@ +/** @file RRuntimeContext.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/RuntimeContext.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/RuntimeContext.json5] + **/ + +#pragma once + +#include "ARuntimeContext.hpp" + +namespace xo { +namespace scm { + +/** @class RRuntimeContext + **/ +template +class RRuntimeContext : public Object { +private: + using O = Object; + +public: + /** @defgroup scm-runtimecontext-router-type-traits **/ + ///@{ + using ObjectType = Object; + using DataPtr = Object::DataPtr; + using typeseq = xo::reflect::typeseq; + using AAllocator = ARuntimeContext::AAllocator; + ///@} + + /** @defgroup scm-runtimecontext-router-ctors **/ + ///@{ + RRuntimeContext() {} + RRuntimeContext(Object::DataPtr data) : Object{std::move(data)} {} + RRuntimeContext(const ARuntimeContext * iface, void * data) + requires std::is_same_v + : Object(iface, data) {} + + ///@} + /** @defgroup scm-runtimecontext-router-methods **/ + ///@{ + + // const methods + typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + obj allocator() const noexcept { + return O::iface()->allocator(O::data()); + } + + // non-const methods (still const in router!) + + ///@} + /** @defgroup scm-runtimecontext-member-vars **/ + ///@{ + + static bool _valid; + + ///@} +}; + +template +bool +RRuntimeContext::_valid = xo::facet::valid_object_router(); + +} /*namespace scm*/ +} /*namespace xo*/ + +namespace xo { namespace facet { + template + struct RoutingFor { + using RoutingType = xo::scm::RRuntimeContext; + }; +} } + +/* end RRuntimeContext.hpp */ \ No newline at end of file diff --git a/src/procedure2/CMakeLists.txt b/src/procedure2/CMakeLists.txt index edc5d3c..11a9c30 100644 --- a/src/procedure2/CMakeLists.txt +++ b/src/procedure2/CMakeLists.txt @@ -5,6 +5,9 @@ set(SELF_SRCS init_procedure2.cpp init_primitives.cpp DPrimitive.cpp + IRuntimeContext_Any.cpp + IProcedure_Any.cpp + IProcedure_DPrimitive_gco_2_gco_gco.cpp # Add source files here, e.g.: # procedure2.cpp ) diff --git a/src/procedure2/IProcedure_Any.cpp b/src/procedure2/IProcedure_Any.cpp index 3044c10..d28d98e 100644 --- a/src/procedure2/IProcedure_Any.cpp +++ b/src/procedure2/IProcedure_Any.cpp @@ -35,7 +35,7 @@ IProcedure_Any::_valid // nonconst methods auto -IProcedure_Any::apply_nocheck(Opaque, obj, const DArray *) -> obj +IProcedure_Any::apply_nocheck(Opaque, obj, const DArray *) -> obj { _fatal(); } diff --git a/src/procedure2/IProcedure_DPrimitive_gco_2_gco_gco.cpp b/src/procedure2/IProcedure_DPrimitive_gco_2_gco_gco.cpp new file mode 100644 index 0000000..67e73c9 --- /dev/null +++ b/src/procedure2/IProcedure_DPrimitive_gco_2_gco_gco.cpp @@ -0,0 +1,39 @@ +/** @file IProcedure_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/IProcedure_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/IProcedure_DPrimitive_gco_2_gco_gco.json5] +**/ + +#include "detail/IProcedure_DPrimitive_gco_2_gco_gco.hpp" + +namespace xo { + namespace scm { + auto + IProcedure_DPrimitive_gco_2_gco_gco::is_nary(const DPrimitive_gco_2_gco_gco & self) noexcept -> bool + { + return self.is_nary(); + } + + auto + IProcedure_DPrimitive_gco_2_gco_gco::n_args(const DPrimitive_gco_2_gco_gco & self) noexcept -> std::int32_t + { + return self.n_args(); + } + + auto + IProcedure_DPrimitive_gco_2_gco_gco::apply_nocheck(DPrimitive_gco_2_gco_gco & self, obj rcx, const DArray * args) -> obj + { + return self.apply_nocheck(rcx, args); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IProcedure_DPrimitive_gco_2_gco_gco.cpp */ \ No newline at end of file diff --git a/src/procedure2/IRuntimeContext_Any.cpp b/src/procedure2/IRuntimeContext_Any.cpp new file mode 100644 index 0000000..a9c5b55 --- /dev/null +++ b/src/procedure2/IRuntimeContext_Any.cpp @@ -0,0 +1,41 @@ +/** @file IRuntimeContext_Any.cpp + * + **/ + +#include "detail/IRuntimeContext_Any.hpp" +#include + +namespace xo { +namespace scm { + +using xo::facet::DVariantPlaceholder; +using xo::facet::typeseq; +using xo::facet::valid_facet_implementation; + +void +IRuntimeContext_Any::_fatal() +{ + /* control here on uninitialized IAllocator_Any. + * Initialized instance will have specific implementation type + */ + std::cerr << "fatal" + << ": attempt to call uninitialized" + << " IRuntimeContext_Any method" + << std::endl; + std::terminate(); +} + +typeseq +IRuntimeContext_Any::s_typeseq = typeseq::id(); + +bool +IRuntimeContext_Any::_valid + = valid_facet_implementation(); + +// nonconst methods + + +} /*namespace scm*/ +} /*namespace xo*/ + +/* end IRuntimeContext_Any.cpp */ \ No newline at end of file diff --git a/src/procedure2/init_primitives.cpp b/src/procedure2/init_primitives.cpp index 169b660..35709e0 100644 --- a/src/procedure2/init_primitives.cpp +++ b/src/procedure2/init_primitives.cpp @@ -5,6 +5,7 @@ #include "init_primitives.hpp" #include "DPrimitive.hpp" +#include namespace xo { namespace scm { @@ -23,6 +24,40 @@ namespace xo { return x - y; } +#ifdef NOT_YET + obj + mul_any_any(obj x_gco, obj y_gco) + { + // PLACEHOLDER + + // TODO: + // 1. move this to xo-numeric2/ when available + // 2. at that point will require polymorphic dispatch + // on argument representations, analogous to dispatch + // in FacetRegistry + // 3. Need concept of a 'runtime context'. + // This will need to be part of the AProcedure api + // e.g. passed to apply_nocheck + + typeseq x_tseq = x_gco._typeseq(); + typeseq y_tseq = y_gco._typeseq(); + + // FOR NOW: just test runtime values + // + if (x_tseq == typeseq::id()) { + if (y_tseq == typeseq::id()) { + // unusable placeholder allocator; + obj placeholder_mm; + + // f64 * f64. + double x = GCObjectConversion::from_gco(placeholder_mm, x_gco); + double y = GCObjectConversion::from_gco(placeholder_mm, y_gco); + + + + } +#endif + double mul_f64_f64(double x, double y) { return x * y;