diff --git a/idl/Procedure.json5 b/idl/Procedure.json5 index f26a4e5..91c8bdf 100644 --- a/idl/Procedure.json5 +++ b/idl/Procedure.json5 @@ -1,3 +1,7 @@ +// can regenerate downstream .*pp files with either: +// cmake --build -- xo-procedure2-facet-procedure +// cmake --build -- xo-procedure2-genfacet-all + { mode: "facet", // includes in ASyntaxStateMachine.hpp @@ -56,6 +60,7 @@ doc: ["invoke procedure; assume arguments satisfy type system" ], return_type: "obj", args: [ + {type: "obj", name: "rcx"}, {type: "const DArray *", name: "args"}, ] } diff --git a/include/xo/procedure2/DPrimitive.hpp b/include/xo/procedure2/DPrimitive.hpp index cf913a1..afd2ada 100644 --- a/include/xo/procedure2/DPrimitive.hpp +++ b/include/xo/procedure2/DPrimitive.hpp @@ -19,43 +19,49 @@ namespace xo { namespace scm { - /** @brief Extract return type and argument types from a function type. - * - * Primary template (undefined) - specializations handle specific cases + namespace detail { + /** @brief Extract return type and argument types from a function type. + * + * Primary template (undefined) - specializations handle specific cases + **/ + template + struct PmFnTraits; + + /** specialization for function pointers **/ + template + struct PmFnTraits rcx, Args...)> { + /** function return type **/ + using return_type = R; + /** tuple type for function arguments (except for runtime context) **/ + using args_tuple = std::tuple; + /** number of arguments (except for runtime context) **/ + static constexpr std::size_t n_args = sizeof...(Args); + + /** arg_type is the type of the i'th argument to Fn. + * (starting from argument after runtime context) + **/ + template + using arg_type = std::tuple_element_t; + }; + + /** specialization for function references **/ + template + struct PmFnTraits, Args...)> : PmFnTraits, Args...)> {}; + + /** specialization for plain function types **/ + template + struct PmFnTraits, Args...)> : PmFnTraits, Args...)> {}; + } + + /** @brief Schematika primitive with fixed number of arguments **/ - template - struct FnTraits; - - /** specialization for function pointers **/ - template - struct FnTraits { - /** function return type **/ - using return_type = R; - /** tuple type for function arguments **/ - using args_tuple = std::tuple; - /** number of arguments **/ - static constexpr std::size_t n_args = sizeof...(Args); - - /** arg_type is the type of the i'th argument to Fn **/ - template - using arg_type = std::tuple_element_t; - }; - - /** specialization for function references **/ - template - struct FnTraits : FnTraits {}; - - /** specialization for plain function types **/ - template - struct FnTraits : FnTraits {}; - template class Primitive { public: using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; using DArray = xo::scm::DArray; - using Traits = FnTraits; + using Traits = detail::PmFnTraits; public: Primitive(std::string_view name, Fn fn) : name_{name}, fn_{fn} {} @@ -63,14 +69,15 @@ namespace xo { bool is_nary() const noexcept { return false; } static constexpr std::int32_t n_args() noexcept { return Traits::n_args; } - obj apply_nocheck(const DArray * args) { - return _apply_nocheck(args, + obj apply_nocheck(obj rcx, const DArray * args) { + return _apply_nocheck(rcx, args, std::make_index_sequence{}); } private: template - obj _apply_nocheck(const DArray * args, + obj _apply_nocheck(obj rcx, + const DArray * args, std::index_sequence) { using xo::facet::FacetRegistry; @@ -80,12 +87,11 @@ namespace xo { assert(args); assert(args->size() > 0); - obj rcx - = FacetRegistry::instance().variant(args->at(0)); 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 index 24ad3b4..78dd26b 100644 --- a/include/xo/procedure2/DPrimitive_gco_2_gco_gco.hpp +++ b/include/xo/procedure2/DPrimitive_gco_2_gco_gco.hpp @@ -1,3 +1,8 @@ +/** @file DPrimitive_gco_2_gco_gco.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + #pragma once #include @@ -13,3 +18,5 @@ namespace xo { obj)>; } } + +/* end DPrimitive_gco_2_gco_gco.hpp */ 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 index 2e8300e..3241451 100644 --- a/include/xo/procedure2/RuntimeContext.hpp +++ b/include/xo/procedure2/RuntimeContext.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/RuntimeContext.json5] * 2. jinja2 template for facet .hpp file: diff --git a/include/xo/procedure2/detail/AProcedure.hpp b/include/xo/procedure2/detail/AProcedure.hpp index 1be5e0d..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: @@ -56,7 +56,7 @@ public: // nonconst methods /** invoke procedure; assume arguments satisfy type system **/ - virtual obj apply_nocheck(Opaque data, 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 index 42030d9..4e96bc8 100644 --- a/include/xo/procedure2/detail/ARuntimeContext.hpp +++ b/include/xo/procedure2/detail/ARuntimeContext.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/RuntimeContext.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/procedure2/detail/IProcedure_Any.hpp b/include/xo/procedure2/detail/IProcedure_Any.hpp index 3f66fcd..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, 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 index 4b4351d..11f2cd6 100644 --- a/include/xo/procedure2/detail/IProcedure_DPrimitive_gco_2_gco_gco.hpp +++ b/include/xo/procedure2/detail/IProcedure_DPrimitive_gco_2_gco_gco.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/IProcedure_DPrimitive_gco_2_gco_gco.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -57,7 +57,7 @@ namespace xo { // non-const methods /** invoke procedure; assume arguments satisfy type system **/ - static obj apply_nocheck(DPrimitive_gco_2_gco_gco & self, const DArray * args); + static obj apply_nocheck(DPrimitive_gco_2_gco_gco & self, obj rcx, const DArray * args); ///@} }; diff --git a/include/xo/procedure2/detail/IProcedure_Xfer.hpp b/include/xo/procedure2/detail/IProcedure_Xfer.hpp index adf4995..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: @@ -50,8 +50,8 @@ namespace scm { } // non-const methods - obj apply_nocheck(Opaque data, const DArray * args) override { - return I::apply_nocheck(_dcast(data), 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 index 419d45c..1e5f97c 100644 --- a/include/xo/procedure2/detail/IRuntimeContext_Any.hpp +++ b/include/xo/procedure2/detail/IRuntimeContext_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/RuntimeContext.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/procedure2/detail/IRuntimeContext_Xfer.hpp b/include/xo/procedure2/detail/IRuntimeContext_Xfer.hpp index e9f5512..cd71b73 100644 --- a/include/xo/procedure2/detail/IRuntimeContext_Xfer.hpp +++ b/include/xo/procedure2/detail/IRuntimeContext_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/RuntimeContext.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/procedure2/detail/RProcedure.hpp b/include/xo/procedure2/detail/RProcedure.hpp index 9fff0c6..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(const DArray * args) { - return O::iface()->apply_nocheck(O::data(), 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 index 06b093d..b06227c 100644 --- a/include/xo/procedure2/detail/RRuntimeContext.hpp +++ b/include/xo/procedure2/detail/RRuntimeContext.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/RuntimeContext.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/procedure2/IProcedure_Any.cpp b/src/procedure2/IProcedure_Any.cpp index 79b3b77..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, 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 index 5266477..67e73c9 100644 --- a/src/procedure2/IProcedure_DPrimitive_gco_2_gco_gco.cpp +++ b/src/procedure2/IProcedure_DPrimitive_gco_2_gco_gco.cpp @@ -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/IProcedure_DPrimitive_gco_2_gco_gco.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -28,9 +28,9 @@ namespace xo { } auto - IProcedure_DPrimitive_gco_2_gco_gco::apply_nocheck(DPrimitive_gco_2_gco_gco & self, const DArray * args) -> obj + IProcedure_DPrimitive_gco_2_gco_gco::apply_nocheck(DPrimitive_gco_2_gco_gco & self, obj rcx, const DArray * args) -> obj { - return self.apply_nocheck(args); + return self.apply_nocheck(rcx, args); } } /*namespace scm*/