+ xo-numeric/ [WIP]
This commit is contained in:
parent
77546db923
commit
b8fd087319
13 changed files with 661 additions and 0 deletions
42
CMakeLists.txt
Normal file
42
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# xo-numeric/CMakeLists.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(xo_numeric 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-numeric-facet-numeric
|
||||
FACET Numeric
|
||||
INPUT idl/Numeric.json5
|
||||
)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
xo_add_genfacet_all(xo-numeric-genfacet-all)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
#add_subdirectory(src/numeric) # NOTE: will need cmake export here
|
||||
#add_subdirectory(utest)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# cmake export
|
||||
|
||||
|
||||
44
NumericDispatch.hpp
Normal file
44
NumericDispatch.hpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/** @file NumericDispatch.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
//#include <xo/facet/FacetRegistry.hpp> // probably will need this at some point?
|
||||
#include <xo/arena/DArenaHashMap.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
/** type-erased arithmetic dispatch.
|
||||
**/
|
||||
struct NumericOps {
|
||||
obj<ANumeric>
|
||||
};
|
||||
|
||||
class NumericDispatch {
|
||||
public:
|
||||
using KeyType = std::pair<typeseq, typeseq>;
|
||||
using MapType = xo::map::DArenaHashMap<KeyType, MappedType, KeyHash>
|
||||
|
||||
/** combine two typeseq's to get hash value **/
|
||||
struct KeyHash {
|
||||
std::size_t operator()(const key_type & k) const noexcept {
|
||||
// combine the two seqno values
|
||||
std::size_t h1 = std::hash<int32_t>{}(k.first.seqno());
|
||||
std::size_t h2 = std::hash<int32_t>{}(k.second.seqno());
|
||||
return h1 ^ (h2 << 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end NumericDispqatch.hpp */
|
||||
|
||||
|
||||
41
cmake/xo-bootstrap-macros.cmake
Normal file
41
cmake/xo-bootstrap-macros.cmake
Normal file
|
|
@ -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()
|
||||
15
cmake/xo_numericConfig.cmake.in
Normal file
15
cmake/xo_numericConfig.cmake.in
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
@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(xo_facet)
|
||||
find_dependency(subsys)
|
||||
#find_dependency(indentlog)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
75
idl/Numeric.json5
Normal file
75
idl/Numeric.json5
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
// can regenerate downstream .*pp files with either:
|
||||
// cmake --build -- xo-numeric-facet-procedure
|
||||
// cmake --build -- xo-numeric-genfacet-all
|
||||
|
||||
{
|
||||
mode: "facet",
|
||||
output_cpp_dir: "src/numeric",
|
||||
output_hpp_dir: "include/xo/numeric",
|
||||
output_impl_subdir: "detail",
|
||||
// includes in ASyntaxStateMachine.hpp
|
||||
includes: [
|
||||
// "\"RuntimeContext.hpp\"",
|
||||
// "<xo/gc/GCObject.hpp>",
|
||||
],
|
||||
// extra includes in Procedure.hpp, if any
|
||||
user_hpp_includes: [
|
||||
],
|
||||
namespace1: "xo",
|
||||
namespace2: "scm",
|
||||
// text after includes, before ASyntaxStateMachine
|
||||
pretext: [
|
||||
//"namespace xo { namespace scm { class ARuntimeContext; } }",
|
||||
//"namespace xo { namespace scm { class DArray; } }",
|
||||
],
|
||||
facet: "Numeric",
|
||||
detail_subdir: "detail",
|
||||
brief: "abstraction for a schematika numeric i.e. something that can participate in arithmetic",
|
||||
using_doxygen: true,
|
||||
doc: [
|
||||
"Abstraction for a schematika numeric"
|
||||
],
|
||||
types: [
|
||||
// {
|
||||
// name: "AGCObject",
|
||||
// definition: "xo::mm::AGCObject",
|
||||
// doc: [ "a gc-aware object" ],
|
||||
// },
|
||||
// { name: string, doc: [ string ], definition: string },
|
||||
],
|
||||
const_methods: [
|
||||
// {
|
||||
// name: "multiply",
|
||||
// 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<AGCObject>",
|
||||
// args: [
|
||||
// {type: "obj<ARuntimeContext>", name: "rcx"},
|
||||
// {type: "const DArray *", name: "args"},
|
||||
// ]
|
||||
// }
|
||||
],
|
||||
router_facet_explicit_content: [
|
||||
// this doesn't seem to show up anywhere
|
||||
"static obj<ANumeric> multiply(obj<ANumeric> lhs, obj<ANumeric> rhs);"
|
||||
],
|
||||
}
|
||||
22
include/xo/numeric/Numeric.hpp
Normal file
22
include/xo/numeric/Numeric.hpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/** @file Numeric.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Numeric.json5]
|
||||
* 2. jinja2 template for facet .hpp file:
|
||||
* [facet.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Numeric.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "detail/ANumeric.hpp"
|
||||
#include "detail/INumeric_Any.hpp"
|
||||
#include "detail/INumeric_Xfer.hpp"
|
||||
#include "detail/RNumeric.hpp"
|
||||
|
||||
|
||||
/* end Numeric.hpp */
|
||||
20
include/xo/numeric/NumericDispatch.hpp
Normal file
20
include/xo/numeric/NumericDispatch.hpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/** @file NumericDispatch.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
class NumericDispatch {
|
||||
public:
|
||||
|
||||
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end NumericDispatch.hpp */
|
||||
44
include/xo/numeric/NumericOps.hpp
Normal file
44
include/xo/numeric/NumericOps.hpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/** @file NumericOps.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Numeric.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
class INumericOps {
|
||||
public:
|
||||
using BinaryOp1 = obj<ANumeric> (*)(obj<AAllocator> mm, void * x, void * y);
|
||||
|
||||
public:
|
||||
explicit INumericOp9s(BinaryOp1 multiply) : multiply_{multiply} {}
|
||||
|
||||
/** multiply (x,y); allocate from mm **/
|
||||
BinaryOp1 multiply_;
|
||||
};
|
||||
|
||||
/** Convenience template. To use, provide implementation
|
||||
* for
|
||||
* _multiply() ...
|
||||
*
|
||||
**/
|
||||
template <typename DRepr1, typename DRepr2>
|
||||
class NumericOps : public INumericOps {
|
||||
public:
|
||||
using BinaryOp1_Impl = obj<ANumeric> (*)(obj<AAllocator> mm, DRepr1 * x, DRepr2 * y);
|
||||
|
||||
public:
|
||||
explicit NumericOps(BinaryOp1_Impl multiply)
|
||||
: INumericOps(reinterpret_cast<INumericOps::BinaryOp1>(multiply))
|
||||
{}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end NumericOps.hpp */
|
||||
|
||||
70
include/xo/numeric/detail/ANumeric.hpp
Normal file
70
include/xo/numeric/detail/ANumeric.hpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/** @file ANumeric.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Numeric.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [abstract_facet.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Numeric.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
// includes (via {facet_includes})
|
||||
#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 *;
|
||||
|
||||
/**
|
||||
Abstraction for a schematika numeric
|
||||
**/
|
||||
class ANumeric {
|
||||
public:
|
||||
/** @defgroup scm-numeric-type-traits **/
|
||||
///@{
|
||||
// types
|
||||
/** integer identifying a type **/
|
||||
using typeseq = xo::facet::typeseq;
|
||||
using Copaque = const void *;
|
||||
using Opaque = void *;
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-numeric-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** RTTI: unique id# for actual runtime data representation **/
|
||||
virtual typeseq _typeseq() const noexcept = 0;
|
||||
/** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/
|
||||
virtual void _drop(Opaque d) const noexcept = 0;
|
||||
|
||||
// nonconst methods
|
||||
///@}
|
||||
}; /*ANumeric*/
|
||||
|
||||
/** Implementation INumeric_DRepr of ANumeric for state DRepr
|
||||
* should provide a specialization:
|
||||
*
|
||||
* template <>
|
||||
* struct xo::facet::FacetImplementation<ANumeric, DRepr> {
|
||||
* using Impltype = INumeric_DRepr;
|
||||
* };
|
||||
*
|
||||
* then INumeric_ImplType<DRepr> --> INumeric_DRepr
|
||||
**/
|
||||
template <typename DRepr>
|
||||
using INumeric_ImplType = xo::facet::FacetImplType<ANumeric, DRepr>;
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* ANumeric.hpp */
|
||||
87
include/xo/numeric/detail/INumeric_Any.hpp
Normal file
87
include/xo/numeric/detail/INumeric_Any.hpp
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/** @file INumeric_Any.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Numeric.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Numeric.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ANumeric.hpp"
|
||||
#include <xo/facet/obj.hpp>
|
||||
|
||||
namespace xo { namespace scm { class INumeric_Any; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
|
||||
template <>
|
||||
struct FacetImplementation<xo::scm::ANumeric,
|
||||
DVariantPlaceholder>
|
||||
{
|
||||
using ImplType = xo::scm::INumeric_Any;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
/** @class INumeric_Any
|
||||
* @brief ANumeric implementation for empty variant instance
|
||||
**/
|
||||
class INumeric_Any : public ANumeric {
|
||||
public:
|
||||
/** @defgroup scm-numeric-any-type-traits **/
|
||||
///@{
|
||||
|
||||
/** integer identifying a type **/
|
||||
using typeseq = xo::facet::typeseq;
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-numeric-any-methods **/
|
||||
///@{
|
||||
|
||||
const ANumeric * iface() const { return std::launder(this); }
|
||||
|
||||
// from ANumeric
|
||||
|
||||
// builtin methods
|
||||
typeseq _typeseq() const noexcept override { return s_typeseq; }
|
||||
[[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); }
|
||||
|
||||
// const methods
|
||||
|
||||
// nonconst methods
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
/** @defgraoup scm-numeric-any-private-methods **/
|
||||
///@{
|
||||
|
||||
[[noreturn]] static void _fatal();
|
||||
|
||||
///@}
|
||||
|
||||
public:
|
||||
/** @defgroup scm-numeric-any-member-vars **/
|
||||
///@{
|
||||
|
||||
static typeseq s_typeseq;
|
||||
static bool _valid;
|
||||
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm */
|
||||
} /*namespace xo */
|
||||
|
||||
/* INumeric_Any.hpp */
|
||||
79
include/xo/numeric/detail/INumeric_Xfer.hpp
Normal file
79
include/xo/numeric/detail/INumeric_Xfer.hpp
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/** @file INumeric_Xfer.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Numeric.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Numeric.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** @class INumeric_Xfer
|
||||
**/
|
||||
template <typename DRepr, typename INumeric_DRepr>
|
||||
class INumeric_Xfer : public ANumeric {
|
||||
public:
|
||||
/** @defgroup scm-numeric-xfer-type-traits **/
|
||||
///@{
|
||||
/** actual implementation (not generated; often delegates to DRepr) **/
|
||||
using Impl = INumeric_DRepr;
|
||||
/** integer identifying a type **/
|
||||
using typeseq = ANumeric::typeseq;
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-numeric-xfer-methods **/
|
||||
///@{
|
||||
|
||||
static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; }
|
||||
static DRepr & _dcast(Opaque d) { return *(DRepr *)d; }
|
||||
|
||||
// from ANumeric
|
||||
|
||||
// builtin methods
|
||||
typeseq _typeseq() const noexcept override { return s_typeseq; }
|
||||
void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); }
|
||||
|
||||
// const methods
|
||||
|
||||
// non-const methods
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
using I = Impl;
|
||||
|
||||
public:
|
||||
/** @defgroup scm-numeric-xfer-member-vars **/
|
||||
///@{
|
||||
|
||||
/** typeseq for template parameter DRepr **/
|
||||
static typeseq s_typeseq;
|
||||
/** true iff satisfies facet implementation **/
|
||||
static bool _valid;
|
||||
|
||||
///@}
|
||||
};
|
||||
|
||||
template <typename DRepr, typename INumeric_DRepr>
|
||||
xo::facet::typeseq
|
||||
INumeric_Xfer<DRepr, INumeric_DRepr>::s_typeseq
|
||||
= xo::facet::typeseq::id<DRepr>();
|
||||
|
||||
template <typename DRepr, typename INumeric_DRepr>
|
||||
bool
|
||||
INumeric_Xfer<DRepr, INumeric_DRepr>::_valid
|
||||
= xo::facet::valid_facet_implementation<ANumeric,
|
||||
INumeric_Xfer>();
|
||||
|
||||
} /*namespace scm */
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end INumeric_Xfer.hpp */
|
||||
81
include/xo/numeric/detail/RNumeric.hpp
Normal file
81
include/xo/numeric/detail/RNumeric.hpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/** @file RNumeric.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Numeric.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Numeric.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ANumeric.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
/** @class RNumeric
|
||||
**/
|
||||
template <typename Object>
|
||||
class RNumeric : public Object {
|
||||
private:
|
||||
using O = Object;
|
||||
|
||||
public:
|
||||
/** @defgroup scm-numeric-router-type-traits **/
|
||||
///@{
|
||||
using ObjectType = Object;
|
||||
using DataPtr = Object::DataPtr;
|
||||
using typeseq = xo::reflect::typeseq;
|
||||
///@}
|
||||
|
||||
/** @defgroup scm-numeric-router-ctors **/
|
||||
///@{
|
||||
RNumeric() {}
|
||||
RNumeric(Object::DataPtr data) : Object{std::move(data)} {}
|
||||
RNumeric(const ANumeric * iface, void * data)
|
||||
requires std::is_same_v<typename Object::DataType, xo::facet::DVariantPlaceholder>
|
||||
: Object(iface, data) {}
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-numeric-router-methods **/
|
||||
///@{
|
||||
|
||||
// explicit injected content
|
||||
|
||||
// builtin methods
|
||||
typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); }
|
||||
void _drop() const noexcept { O::iface()->_drop(O::data()); }
|
||||
|
||||
// const methods
|
||||
|
||||
// non-const methods (still const in router!)
|
||||
|
||||
///@}
|
||||
/** @defgroup scm-numeric-member-vars **/
|
||||
///@{
|
||||
|
||||
static bool _valid;
|
||||
|
||||
///@}
|
||||
};
|
||||
|
||||
template <typename Object>
|
||||
bool
|
||||
RNumeric<Object>::_valid = xo::facet::valid_object_router<Object>();
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
namespace xo { namespace facet {
|
||||
template <typename Object>
|
||||
struct RoutingFor<xo::scm::ANumeric, Object> {
|
||||
using RoutingType = xo::scm::RNumeric<Object>;
|
||||
};
|
||||
} }
|
||||
|
||||
/* end RNumeric.hpp */
|
||||
41
src/numeric/INumeric_Any.cpp
Normal file
41
src/numeric/INumeric_Any.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/** @file INumeric_Any.cpp
|
||||
*
|
||||
**/
|
||||
|
||||
#include "detail/INumeric_Any.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
||||
using xo::facet::DVariantPlaceholder;
|
||||
using xo::facet::typeseq;
|
||||
using xo::facet::valid_facet_implementation;
|
||||
|
||||
void
|
||||
INumeric_Any::_fatal()
|
||||
{
|
||||
/* control here on uninitialized IAllocator_Any.
|
||||
* Initialized instance will have specific implementation type
|
||||
*/
|
||||
std::cerr << "fatal"
|
||||
<< ": attempt to call uninitialized"
|
||||
<< " INumeric_Any method"
|
||||
<< std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
typeseq
|
||||
INumeric_Any::s_typeseq = typeseq::id<DVariantPlaceholder>();
|
||||
|
||||
bool
|
||||
INumeric_Any::_valid
|
||||
= valid_facet_implementation<ANumeric, INumeric_Any>();
|
||||
|
||||
// nonconst methods
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end INumeric_Any.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue