xo-reader2 stack: + xo-numeric + setup multi dispatch for *,/
This commit is contained in:
parent
b8fd087319
commit
ac1395ce98
28 changed files with 912 additions and 70 deletions
|
|
@ -29,14 +29,32 @@ xo_add_genfacet(
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
# note: manual target; generated code committed to git
|
||||||
|
xo_add_genfacetimpl(
|
||||||
|
TARGET xo-numeric-facetimpl-numeric-float
|
||||||
|
FACET_PKG xo_numeric
|
||||||
|
FACET Numeric
|
||||||
|
REPR Float
|
||||||
|
INPUT idl/INumeric_DFloat.json5
|
||||||
|
)
|
||||||
|
|
||||||
|
# note: manual target; generated code committed to git
|
||||||
|
xo_add_genfacetimpl(
|
||||||
|
TARGET xo-numeric-facetimpl-numeric-integer
|
||||||
|
FACET_PKG xo_numeric
|
||||||
|
FACET Numeric
|
||||||
|
REPR Integer
|
||||||
|
INPUT idl/INumeric_DInteger.json5
|
||||||
|
)
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
xo_add_genfacet_all(xo-numeric-genfacet-all)
|
xo_add_genfacet_all(xo-numeric-genfacet-all)
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
#add_subdirectory(src/numeric) # NOTE: will need cmake export here
|
add_subdirectory(src/numeric)
|
||||||
#add_subdirectory(utest)
|
add_subdirectory(utest)
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
# cmake export
|
# cmake export
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
/** @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 */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@ include(CMakeFindDependencyMacro)
|
||||||
# in CMakeLists.txt
|
# in CMakeLists.txt
|
||||||
#
|
#
|
||||||
#find_dependency(xo_gc)
|
#find_dependency(xo_gc)
|
||||||
find_dependency(xo_facet)
|
find_dependency(xo_procedure2)
|
||||||
find_dependency(subsys)
|
find_dependency(subsys)
|
||||||
#find_dependency(indentlog)
|
#find_dependency(indentlog)
|
||||||
|
|
||||||
|
|
|
||||||
18
idl/INumeric_DFloat.json5
Normal file
18
idl/INumeric_DFloat.json5
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
mode: "implementation",
|
||||||
|
output_cpp_dir: "src/numeric",
|
||||||
|
output_hpp_dir: "include/xo/numeric",
|
||||||
|
output_impl_subdir: "float",
|
||||||
|
includes: [
|
||||||
|
// "<xo/printable2/Printable.hpp>",
|
||||||
|
// "<xo/printable2/detail/IPrintable_Xfer.hpp>"
|
||||||
|
],
|
||||||
|
local_types: [ ],
|
||||||
|
namespace1: "xo",
|
||||||
|
namespace2: "scm",
|
||||||
|
facet_idl: "idl/Numeric.json5",
|
||||||
|
brief: "provide ANumeric interface for DFloat",
|
||||||
|
using_doxygen: true,
|
||||||
|
repr: "DFloat",
|
||||||
|
doc: [ "implement ANumeric for DFloat" ],
|
||||||
|
}
|
||||||
18
idl/INumeric_DInteger.json5
Normal file
18
idl/INumeric_DInteger.json5
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
mode: "implementation",
|
||||||
|
output_cpp_dir: "src/numeric",
|
||||||
|
output_hpp_dir: "include/xo/numeric",
|
||||||
|
output_impl_subdir: "integer",
|
||||||
|
includes: [
|
||||||
|
// "<xo/printable2/Printable.hpp>",
|
||||||
|
// "<xo/printable2/detail/IPrintable_Xfer.hpp>"
|
||||||
|
],
|
||||||
|
local_types: [ ],
|
||||||
|
namespace1: "xo",
|
||||||
|
namespace2: "scm",
|
||||||
|
facet_idl: "idl/Numeric.json5",
|
||||||
|
brief: "provide ANumeric interface for DInteger",
|
||||||
|
using_doxygen: true,
|
||||||
|
repr: "DInteger",
|
||||||
|
doc: [ "implement ANumeric for DInteger" ],
|
||||||
|
}
|
||||||
42
include/xo/numeric/FloatIntegerOps.hpp
Normal file
42
include/xo/numeric/FloatIntegerOps.hpp
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
/** @file FloatIntegerOps.hpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Numeric.hpp"
|
||||||
|
#include <xo/procedure2/RuntimeContext.hpp>
|
||||||
|
#include <xo/object2/Float.hpp>
|
||||||
|
#include <xo/object2/Integer.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
class FloatIntegerOps {
|
||||||
|
public:
|
||||||
|
using AGCObject = xo::mm::AGCObject;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static obj<AGCObject> multiply(obj<ARuntimeContext> rcx,
|
||||||
|
DFloat * x, DInteger * y);
|
||||||
|
static obj<AGCObject> divide(obj<ARuntimeContext> rcx,
|
||||||
|
DFloat * x, DInteger * y);
|
||||||
|
};
|
||||||
|
|
||||||
|
class IntegerFloatOps {
|
||||||
|
public:
|
||||||
|
using AGCObject = xo::mm::AGCObject;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static obj<AGCObject> multiply(obj<ARuntimeContext> rcx,
|
||||||
|
DInteger * x, DFloat * y);
|
||||||
|
static obj<AGCObject> divide(obj<ARuntimeContext> rcx,
|
||||||
|
DInteger * x, DFloat * y);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end FloatIntegerOps.hpp */
|
||||||
30
include/xo/numeric/FloatOps.hpp
Normal file
30
include/xo/numeric/FloatOps.hpp
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/** @file FloatOps.hpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Numeric.hpp"
|
||||||
|
#include <xo/procedure2/RuntimeContext.hpp>
|
||||||
|
#include <xo/object2/Float.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
class FloatOps {
|
||||||
|
public:
|
||||||
|
using AGCObject = xo::mm::AGCObject;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static obj<AGCObject> multiply(obj<ARuntimeContext> rcx,
|
||||||
|
DFloat * x, DFloat * y);
|
||||||
|
static obj<AGCObject> divide(obj<ARuntimeContext> rcx,
|
||||||
|
DFloat * x, DFloat * y);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end FloatOps.hpp */
|
||||||
31
include/xo/numeric/IntegerOps.hpp
Normal file
31
include/xo/numeric/IntegerOps.hpp
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
/** @file IntegerOps.hpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Numeric.hpp"
|
||||||
|
#include <xo/procedure2/RuntimeContext.hpp>
|
||||||
|
#include <xo/object2/Integer.hpp>
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
class IntegerOps {
|
||||||
|
public:
|
||||||
|
using AGCObject = xo::mm::AGCObject;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static obj<AGCObject> multiply(obj<ARuntimeContext> rcx,
|
||||||
|
DInteger * x, DInteger * y);
|
||||||
|
|
||||||
|
static obj<AGCObject> divide(obj<ARuntimeContext> rcx,
|
||||||
|
DInteger * x, DInteger * y);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end IntegerOps.hpp */
|
||||||
|
|
@ -5,13 +5,93 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "NumericOps.hpp"
|
||||||
|
#include <xo/procedure2/RuntimeContext.hpp>
|
||||||
|
#include <xo/gc/GCObject.hpp>
|
||||||
|
#include <xo/arena/DArenaHashMap.hpp>
|
||||||
|
#include <xo/reflectutil/typeseq.hpp>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
namespace scm {
|
namespace scm {
|
||||||
|
|
||||||
|
/** Runtime polymoprhic multimethod dispatch.
|
||||||
|
* Hash on argument types to get function table
|
||||||
|
**/
|
||||||
class NumericDispatch {
|
class NumericDispatch {
|
||||||
public:
|
public:
|
||||||
|
//using AAllocator = xo::mm::AAllocator;
|
||||||
|
using AGCObject = xo::mm::AGCObject;
|
||||||
|
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
|
||||||
|
using typeseq = xo::reflect::typeseq;
|
||||||
|
using KeyType = std::pair<typeseq, typeseq>;
|
||||||
|
using MappedType = AnonymizedNumericOps;
|
||||||
|
|
||||||
|
/** hash function for key_type **/
|
||||||
|
struct KeyHash {
|
||||||
|
|
||||||
|
std::size_t operator()(const KeyType & 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 << 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
using MapType = xo::map::DArenaHashMap<KeyType,
|
||||||
|
MappedType,
|
||||||
|
KeyHash,
|
||||||
|
std::equal_to<void>>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
NumericDispatch(uint32_t hint_max_capacity)
|
||||||
|
: dispatch_{"numeric-dispatch",
|
||||||
|
hint_max_capacity,
|
||||||
|
false /*!debug_flag*/} {}
|
||||||
|
|
||||||
|
/** @p hint_max_capacity only honored the first time instance()
|
||||||
|
* is called.
|
||||||
|
**/
|
||||||
|
static NumericDispatch & instance(uint32_t hint_max_capacity = 64) {
|
||||||
|
static NumericDispatch s_instance(hint_max_capacity);
|
||||||
|
return s_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** multiply w/ runtime polymorphism (double-dispatch)
|
||||||
|
**/
|
||||||
|
static obj<AGCObject> multiply(obj<ARuntimeContext> rcx,
|
||||||
|
obj<AGCObject> x,
|
||||||
|
obj<AGCObject> y);
|
||||||
|
|
||||||
|
/** divide w/ runtime polymorphism (double-dispatch)
|
||||||
|
**/
|
||||||
|
static obj<AGCObject> divide(obj<ARuntimeContext> rcx,
|
||||||
|
obj<AGCObject> x,
|
||||||
|
obj<AGCObject> y);
|
||||||
|
|
||||||
|
/** report memory use for owned arenas to @p visitor **/
|
||||||
|
void visit_pools(const MemorySizeVisitor & visitor);
|
||||||
|
|
||||||
|
/** Use:
|
||||||
|
* Need to have overload
|
||||||
|
* multiply(obj<AAllocator>, DRepr1, DRepr2) -> obj<ANumeric>
|
||||||
|
* available
|
||||||
|
**/
|
||||||
|
template <typename DRepr1, typename DRepr2>
|
||||||
|
void register_impl(typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl mul_fn,
|
||||||
|
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl div_fn) {
|
||||||
|
|
||||||
|
KeyType key(typeseq::id<DRepr1>().seqno(),
|
||||||
|
typeseq::id<DRepr2>().seqno());
|
||||||
|
|
||||||
|
// note: copying op table so they're in proximity
|
||||||
|
this->dispatch_[key] = NumericOps<DRepr1, DRepr2>::make(mul_fn, div_fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** 2d dispatch for arithmetic **/
|
||||||
|
MapType dispatch_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,52 @@
|
||||||
/** @file NumericOps.hpp
|
/** @file NumericOps.hpp
|
||||||
*
|
*
|
||||||
* @author Roland Conybeare, Feb 2026
|
* @author Roland Conybeare, Feb 2026
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Numeric.hpp"
|
#include <xo/numeric/Numeric.hpp>
|
||||||
|
#include <xo/procedure2/RuntimeContext.hpp>
|
||||||
|
#include <xo/gc/GCObject.hpp>
|
||||||
|
#include <xo/facet/obj.hpp>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
namespace scm {
|
namespace scm {
|
||||||
|
class AnonymizedNumericOps {
|
||||||
class INumericOps {
|
|
||||||
public:
|
public:
|
||||||
using BinaryOp1 = obj<ANumeric> (*)(obj<AAllocator> mm, void * x, void * y);
|
using ARuntimeContext = xo::scm::ARuntimeContext;
|
||||||
|
using AGCObject = xo::mm::AGCObject;
|
||||||
|
using BinaryOp = obj<AGCObject> (*)(obj<ARuntimeContext> mm, void * x, void * y);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit INumericOp9s(BinaryOp1 multiply) : multiply_{multiply} {}
|
/** note: null ctor load-bearing for membership in DArenaHashTable **/
|
||||||
|
AnonymizedNumericOps() = default;
|
||||||
|
/** @p multiply to multiply (x,y); allocate from mm **/
|
||||||
|
explicit AnonymizedNumericOps(BinaryOp multiply,
|
||||||
|
BinaryOp divide)
|
||||||
|
: multiply_{multiply}, divide_{divide} {}
|
||||||
|
|
||||||
/** multiply (x,y); allocate from mm **/
|
BinaryOp multiply_ = nullptr;
|
||||||
BinaryOp1 multiply_;
|
BinaryOp divide_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Convenience template. To use, provide implementation
|
|
||||||
* for
|
|
||||||
* _multiply() ...
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
template <typename DRepr1, typename DRepr2>
|
template <typename DRepr1, typename DRepr2>
|
||||||
class NumericOps : public INumericOps {
|
class NumericOps {
|
||||||
public:
|
public:
|
||||||
using BinaryOp1_Impl = obj<ANumeric> (*)(obj<AAllocator> mm, DRepr1 * x, DRepr2 * y);
|
using ARuntimeContext = xo::scm::ARuntimeContext;
|
||||||
|
using AGCObject = xo::mm::AGCObject;
|
||||||
|
using BinaryOp_Impl = obj<AGCObject> (*)(obj<ARuntimeContext> rcx, DRepr1 * x, DRepr2 * y);
|
||||||
|
using BinaryOp_Anon = AnonymizedNumericOps::BinaryOp;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NumericOps(BinaryOp1_Impl multiply)
|
static AnonymizedNumericOps make(BinaryOp_Impl multiply,
|
||||||
: INumericOps(reinterpret_cast<INumericOps::BinaryOp1>(multiply))
|
BinaryOp_Impl divide) {
|
||||||
{}
|
return AnonymizedNumericOps(reinterpret_cast<BinaryOp_Anon>(multiply),
|
||||||
|
reinterpret_cast<BinaryOp_Anon>(divide));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
||||||
/* end NumericOps.hpp */
|
/* end NumericOps.hpp */
|
||||||
|
|
||||||
|
|
|
||||||
23
include/xo/numeric/NumericPrimitives.hpp
Normal file
23
include/xo/numeric/NumericPrimitives.hpp
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
/** @file NumericDispatch.hpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <xo/procedure2/DPrimitive_gco_2_gco_gco.hpp>
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
/** @brief primitives using multidispatch
|
||||||
|
**/
|
||||||
|
class NumericPrimitives {
|
||||||
|
public:
|
||||||
|
/** poly divide **/
|
||||||
|
static DPrimitive_gco_2_gco_gco s_div_gco_gco_pm;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end NumericDispatch.hpp */
|
||||||
56
include/xo/numeric/float/INumeric_DFloat.hpp
Normal file
56
include/xo/numeric/float/INumeric_DFloat.hpp
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
/** @file INumeric_DFloat.hpp
|
||||||
|
*
|
||||||
|
* Generated automagically from ingredients:
|
||||||
|
* 1. code generator:
|
||||||
|
* [xo-facet/codegen/genfacet]
|
||||||
|
* arguments:
|
||||||
|
* --input [idl/INumeric_DFloat.json5]
|
||||||
|
* 2. jinja2 template for abstract facet .hpp file:
|
||||||
|
* [iface_facet_repr.hpp.j2]
|
||||||
|
* 3. idl for facet methods
|
||||||
|
* [idl/INumeric_DFloat.json5]
|
||||||
|
**/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Numeric.hpp"
|
||||||
|
#include "DFloat.hpp"
|
||||||
|
|
||||||
|
namespace xo { namespace scm { class INumeric_DFloat; } }
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace facet {
|
||||||
|
template <>
|
||||||
|
struct FacetImplementation<xo::scm::ANumeric,
|
||||||
|
xo::scm::DFloat>
|
||||||
|
{
|
||||||
|
using ImplType = xo::scm::INumeric_Xfer
|
||||||
|
<xo::scm::DFloat,
|
||||||
|
xo::scm::INumeric_DFloat>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace scm {
|
||||||
|
/** @class INumeric_DFloat
|
||||||
|
**/
|
||||||
|
class INumeric_DFloat {
|
||||||
|
public:
|
||||||
|
/** @defgroup scm-numeric-dfloat-type-traits **/
|
||||||
|
///@{
|
||||||
|
using Copaque = xo::scm::ANumeric::Copaque;
|
||||||
|
using Opaque = xo::scm::ANumeric::Opaque;
|
||||||
|
///@}
|
||||||
|
/** @defgroup scm-numeric-dfloat-methods **/
|
||||||
|
///@{
|
||||||
|
// const methods
|
||||||
|
|
||||||
|
// non-const methods
|
||||||
|
///@}
|
||||||
|
};
|
||||||
|
|
||||||
|
} /*namespace scm*/
|
||||||
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
/* end */
|
||||||
21
include/xo/numeric/init_numeric.hpp
Normal file
21
include/xo/numeric/init_numeric.hpp
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
/** @file init_numeric.hpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <xo/subsys/Subsystem.hpp>
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
/* tag to represent the xo-numeric/ subsystem within ordered initialization */
|
||||||
|
enum S_numeric_tag {};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct InitSubsys<S_numeric_tag> {
|
||||||
|
static void init();
|
||||||
|
static InitEvidence require();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end init_numeric.hpp */
|
||||||
56
include/xo/numeric/integer/INumeric_DInteger.hpp
Normal file
56
include/xo/numeric/integer/INumeric_DInteger.hpp
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
/** @file INumeric_DInteger.hpp
|
||||||
|
*
|
||||||
|
* Generated automagically from ingredients:
|
||||||
|
* 1. code generator:
|
||||||
|
* [xo-facet/codegen/genfacet]
|
||||||
|
* arguments:
|
||||||
|
* --input [idl/INumeric_DInteger.json5]
|
||||||
|
* 2. jinja2 template for abstract facet .hpp file:
|
||||||
|
* [iface_facet_repr.hpp.j2]
|
||||||
|
* 3. idl for facet methods
|
||||||
|
* [idl/INumeric_DInteger.json5]
|
||||||
|
**/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Numeric.hpp"
|
||||||
|
#include "DInteger.hpp"
|
||||||
|
|
||||||
|
namespace xo { namespace scm { class INumeric_DInteger; } }
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace facet {
|
||||||
|
template <>
|
||||||
|
struct FacetImplementation<xo::scm::ANumeric,
|
||||||
|
xo::scm::DInteger>
|
||||||
|
{
|
||||||
|
using ImplType = xo::scm::INumeric_Xfer
|
||||||
|
<xo::scm::DInteger,
|
||||||
|
xo::scm::INumeric_DInteger>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace scm {
|
||||||
|
/** @class INumeric_DInteger
|
||||||
|
**/
|
||||||
|
class INumeric_DInteger {
|
||||||
|
public:
|
||||||
|
/** @defgroup scm-numeric-dinteger-type-traits **/
|
||||||
|
///@{
|
||||||
|
using Copaque = xo::scm::ANumeric::Copaque;
|
||||||
|
using Opaque = xo::scm::ANumeric::Opaque;
|
||||||
|
///@}
|
||||||
|
/** @defgroup scm-numeric-dinteger-methods **/
|
||||||
|
///@{
|
||||||
|
// const methods
|
||||||
|
|
||||||
|
// non-const methods
|
||||||
|
///@}
|
||||||
|
};
|
||||||
|
|
||||||
|
} /*namespace scm*/
|
||||||
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
/* end */
|
||||||
16
include/xo/numeric/numeric_register_facets.hpp
Normal file
16
include/xo/numeric/numeric_register_facets.hpp
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
/** @file numeric_register_facets.hpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace scm {
|
||||||
|
/** Setup numeric facet dispatch **/
|
||||||
|
bool numeric_register_facets();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end numeric_register_facets.hpp */
|
||||||
25
src/numeric/CMakeLists.txt
Normal file
25
src/numeric/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# numeric/CMakeLists.txt
|
||||||
|
|
||||||
|
set(SELF_LIB xo_numeric)
|
||||||
|
set(SELF_SRCS
|
||||||
|
init_numeric.cpp
|
||||||
|
numeric_register_facets.cpp
|
||||||
|
NumericPrimitives.cpp
|
||||||
|
NumericDispatch.cpp
|
||||||
|
INumeric_Any.cpp
|
||||||
|
FloatIntegerOps.cpp
|
||||||
|
FloatOps.cpp
|
||||||
|
IntegerOps.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})
|
||||||
|
xo_dependency(${SELF_LIB} xo_procedure2)
|
||||||
|
xo_dependency(${SELF_LIB} subsys)
|
||||||
|
|
||||||
|
xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets)
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# docs targets depend on other library/utest/exec targets above,
|
||||||
|
# --> must come after them.
|
||||||
|
#
|
||||||
|
#add_subdirectory(docs)
|
||||||
48
src/numeric/FloatIntegerOps.cpp
Normal file
48
src/numeric/FloatIntegerOps.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
/** @file FloatIntegerOps.cp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2206
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "FloatIntegerOps.hpp"
|
||||||
|
#include "float/INumeric_DFloat.hpp"
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
using xo::mm::AGCObject;
|
||||||
|
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
// ----- Float op Integer -----
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
FloatIntegerOps::multiply(obj<ARuntimeContext> rcx,
|
||||||
|
DFloat * x, DInteger * y)
|
||||||
|
{
|
||||||
|
return DFloat::box<AGCObject>(rcx.allocator(), x->value() * y->value());
|
||||||
|
}
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
FloatIntegerOps::divide(obj<ARuntimeContext> rcx,
|
||||||
|
DFloat * x, DInteger * y)
|
||||||
|
{
|
||||||
|
return DFloat::box<AGCObject>(rcx.allocator(), x->value() / y->value());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----- Integer op Float -----
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
IntegerFloatOps::multiply(obj<ARuntimeContext> rcx,
|
||||||
|
DInteger * x, DFloat * y)
|
||||||
|
{
|
||||||
|
return DFloat::box<AGCObject>(rcx.allocator(), x->value() * y->value());
|
||||||
|
}
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
IntegerFloatOps::divide(obj<ARuntimeContext> rcx,
|
||||||
|
DInteger * x, DFloat * y)
|
||||||
|
{
|
||||||
|
return DFloat::box<AGCObject>(rcx.allocator(), x->value() / y->value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end FloatIntegerOps.cpp */
|
||||||
31
src/numeric/FloatOps.cpp
Normal file
31
src/numeric/FloatOps.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
/** @file FloatOps.cp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2206
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "FloatOps.hpp"
|
||||||
|
#include "float/INumeric_DFloat.hpp"
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
using xo::mm::AGCObject;
|
||||||
|
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
FloatOps::multiply(obj<ARuntimeContext> rcx,
|
||||||
|
DFloat * x, DFloat * y)
|
||||||
|
{
|
||||||
|
return DFloat::box<AGCObject>(rcx.allocator(), x->value() * y->value());
|
||||||
|
}
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
FloatOps::divide(obj<ARuntimeContext> rcx,
|
||||||
|
DFloat * x, DFloat * y)
|
||||||
|
{
|
||||||
|
return DFloat::box<AGCObject>(rcx.allocator(), x->value() / y->value());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end FloatOps.cpp */
|
||||||
22
src/numeric/INumeric_DFloat.cpp
Normal file
22
src/numeric/INumeric_DFloat.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
/** @file INumeric_DFloat.cpp
|
||||||
|
*
|
||||||
|
* Generated automagically from ingredients:
|
||||||
|
* 1. code generator:
|
||||||
|
* [xo-facet/codegen/genfacet]
|
||||||
|
* arguments:
|
||||||
|
* --input [idl/INumeric_DFloat.json5]
|
||||||
|
* 2. jinja2 template for abstract facet .hpp file:
|
||||||
|
* [iface_facet_any.hpp.j2]
|
||||||
|
* 3. idl for facet methods
|
||||||
|
* [idl/INumeric_DFloat.json5]
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "float/INumeric_DFloat.hpp"
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
} /*namespace scm*/
|
||||||
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
/* end INumeric_DFloat.cpp */
|
||||||
22
src/numeric/INumeric_DInteger.cpp
Normal file
22
src/numeric/INumeric_DInteger.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
/** @file INumeric_DInteger.cpp
|
||||||
|
*
|
||||||
|
* Generated automagically from ingredients:
|
||||||
|
* 1. code generator:
|
||||||
|
* [xo-facet/codegen/genfacet]
|
||||||
|
* arguments:
|
||||||
|
* --input [idl/INumeric_DInteger.json5]
|
||||||
|
* 2. jinja2 template for abstract facet .hpp file:
|
||||||
|
* [iface_facet_any.hpp.j2]
|
||||||
|
* 3. idl for facet methods
|
||||||
|
* [idl/INumeric_DInteger.json5]
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "integer/INumeric_DInteger.hpp"
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
} /*namespace scm*/
|
||||||
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
/* end INumeric_DInteger.cpp */
|
||||||
31
src/numeric/IntegerOps.cpp
Normal file
31
src/numeric/IntegerOps.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
/** @file IntegerOps.cpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "IntegerOps.hpp"
|
||||||
|
#include "integer/INumeric_DInteger.hpp"
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
using xo::mm::AGCObject;
|
||||||
|
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
IntegerOps::multiply(obj<ARuntimeContext> rcx,
|
||||||
|
DInteger * x, DInteger * y)
|
||||||
|
{
|
||||||
|
return DInteger::box<AGCObject>(rcx.allocator(), x->value() * y->value());
|
||||||
|
}
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
IntegerOps::divide(obj<ARuntimeContext> rcx,
|
||||||
|
DInteger * x, DInteger * y)
|
||||||
|
{
|
||||||
|
return DInteger::box<AGCObject>(rcx.allocator(), x->value() / y->value());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end IntegerOps.cpp */
|
||||||
59
src/numeric/NumericDispatch.cpp
Normal file
59
src/numeric/NumericDispatch.cpp
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
/** @file NumericDispatch.cpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "NumericDispatch.hpp"
|
||||||
|
#include <xo/indentlog/scope.hpp>
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
using xo::mm::AGCObject;
|
||||||
|
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
void
|
||||||
|
NumericDispatch::visit_pools(const MemorySizeVisitor & visitor)
|
||||||
|
{
|
||||||
|
dispatch_.visit_pools(visitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
NumericDispatch::multiply(obj<ARuntimeContext> rcx,
|
||||||
|
obj<AGCObject> x,
|
||||||
|
obj<AGCObject> y)
|
||||||
|
{
|
||||||
|
KeyType key(x._typeseq(), y._typeseq());
|
||||||
|
|
||||||
|
auto target_fn
|
||||||
|
= NumericDispatch::instance().dispatch_[key].multiply_;
|
||||||
|
|
||||||
|
return (*target_fn)(rcx, x.data(), y.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
NumericDispatch::divide(obj<ARuntimeContext> rcx,
|
||||||
|
obj<AGCObject> x,
|
||||||
|
obj<AGCObject> y)
|
||||||
|
{
|
||||||
|
scope log(XO_DEBUG(true));
|
||||||
|
|
||||||
|
KeyType key(x._typeseq(), y._typeseq());
|
||||||
|
|
||||||
|
log && log(xtag("x.tseq", x._typeseq().seqno()),
|
||||||
|
xtag("y.tseq", y._typeseq().seqno()));
|
||||||
|
|
||||||
|
auto target_fn
|
||||||
|
= NumericDispatch::instance().dispatch_[key].divide_;
|
||||||
|
|
||||||
|
log && log(xtag("target_fn", target_fn));
|
||||||
|
|
||||||
|
assert(target_fn);
|
||||||
|
|
||||||
|
return (*target_fn)(rcx, x.data(), y.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} /*namespace scm*/
|
||||||
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
/* end NumericDispatch.cpp **/
|
||||||
22
src/numeric/NumericPrimitives.cpp
Normal file
22
src/numeric/NumericPrimitives.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
/** @file NumericPrimitives.cpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "NumericPrimitives.hpp"
|
||||||
|
#include "NumericDispatch.hpp"
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
using xo::mm::AGCObject;
|
||||||
|
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
DPrimitive_gco_2_gco_gco
|
||||||
|
NumericPrimitives::s_div_gco_gco_pm("_div",
|
||||||
|
&NumericDispatch::divide);
|
||||||
|
|
||||||
|
|
||||||
|
} /*namespace scm*/
|
||||||
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
/* end NumericDispatch.cpp */
|
||||||
36
src/numeric/init_numeric.cpp
Normal file
36
src/numeric/init_numeric.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
/** @file init_numeric.cpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "init_numeric.hpp"
|
||||||
|
#include <xo/procedure2/init_procedure2.hpp>
|
||||||
|
#include "Subsystem.hpp"
|
||||||
|
#include "numeric_register_facets.hpp"
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
using xo::scm::numeric_register_facets;
|
||||||
|
|
||||||
|
void
|
||||||
|
InitSubsys<S_numeric_tag>::init()
|
||||||
|
{
|
||||||
|
numeric_register_facets();
|
||||||
|
}
|
||||||
|
|
||||||
|
InitEvidence
|
||||||
|
InitSubsys<S_numeric_tag>::require()
|
||||||
|
{
|
||||||
|
InitEvidence retval;
|
||||||
|
|
||||||
|
/* direct subsystem deps for xo-numeric/ */
|
||||||
|
retval ^= InitSubsys<S_procedure2_tag>::require();
|
||||||
|
|
||||||
|
/* xo-numeric/'s own initialization code */
|
||||||
|
retval ^= Subsystem::provide<S_numeric_tag>("numeric", &init);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
/* end init_numeric.cpp */
|
||||||
61
src/numeric/numeric_register_facets.cpp
Normal file
61
src/numeric/numeric_register_facets.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
/** @file numeric_register_facets.cpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "numeric_register_facets.hpp"
|
||||||
|
#include "NumericDispatch.hpp"
|
||||||
|
#include "Numeric.hpp"
|
||||||
|
|
||||||
|
#include "FloatIntegerOps.hpp"
|
||||||
|
#include "FloatOps.hpp"
|
||||||
|
#include "float/INumeric_DFloat.hpp"
|
||||||
|
|
||||||
|
#include "IntegerOps.hpp"
|
||||||
|
#include "integer/INumeric_DInteger.hpp"
|
||||||
|
|
||||||
|
#include <xo/object2/DFloat.hpp>
|
||||||
|
#include <xo/object2/Integer.hpp>
|
||||||
|
|
||||||
|
#include <xo/facet/FacetRegistry.hpp>
|
||||||
|
#include <xo/reflectutil/typeseq.hpp>
|
||||||
|
#include <xo/indentlog/scope.hpp>
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
using xo::facet::FacetRegistry;
|
||||||
|
using xo::reflect::typeseq;
|
||||||
|
|
||||||
|
namespace scm {
|
||||||
|
|
||||||
|
bool
|
||||||
|
numeric_register_facets()
|
||||||
|
{
|
||||||
|
scope log(XO_DEBUG(true));
|
||||||
|
|
||||||
|
FacetRegistry::register_impl<ANumeric, DInteger>();
|
||||||
|
|
||||||
|
NumericDispatch::instance().register_impl<DFloat, DFloat>
|
||||||
|
(&FloatOps::multiply,
|
||||||
|
&FloatOps::divide);
|
||||||
|
|
||||||
|
NumericDispatch::instance().register_impl<DFloat, DInteger>
|
||||||
|
(&FloatIntegerOps::multiply,
|
||||||
|
&FloatIntegerOps::divide);
|
||||||
|
|
||||||
|
NumericDispatch::instance().register_impl<DInteger, DFloat>
|
||||||
|
(&IntegerFloatOps::multiply,
|
||||||
|
&IntegerFloatOps::divide);
|
||||||
|
|
||||||
|
NumericDispatch::instance().register_impl<DInteger, DInteger>
|
||||||
|
(&IntegerOps::multiply,
|
||||||
|
&IntegerOps::divide);
|
||||||
|
|
||||||
|
log && log(xtag("ANumeric.tseq", typeseq::id<ANumeric>()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /*namespace scm*/
|
||||||
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
/* end numeric_register_facets.cpp */
|
||||||
12
utest/CMakeLists.txt
Normal file
12
utest/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# built unittest xo-numeric/utest
|
||||||
|
|
||||||
|
set(UTEST_EXE utest.numeric)
|
||||||
|
set(UTEST_SRCS
|
||||||
|
numeric_utest_main.cpp
|
||||||
|
Numeric.test.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS})
|
||||||
|
xo_self_dependency(${UTEST_EXE} xo_numeric)
|
||||||
|
#xo_dependency(${UTEST_EXE} randomgen)
|
||||||
|
xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2)
|
||||||
76
utest/Numeric.test.cpp
Normal file
76
utest/Numeric.test.cpp
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
/** @file Numeric.test.cpp
|
||||||
|
*
|
||||||
|
* @author Roland Conybeare, Feb 2026
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "init_numeric.hpp"
|
||||||
|
#include "NumericDispatch.hpp"
|
||||||
|
#include <xo/facet/FacetRegistry.hpp>
|
||||||
|
#include <xo/facet/TypeRegistry.hpp>
|
||||||
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
|
namespace xo {
|
||||||
|
using xo::scm::NumericDispatch;
|
||||||
|
//using xo::mm::AAllocator;
|
||||||
|
using xo::mm::DArena;
|
||||||
|
using xo::mm::ArenaConfig;;
|
||||||
|
using xo::mm::MemorySizeInfo;
|
||||||
|
using xo::facet::FacetRegistry;
|
||||||
|
using xo::facet::TypeRegistry;
|
||||||
|
//using xo::facet::with_facet;
|
||||||
|
//using xo::facet::obj;
|
||||||
|
|
||||||
|
namespace ut {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
struct Fixture {
|
||||||
|
explicit Fixture(const std::string & testname,
|
||||||
|
std::size_t aux_arena_size = 16 * 1024)
|
||||||
|
: aux_arena_(
|
||||||
|
ArenaConfig().with_name(testname).with_size(aux_arena_size))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
bool log_memory_layout(scope * p_log) {
|
||||||
|
auto visitor = [p_log](const MemorySizeInfo & info) {
|
||||||
|
*p_log && (*p_log)(xtag("resource", info.resource_name_),
|
||||||
|
xtag("used", info.used_),
|
||||||
|
xtag("alloc", info.allocated_),
|
||||||
|
xtag("commit", info.committed_),
|
||||||
|
xtag("resv", info.reserved_));
|
||||||
|
};
|
||||||
|
|
||||||
|
aux_arena_.visit_pools(visitor);
|
||||||
|
TypeRegistry::instance().visit_pools(visitor);
|
||||||
|
FacetRegistry::instance().visit_pools(visitor);
|
||||||
|
NumericDispatch::instance().visit_pools(visitor);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DArena aux_arena_;
|
||||||
|
};
|
||||||
|
} /*namespace*/
|
||||||
|
|
||||||
|
static InitEvidence s_init = (InitSubsys<S_numeric_tag>::require());
|
||||||
|
|
||||||
|
TEST_CASE("Numeric-init" "[numeric]")
|
||||||
|
{
|
||||||
|
const auto & testname = Catch::getResultCapture().getCurrentTestName();
|
||||||
|
|
||||||
|
constexpr bool c_debug_flag = true;
|
||||||
|
scope log(XO_DEBUG(c_debug_flag), xtag("test", testname));
|
||||||
|
|
||||||
|
Fixture fixture(testname);
|
||||||
|
{
|
||||||
|
// real purpose: ensure s_init sutvives static linking
|
||||||
|
REQUIRE(s_init.evidence());
|
||||||
|
}
|
||||||
|
|
||||||
|
log && fixture.log_memory_layout(&log);
|
||||||
|
}
|
||||||
|
|
||||||
|
} /*namespace ut*/
|
||||||
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
/* end Numeric.test.cpp */
|
||||||
24
utest/numeric_utest_main.cpp
Normal file
24
utest/numeric_utest_main.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
/* file numeric_utest_main.cpp */
|
||||||
|
|
||||||
|
#include <xo/subsys/Subsystem.hpp>
|
||||||
|
|
||||||
|
#define CATCH_CONFIG_RUNNER
|
||||||
|
#include "catch2/catch.hpp"
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
using xo::Subsystem;
|
||||||
|
|
||||||
|
// Your custom initialization code here
|
||||||
|
Subsystem::initialize_all();
|
||||||
|
|
||||||
|
// Run Catch2's test session
|
||||||
|
int result = Catch::Session().run(argc, argv);
|
||||||
|
|
||||||
|
// cleanup here, if any
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end numeric_utest_main.cpp */
|
||||||
Loading…
Add table
Add a link
Reference in a new issue