xo-procedure2: work on Primitive.apply_nocheck() + ARuntimeContext [WIP]
This commit is contained in:
parent
c0978f5098
commit
65f50609f6
23 changed files with 668 additions and 25 deletions
|
|
@ -104,6 +104,7 @@ add_subdirectory(xo-object)
|
|||
add_subdirectory(xo-object2) # experiment w/ facet object model
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
17
xo-procedure2/idl/IProcedure_DPrimitive_gco_2_gco_gco.json5
Normal file
17
xo-procedure2/idl/IProcedure_DPrimitive_gco_2_gco_gco.json5
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
mode: "implementation",
|
||||
includes: [
|
||||
"<xo/procedure2/RuntimeContext.hpp>",
|
||||
"<xo/procedure2/detail/IRuntimeContext_Xfer.hpp>",
|
||||
"<xo/procedure2/Procedure.hpp>",
|
||||
"<xo/procedure2/detail/IProcedure_Xfer.hpp>",
|
||||
],
|
||||
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" ],
|
||||
}
|
||||
|
|
@ -2,14 +2,19 @@
|
|||
mode: "facet",
|
||||
// includes in ASyntaxStateMachine.hpp
|
||||
includes: [
|
||||
"\"RuntimeContext.hpp\"",
|
||||
"<xo/gc/GCObject.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<AGCObject>",
|
||||
args: [
|
||||
{type: "obj<AAllocator>", name: "mm"},
|
||||
{type: "obj<ARuntimeContext>", name: "rcx"},
|
||||
{type: "const DArray *", name: "args"},
|
||||
]
|
||||
}
|
||||
|
|
|
|||
43
xo-procedure2/idl/RuntimeContext.json5
Normal file
43
xo-procedure2/idl/RuntimeContext.json5
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
mode: "facet",
|
||||
// includes in ARuntimeContext.hpp
|
||||
includes: [
|
||||
"<xo/alloc2/Allocator.hpp>"
|
||||
],
|
||||
// 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<AAllocator>",
|
||||
args: [],
|
||||
const: true,
|
||||
noexcept: true,
|
||||
attributes: [],
|
||||
},
|
||||
],
|
||||
nonconst_methods: [
|
||||
],
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "RuntimeContext.hpp"
|
||||
#include <xo/object2/DArray.hpp>
|
||||
#include <xo/gc/GCObjectConversion.hpp>
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
|
|
@ -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<AGCObject> apply_nocheck(obj<AAllocator> mm, const DArray * args) {
|
||||
return _apply_nocheck(mm, args,
|
||||
std::make_index_sequence<Traits::n_args>{});
|
||||
obj<AGCObject> apply_nocheck(obj<ARuntimeContext> rcx, const DArray * args) {
|
||||
return _apply_nocheck(rcx, args,
|
||||
std::make_index_sequence<Traits::n_args>{});
|
||||
}
|
||||
|
||||
private:
|
||||
template <std::size_t... Is>
|
||||
obj<AGCObject> _apply_nocheck(obj<AAllocator> mm,
|
||||
obj<AGCObject> _apply_nocheck(obj<ARuntimeContext> rcx,
|
||||
const DArray * args,
|
||||
std::index_sequence<Is...>)
|
||||
{
|
||||
using R = typename Traits::return_type;
|
||||
|
||||
obj<AAllocator> mm = rcx.allocator();
|
||||
|
||||
R result
|
||||
= fn_(GCObjectConversion<typename Traits::template arg_type<Is>>::from_gco(mm, args->at(Is))...
|
||||
);
|
||||
= fn_(rcx,
|
||||
GCObjectConversion<typename Traits::template arg_type<Is>>::from_gco(mm, args->at(Is))... );
|
||||
|
||||
return GCObjectConversion<R>::to_gco(mm, result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
#include "DPrimitive.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
using xo::mm::AGCObject;
|
||||
using xo::facet::obj;
|
||||
|
||||
using DPrimitive_gco_2_gco_gco = Primitive<obj<AGCObject> (*)(obj<ARuntimeContext>,
|
||||
obj<AGCObject>,
|
||||
obj<AGCObject>)>;
|
||||
}
|
||||
}
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
22
xo-procedure2/include/xo/procedure2/RuntimeContext.hpp
Normal file
22
xo-procedure2/include/xo/procedure2/RuntimeContext.hpp
Normal file
|
|
@ -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 */
|
||||
|
|
@ -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 <xo/gc/GCObject.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/facet/typeseq.hpp>
|
||||
|
||||
// {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<AGCObject> apply_nocheck(Opaque data, obj<AAllocator> mm, const DArray * args) = 0;
|
||||
virtual obj<AGCObject> apply_nocheck(Opaque data, obj<ARuntimeContext> rcx, const DArray * args) = 0;
|
||||
///@}
|
||||
}; /*AProcedure*/
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/facet/typeseq.hpp>
|
||||
|
||||
|
||||
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<AAllocator> 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<ARuntimeContext, DRepr> {
|
||||
* using Impltype = IRuntimeContext_DRepr;
|
||||
* };
|
||||
*
|
||||
* then IRuntimeContext_ImplType<DRepr> --> IRuntimeContext_DRepr
|
||||
**/
|
||||
template <typename DRepr>
|
||||
using IRuntimeContext_ImplType = xo::facet::FacetImplType<ARuntimeContext, DRepr>;
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* 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/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<AGCObject> apply_nocheck(Opaque, obj<AAllocator>, const DArray *) override;
|
||||
[[noreturn]] obj<AGCObject> apply_nocheck(Opaque, obj<ARuntimeContext>, const DArray *) override;
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <xo/procedure2/RuntimeContext.hpp>
|
||||
#include <xo/procedure2/detail/IRuntimeContext_Xfer.hpp>
|
||||
#include <xo/procedure2/Procedure.hpp>
|
||||
#include <xo/procedure2/detail/IProcedure_Xfer.hpp>
|
||||
#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<xo::scm::AProcedure,
|
||||
xo::scm::DPrimitive_gco_2_gco_gco>
|
||||
{
|
||||
using ImplType = xo::scm::IProcedure_Xfer
|
||||
<xo::scm::DPrimitive_gco_2_gco_gco,
|
||||
xo::scm::IProcedure_DPrimitive_gco_2_gco_gco>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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<AGCObject> apply_nocheck(DPrimitive_gco_2_gco_gco & self, obj<ARuntimeContext> rcx, const DArray * args);
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -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 <xo/gc/GCObject.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
|
@ -48,8 +50,8 @@ namespace scm {
|
|||
}
|
||||
|
||||
// non-const methods
|
||||
obj<AGCObject> apply_nocheck(Opaque data, obj<AAllocator> mm, const DArray * args) override {
|
||||
return I::apply_nocheck(_dcast(data), mm, args);
|
||||
obj<AGCObject> apply_nocheck(Opaque data, obj<ARuntimeContext> rcx, const DArray * args) override {
|
||||
return I::apply_nocheck(_dcast(data), rcx, args);
|
||||
}
|
||||
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -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 <xo/facet/obj.hpp>
|
||||
|
||||
namespace xo { namespace scm { class IRuntimeContext_Any; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
|
||||
template <>
|
||||
struct FacetImplementation<xo::scm::ARuntimeContext,
|
||||
DVariantPlaceholder>
|
||||
{
|
||||
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<AAllocator> 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 */
|
||||
|
|
@ -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 <xo/alloc2/Allocator.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class IRuntimeContext_Xfer
|
||||
**/
|
||||
template <typename DRepr, typename IRuntimeContext_DRepr>
|
||||
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<AAllocator> 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 <typename DRepr, typename IRuntimeContext_DRepr>
|
||||
xo::facet::typeseq
|
||||
IRuntimeContext_Xfer<DRepr, IRuntimeContext_DRepr>::s_typeseq
|
||||
= xo::facet::typeseq::id<DRepr>();
|
||||
|
||||
template <typename DRepr, typename IRuntimeContext_DRepr>
|
||||
bool
|
||||
IRuntimeContext_Xfer<DRepr, IRuntimeContext_DRepr>::_valid
|
||||
= xo::facet::valid_facet_implementation<ARuntimeContext,
|
||||
IRuntimeContext_Xfer>();
|
||||
|
||||
} /*namespace scm */
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end 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/Procedure.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
|
|
@ -56,8 +56,8 @@ public:
|
|||
}
|
||||
|
||||
// non-const methods (still const in router!)
|
||||
obj<AGCObject> apply_nocheck(obj<AAllocator> mm, const DArray * args) {
|
||||
return O::iface()->apply_nocheck(O::data(), mm, args);
|
||||
obj<AGCObject> apply_nocheck(obj<ARuntimeContext> rcx, const DArray * args) {
|
||||
return O::iface()->apply_nocheck(O::data(), rcx, args);
|
||||
}
|
||||
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -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 <typename Object>
|
||||
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<typename Object::DataType, xo::facet::DVariantPlaceholder>
|
||||
: Object(iface, data) {}
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-runtimecontext-router-methods **/
|
||||
///@{
|
||||
|
||||
// const methods
|
||||
typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); }
|
||||
obj<AAllocator> 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 <typename Object>
|
||||
bool
|
||||
RRuntimeContext<Object>::_valid = xo::facet::valid_object_router<Object>();
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
namespace xo { namespace facet {
|
||||
template <typename Object>
|
||||
struct RoutingFor<xo::scm::ARuntimeContext, Object> {
|
||||
using RoutingType = xo::scm::RRuntimeContext<Object>;
|
||||
};
|
||||
} }
|
||||
|
||||
/* end RRuntimeContext.hpp */
|
||||
|
|
@ -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
|
||||
)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ IProcedure_Any::_valid
|
|||
// nonconst methods
|
||||
|
||||
auto
|
||||
IProcedure_Any::apply_nocheck(Opaque, obj<AAllocator>, const DArray *) -> obj<AGCObject>
|
||||
IProcedure_Any::apply_nocheck(Opaque, obj<ARuntimeContext>, const DArray *) -> obj<AGCObject>
|
||||
{
|
||||
_fatal();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ARuntimeContext> rcx, const DArray * args) -> obj<AGCObject>
|
||||
{
|
||||
return self.apply_nocheck(rcx, args);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IProcedure_DPrimitive_gco_2_gco_gco.cpp */
|
||||
41
xo-procedure2/src/procedure2/IRuntimeContext_Any.cpp
Normal file
41
xo-procedure2/src/procedure2/IRuntimeContext_Any.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/** @file IRuntimeContext_Any.cpp
|
||||
*
|
||||
**/
|
||||
|
||||
#include "detail/IRuntimeContext_Any.hpp"
|
||||
#include <iostream>
|
||||
|
||||
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<DVariantPlaceholder>();
|
||||
|
||||
bool
|
||||
IRuntimeContext_Any::_valid
|
||||
= valid_facet_implementation<ARuntimeContext, IRuntimeContext_Any>();
|
||||
|
||||
// nonconst methods
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IRuntimeContext_Any.cpp */
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "init_primitives.hpp"
|
||||
#include "DPrimitive.hpp"
|
||||
#include <cmath>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
|
@ -23,6 +24,40 @@ namespace xo {
|
|||
return x - y;
|
||||
}
|
||||
|
||||
#ifdef NOT_YET
|
||||
obj<AGCObject>
|
||||
mul_any_any(obj<AGCObject> x_gco, obj<AGCObject> 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<DFloat>()) {
|
||||
if (y_tseq == typeseq::id<DFloat>()) {
|
||||
// unusable placeholder allocator;
|
||||
obj<AAllocator> placeholder_mm;
|
||||
|
||||
// f64 * f64.
|
||||
double x = GCObjectConversion<double>::from_gco(placeholder_mm, x_gco);
|
||||
double y = GCObjectConversion<double>::from_gco(placeholder_mm, y_gco);
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
double
|
||||
mul_f64_f64(double x, double y) {
|
||||
return x * y;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue