diff --git a/xo-procedure2/CMakeLists.txt b/xo-procedure2/CMakeLists.txt new file mode 100644 index 00000000..8d00f310 --- /dev/null +++ b/xo-procedure2/CMakeLists.txt @@ -0,0 +1,41 @@ +# xo-procedure2/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(xo_procedure2 VERSION 1.0) +enable_language(CXX) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +# one-time project-specific c++ flags. usually empty +set(PROJECT_CXX_FLAGS "") +add_definitions(${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- +# output targets + +# note: manual target; generated code committed to git +xo_add_genfacet( + TARGET xo-procedure2-facet-procedure + FACET Procedure + INPUT idl/Procedure.json5 + OUTPUT_HPP_DIR include/xo/procedure2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/procedure2 + ) + +add_subdirectory(src/procedure2) +#add_subdirectory(utest) + +# ---------------------------------------------------------------- +# cmake export + +#xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +# end CMakeLists.txt diff --git a/xo-procedure2/cmake/xo-bootstrap-macros.cmake b/xo-procedure2/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..592272c0 --- /dev/null +++ b/xo-procedure2/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,41 @@ +# ---------------------------------------------------------------- +# for example: +# $ PREFIX=/usr/local # for example +# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build +# +# will get +# CMAKE_MODULE_PATH +# from xo-cmake-config --cmake-module-path +# +# and expect .cmake macros in +# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake +# ---------------------------------------------------------------- + +find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) + +if ("${XO_CMAKE_CONFIG_EXECUTABLE}" STREQUAL "XO_CMAKE_CONFIG_EXECUTABLE-NOT_FOUND") + message(FATAL "could not find xo-cmake-config executable") +endif() + +message(STATUS "XO_CMAKE_CONFIG_EXECUTABLE=${XO_CMAKE_CONFIG_EXECUTABLE}") + +if (XO_SUBMODULE_BUILD) + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # local version of xo-cmake macros + set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/xo-cmake/cmake") + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() +else() + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # default to typical install location for xo-project-macros + execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() +endif() + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo_cxx) + +xo_cxx_bootstrap_message() diff --git a/xo-procedure2/cmake/xo_procedure2Config.cmake.in b/xo-procedure2/cmake/xo_procedure2Config.cmake.in new file mode 100644 index 00000000..0229c033 --- /dev/null +++ b/xo-procedure2/cmake/xo_procedure2Config.cmake.in @@ -0,0 +1,13 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# note: changes to find_dependency() calls here +# must coordinate with xo_dependency() calls +# in CMakeLists.txt +# +find_dependency(xo_gc) +find_dependency(subsys) + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/xo-procedure2/idl/Procedure.json5 b/xo-procedure2/idl/Procedure.json5 new file mode 100644 index 00000000..fb43f310 --- /dev/null +++ b/xo-procedure2/idl/Procedure.json5 @@ -0,0 +1,58 @@ +{ + mode: "facet", + // includes in ASyntaxStateMachine.hpp + includes: [ + ], + // extra includes in SyntaxStateMachine.hpp, if any + user_hpp_includes: [ + ], + namespace1: "xo", + namespace2: "scm", + // text after includes, before ASyntaxStateMachine + pretext: [ "// {pretex} here" ], + facet: "Procedure", + detail_subdir: "detail", + brief: "abstraction for a schematika procedure i.e. something callable", + using_doxygen: true, + doc: [ + "Abstraction for a schematika procedure" + ], + types: [ + { name: "AGCObject", + definition: "xo::mm::AGCObject", + doc: [ "a gc-aware object" ], + }, + // { name: string, doc: [ string ], definition: string }, + ], + const_methods: [ + { + name: "is_nary", + doc: [ "true iff procedure takes n arguments" ], + return_type: "bool", + args: [], + const: true, + noexcept: true, + attributes: [] + }, + { + name: "n_args", + doc: ["number of arguments. -1 for n-ary" ], + return_type: "std::int32_t", + args: [], + const: true, + noexcept: true, + attributes: [] + } + ], + nonconst_methods: [ + { + name: "apply_nocheck", + doc: ["invoke procedure; assume arguments satisfy type system" ], + return_type: "obj", + args: [ + {type: "obj", name: "mm"}, + {type: "const DArray *", name: "args"}, + ] + } + ], +} diff --git a/xo-procedure2/include/xo/procedure2/.gitkeep b/xo-procedure2/include/xo/procedure2/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/xo-procedure2/include/xo/procedure2/DPrimitive.hpp b/xo-procedure2/include/xo/procedure2/DPrimitive.hpp new file mode 100644 index 00000000..5e5f996c --- /dev/null +++ b/xo-procedure2/include/xo/procedure2/DPrimitive.hpp @@ -0,0 +1,94 @@ +/** @file DPrimitive.hpp + * + * @author Roland Conybeare, Jan 2025 + **/ + +#pragma once + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace xo { + namespace scm { + /** @brief Extract return type and argument types from a function type. + * + * Primary template (undefined) - specializations handle specific cases + **/ + 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; + + public: + Primitive(std::string_view name, Fn fn) : name_{name}, fn_{fn} {} + + 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{}); + } + + private: + template + obj _apply_nocheck(obj mm, + const DArray * args, + std::index_sequence) + { + using R = typename Traits::return_type; + + R result + = fn_(GCObjectConversion>::from_gco(mm, args->at(Is))... + ); + + return GCObjectConversion::to_gco(mm, result); + } + + private: + /** name of this primitive **/ + std::string_view name_; + /** function implementation **/ + Fn fn_; + }; /*Primitive*/ + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DPrimitive.hpp */ diff --git a/xo-procedure2/include/xo/procedure2/Procedure.hpp b/xo-procedure2/include/xo/procedure2/Procedure.hpp new file mode 100644 index 00000000..8b2cd91a --- /dev/null +++ b/xo-procedure2/include/xo/procedure2/Procedure.hpp @@ -0,0 +1,22 @@ +/** @file Procedure.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Procedure.json5] + * 2. jinja2 template for facet .hpp file: + * [facet.hpp.j2] + * 3. idl for facet methods + * [idl/Procedure.json5] + **/ + +#pragma once + +#include "detail/AProcedure.hpp" +#include "detail/IProcedure_Any.hpp" +#include "detail/IProcedure_Xfer.hpp" +#include "detail/RProcedure.hpp" + + +/* end Procedure.hpp */ \ No newline at end of file diff --git a/xo-procedure2/include/xo/procedure2/detail/AProcedure.hpp b/xo-procedure2/include/xo/procedure2/detail/AProcedure.hpp new file mode 100644 index 00000000..c0b22f49 --- /dev/null +++ b/xo-procedure2/include/xo/procedure2/detail/AProcedure.hpp @@ -0,0 +1,77 @@ +/** @file AProcedure.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Procedure.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [idl/Procedure.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include +#include +#include + +// {pretex} here + +namespace xo { +namespace scm { + +using Copaque = const void *; +using Opaque = void *; + +/** +Abstraction for a schematika procedure +**/ +class AProcedure { +public: + /** @defgroup scm-procedure-type-traits **/ + ///@{ + // types + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using Copaque = const void *; + using Opaque = void *; + /** a gc-aware object **/ + using AGCObject = xo::mm::AGCObject; + ///@} + + /** @defgroup scm-procedure-methods **/ + ///@{ + // const methods + /** RTTI: unique id# for actual runtime data representation **/ + virtual typeseq _typeseq() const noexcept = 0; + /** true iff procedure takes n arguments **/ + virtual bool is_nary(Copaque data) const noexcept = 0; + /** number of arguments. -1 for n-ary **/ + virtual std::int32_t n_args(Copaque data) const noexcept = 0; + + // nonconst methods + /** invoke procedure; assume arguments satisfy type system **/ + virtual obj apply_nocheck(Opaque data, obj mm, const DArray * args) = 0; + ///@} +}; /*AProcedure*/ + +/** Implementation IProcedure_DRepr of AProcedure for state DRepr + * should provide a specialization: + * + * template <> + * struct xo::facet::FacetImplementation { + * using Impltype = IProcedure_DRepr; + * }; + * + * then IProcedure_ImplType --> IProcedure_DRepr + **/ +template +using IProcedure_ImplType = xo::facet::FacetImplType; + +} /*namespace scm*/ +} /*namespace xo*/ + +/* AProcedure.hpp */ \ No newline at end of file diff --git a/xo-procedure2/include/xo/procedure2/detail/IProcedure_Any.hpp b/xo-procedure2/include/xo/procedure2/detail/IProcedure_Any.hpp new file mode 100644 index 00000000..c1b8c9d6 --- /dev/null +++ b/xo-procedure2/include/xo/procedure2/detail/IProcedure_Any.hpp @@ -0,0 +1,88 @@ +/** @file IProcedure_Any.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Procedure.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Procedure.json5] + **/ + +#pragma once + +#include "AProcedure.hpp" +#include + +namespace xo { namespace scm { class IProcedure_Any; } } + +namespace xo { +namespace facet { + +template <> +struct FacetImplementation +{ + using ImplType = xo::scm::IProcedure_Any; +}; + +} +} + +namespace xo { +namespace scm { + + /** @class IProcedure_Any + * @brief AProcedure implementation for empty variant instance + **/ + class IProcedure_Any : public AProcedure { + public: + /** @defgroup scm-procedure-any-type-traits **/ + ///@{ + + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using AGCObject = AProcedure::AGCObject; + + ///@} + /** @defgroup scm-procedure-any-methods **/ + ///@{ + + const AProcedure * iface() const { return std::launder(this); } + + // from AProcedure + + // const methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] bool is_nary(Copaque) const noexcept override { _fatal(); } + [[noreturn]] std::int32_t n_args(Copaque) const noexcept override { _fatal(); } + + // nonconst methods + [[noreturn]] obj apply_nocheck(Opaque, obj, const DArray *) override; + + ///@} + + private: + /** @defgraoup scm-procedure-any-private-methods **/ + ///@{ + + [[noreturn]] static void _fatal(); + + ///@} + + public: + /** @defgroup scm-procedure-any-member-vars **/ + ///@{ + + static typeseq s_typeseq; + static bool _valid; + + ///@} + }; + +} /*namespace scm */ +} /*namespace xo */ + +/* IProcedure_Any.hpp */ \ No newline at end of file diff --git a/xo-procedure2/include/xo/procedure2/detail/IProcedure_Xfer.hpp b/xo-procedure2/include/xo/procedure2/detail/IProcedure_Xfer.hpp new file mode 100644 index 00000000..dfe8a558 --- /dev/null +++ b/xo-procedure2/include/xo/procedure2/detail/IProcedure_Xfer.hpp @@ -0,0 +1,86 @@ +/** @file IProcedure_Xfer.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Procedure.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Procedure.json5] + **/ + +#pragma once + + +namespace xo { +namespace scm { + /** @class IProcedure_Xfer + **/ + template + class IProcedure_Xfer : public AProcedure { + public: + /** @defgroup scm-procedure-xfer-type-traits **/ + ///@{ + /** actual implementation (not generated; often delegates to DRepr) **/ + using Impl = IProcedure_DRepr; + /** integer identifying a type **/ + using typeseq = AProcedure::typeseq; + using AGCObject = AProcedure::AGCObject; + ///@} + + /** @defgroup scm-procedure-xfer-methods **/ + ///@{ + + static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; } + static DRepr & _dcast(Opaque d) { return *(DRepr *)d; } + + // from AProcedure + + // const methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + bool is_nary(Copaque data) const noexcept override { + return I::is_nary(_dcast(data)); + } + std::int32_t n_args(Copaque data) const noexcept override { + return I::n_args(_dcast(data)); + } + + // non-const methods + obj apply_nocheck(Opaque data, obj mm, const DArray * args) override { + return I::apply_nocheck(_dcast(data), mm, args); + } + + ///@} + + private: + using I = Impl; + + public: + /** @defgroup scm-procedure-xfer-member-vars **/ + ///@{ + + /** typeseq for template parameter DRepr **/ + static typeseq s_typeseq; + /** true iff satisfies facet implementation **/ + static bool _valid; + + ///@} + }; + + template + xo::facet::typeseq + IProcedure_Xfer::s_typeseq + = xo::facet::typeseq::id(); + + template + bool + IProcedure_Xfer::_valid + = xo::facet::valid_facet_implementation(); + +} /*namespace scm */ +} /*namespace xo*/ + +/* end IProcedure_Xfer.hpp */ \ No newline at end of file diff --git a/xo-procedure2/include/xo/procedure2/detail/RProcedure.hpp b/xo-procedure2/include/xo/procedure2/detail/RProcedure.hpp new file mode 100644 index 00000000..dc0f30d8 --- /dev/null +++ b/xo-procedure2/include/xo/procedure2/detail/RProcedure.hpp @@ -0,0 +1,86 @@ +/** @file RProcedure.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Procedure.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Procedure.json5] + **/ + +#pragma once + +#include "AProcedure.hpp" + +namespace xo { +namespace scm { + +/** @class RProcedure + **/ +template +class RProcedure : public Object { +private: + using O = Object; + +public: + /** @defgroup scm-procedure-router-type-traits **/ + ///@{ + using ObjectType = Object; + using DataPtr = Object::DataPtr; + using typeseq = xo::reflect::typeseq; + using AGCObject = AProcedure::AGCObject; + ///@} + + /** @defgroup scm-procedure-router-ctors **/ + ///@{ + RProcedure() {} + RProcedure(Object::DataPtr data) : Object{std::move(data)} {} + RProcedure(const AProcedure * iface, void * data) + requires std::is_same_v + : Object(iface, data) {} + + ///@} + /** @defgroup scm-procedure-router-methods **/ + ///@{ + + // const methods + typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + bool is_nary() const noexcept { + return O::iface()->is_nary(O::data()); + } + std::int32_t n_args() const noexcept { + return O::iface()->n_args(O::data()); + } + + // non-const methods (still const in router!) + obj apply_nocheck(obj mm, const DArray * args) { + return O::iface()->apply_nocheck(O::data(), mm, args); + } + + ///@} + /** @defgroup scm-procedure-member-vars **/ + ///@{ + + static bool _valid; + + ///@} +}; + +template +bool +RProcedure::_valid = xo::facet::valid_object_router(); + +} /*namespace scm*/ +} /*namespace xo*/ + +namespace xo { namespace facet { + template + struct RoutingFor { + using RoutingType = xo::scm::RProcedure; + }; +} } + +/* end RProcedure.hpp */ \ 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 new file mode 100644 index 00000000..d4150d2d --- /dev/null +++ b/xo-procedure2/include/xo/procedure2/init_primitives.hpp @@ -0,0 +1,29 @@ +/** @file init_primitives.hpp **/ + +#pragma once + +#include "DPrimitive.hpp" + +namespace xo { + namespace scm { + using Primitive_f64_1_f64 = Primitive; + using Primitive_f64_2_f64_f64 = Primitive; + + struct Primitives { + static Primitive_f64_1_f64 s_neg_f64_pm; + + static Primitive_f64_2_f64_f64 s_add_f64_f64_pm; + static Primitive_f64_2_f64_f64 s_sub_f64_f64_pm; + static Primitive_f64_2_f64_f64 s_mul_f64_f64_pm; + static Primitive_f64_2_f64_f64 s_div_f64_f64_pm; + static Primitive_f64_2_f64_f64 s_pow_f64_f64_pm; + + static Primitive_f64_1_f64 s_log_f64_pm; + static Primitive_f64_1_f64 s_sin_f64_pm; + static Primitive_f64_1_f64 s_cos_f64_pm; + static Primitive_f64_1_f64 s_tan_f64_pm; + }; + } +} + +/* end init_primitives.hpp */ diff --git a/xo-procedure2/include/xo/procedure2/init_procedure2.hpp b/xo-procedure2/include/xo/procedure2/init_procedure2.hpp new file mode 100644 index 00000000..793cc061 --- /dev/null +++ b/xo-procedure2/include/xo/procedure2/init_procedure2.hpp @@ -0,0 +1,21 @@ +/** @file init_procedure2.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + /* tag to represent the xo-procedure2/ subsystem within ordered iniitalization */ + enum S_procedure2_tag {}; + + template <> + struct InitSubsys { + static void init(); + static InitEvidence require(); + }; +} /*namespace xo*/ + +/* end init_procedure2.hpp */ diff --git a/xo-procedure2/include/xo/procedure2/primitives.hpp b/xo-procedure2/include/xo/procedure2/primitives.hpp new file mode 100644 index 00000000..e2e0d88a --- /dev/null +++ b/xo-procedure2/include/xo/procedure2/primitives.hpp @@ -0,0 +1,13 @@ +/** @file primitives.hpp **/ + +#pragma once + +namespace xo { + namespace scm { + struct Primitives { + static void init_primitives(); + }; + } +} + +/* end primitives.hpp */ diff --git a/xo-procedure2/src/procedure2/CMakeLists.txt b/xo-procedure2/src/procedure2/CMakeLists.txt new file mode 100644 index 00000000..edc5d3ce --- /dev/null +++ b/xo-procedure2/src/procedure2/CMakeLists.txt @@ -0,0 +1,26 @@ +# xo-procedure2/src/CMakeLists.txt + +set(SELF_LIB xo_procedure2) +set(SELF_SRCS + init_procedure2.cpp + init_primitives.cpp + DPrimitive.cpp + # Add source files here, e.g.: + # procedure2.cpp +) + +xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) +xo_install_include_tree3(include/xo/procedure2) + +# ---------------------------------------------------------------- +# input dependencies +# +# NOTE: dependency set here must be kept consistent with +# xo-procedure2/cmake/xo_procedure2Config.cmake.in + +xo_dependency(${SELF_LIB} xo_object2) +xo_dependency(${SELF_LIB} xo_gc) +xo_dependency(${SELF_LIB} subsys) +#xo_dependency(${SELF_LIB} xo_indentlog) + +# end src/CMakeLists.txt diff --git a/xo-procedure2/src/procedure2/DPrimitive.cpp b/xo-procedure2/src/procedure2/DPrimitive.cpp new file mode 100644 index 00000000..ab335d8d --- /dev/null +++ b/xo-procedure2/src/procedure2/DPrimitive.cpp @@ -0,0 +1,16 @@ +/** @file DPrimitive.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DPrimitive.hpp" +#include + +namespace xo { + namespace scm { + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DPrimitive.cpp */ diff --git a/xo-procedure2/src/procedure2/IProcedure_Any.cpp b/xo-procedure2/src/procedure2/IProcedure_Any.cpp new file mode 100644 index 00000000..3044c104 --- /dev/null +++ b/xo-procedure2/src/procedure2/IProcedure_Any.cpp @@ -0,0 +1,47 @@ +/** @file IProcedure_Any.cpp + * + **/ + +#include "detail/IProcedure_Any.hpp" +#include + +namespace xo { +namespace scm { + +using xo::facet::DVariantPlaceholder; +using xo::facet::typeseq; +using xo::facet::valid_facet_implementation; + +void +IProcedure_Any::_fatal() +{ + /* control here on uninitialized IAllocator_Any. + * Initialized instance will have specific implementation type + */ + std::cerr << "fatal" + << ": attempt to call uninitialized" + << " IProcedure_Any method" + << std::endl; + std::terminate(); +} + +typeseq +IProcedure_Any::s_typeseq = typeseq::id(); + +bool +IProcedure_Any::_valid + = valid_facet_implementation(); + +// nonconst methods + +auto +IProcedure_Any::apply_nocheck(Opaque, obj, const DArray *) -> obj +{ + _fatal(); +} + + +} /*namespace scm*/ +} /*namespace xo*/ + +/* end IProcedure_Any.cpp */ \ No newline at end of file diff --git a/xo-procedure2/src/procedure2/init_primitives.cpp b/xo-procedure2/src/procedure2/init_primitives.cpp new file mode 100644 index 00000000..169b660e --- /dev/null +++ b/xo-procedure2/src/procedure2/init_primitives.cpp @@ -0,0 +1,95 @@ +/** @file init_primitives.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_primitives.hpp" +#include "DPrimitive.hpp" + +namespace xo { + namespace scm { + double + neg_f64(double x) { + return -x; + } + + double + add_f64_f64(double x, double y) { + return x + y; + } + + double + sub_f64_f64(double x, double y) { + return x - y; + } + + double + mul_f64_f64(double x, double y) { + return x * y; + } + + double + div_f64_f64(double x, double y) { + return x / y; + } + + double + pow_f64_f64(double x, double y) { + return ::pow(x, y); + } + + double + log_f64(double x) { + return ::log(x); + } + + double + sin_f64(double x) { + return ::sin(x); + } + + double + cos_f64(double x) { + return ::cos(x); + } + + double + tan_f64(double x) { + return ::tan(x); + } + + Primitive_f64_1_f64 + Primitives::s_neg_f64_pm("_neg_d", + &neg_f64); + + Primitive_f64_2_f64_f64 + Primitives::s_add_f64_f64_pm("_add_d_d", &add_f64_f64); + + Primitive_f64_2_f64_f64 + Primitives::s_sub_f64_f64_pm("_sub_d_d", &sub_f64_f64); + + Primitive_f64_2_f64_f64 + Primitives::s_mul_f64_f64_pm("_mul_d_d", &mul_f64_f64); + + Primitive_f64_2_f64_f64 + Primitives::s_div_f64_f64_pm("_div_d_d", &div_f64_f64); + + Primitive_f64_2_f64_f64 + Primitives::s_pow_f64_f64_pm("_pow_d_d", &pow_f64_f64); + + Primitive_f64_1_f64 + Primitives::s_log_f64_pm("_log_d", &log_f64); + + Primitive_f64_1_f64 + Primitives::s_sin_f64_pm("_sin_d", &sin_f64); + + Primitive_f64_1_f64 + Primitives::s_cos_f64_pm("_cos_d", &cos_f64); + + Primitive_f64_1_f64 + Primitives::s_tan_f64_pm("_tan_d", &tan_f64); + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end init_primitives.cpp */ diff --git a/xo-procedure2/src/procedure2/init_procedure2.cpp b/xo-procedure2/src/procedure2/init_procedure2.cpp new file mode 100644 index 00000000..fc316653 --- /dev/null +++ b/xo-procedure2/src/procedure2/init_procedure2.cpp @@ -0,0 +1,32 @@ +/** @file init_procedure2.cpp + * + * @author Roland Conybeare, Jan 2026 +**/ + +#include "init_procedure2.hpp" +#include "init_primitives.hpp" +//#include "procedure2_register_facets.hpp" +//#include "procedure2_register_types.hpp" +#include + +namespace xo { + using xo::scm::Primitives; + + void + InitSubsys::init() + { + } + + InitEvidence + InitSubsys::require() + { + InitEvidence retval; + + /* xo-procedure2/'s own initialization code */ + retval ^= Subsystem::provide("procedure2", &init); + + return retval; + } +} /*namespace xo*/ + +/* end init_procedure2.cpp */