60 template<
typename TFDecl>
61 typename TFDecl::Signature
62 Get(
bool isInvocation )
const;
73 template<
typename TFDecl>
requires std::same_as<TFDecl, FAppend<character,lang::HeapAllocator>>
77 template<
typename TFDecl>
requires ( !std::same_as<TFDecl, FHashcode >
78 && !std::same_as<TFDecl, FIsNotNull>
79 && !std::same_as<TFDecl, FEquals >
80 && !std::same_as<TFDecl, FIsLess >
81 && !std::same_as<TFDecl, FIsTrue >
83 && !std::same_as<TFDecl, FClone >
86 && !std::same_as<TFDecl, FAppend<character,lang::HeapAllocator>>
88 )
typename TFDecl::Signature
Get(
ALIB_DBG(
bool isInvocation ))
const {
89return reinterpret_cast<typename TFDecl::Signature
>(
getCustom(
typeid(TFDecl)
ALIB_DBG(, isInvocation ) ) );
103 template<
typename TFDecl>
104 void Set(
typename TFDecl::Signature implementation );
106 template<
typename TFDecl>
requires std::same_as<TFDecl, FHashcode >
void Set( FHashcode ::Signature impl) {
fHashcode = impl; }
108 template<
typename TFDecl>
requires std::same_as<TFDecl, FEquals >
void Set( FEquals ::Signature impl) {
fEquals = impl; }
109 template<
typename TFDecl>
requires std::same_as<TFDecl, FIsLess >
void Set( FIsLess ::Signature impl) {
fIsLess = impl; }
110 template<
typename TFDecl>
requires std::same_as<TFDecl, FIsTrue >
void Set( FIsTrue ::Signature impl) {
fIsTrue = impl; }
112 template<
typename TFDecl>
requires std::same_as<TFDecl, FClone >
void Set( FClone ::Signature impl) {
fClone = impl; }
115 template<
typename TFDecl>
requires std::same_as<TFDecl,
117 ::Signature impl) {
fAppend = impl; }
120 template<
typename TFDecl>
requires ( !std::same_as<TFDecl, FHashcode >
121 && !std::same_as<TFDecl, FIsNotNull>
122 && !std::same_as<TFDecl, FEquals >
123 && !std::same_as<TFDecl, FIsLess >
124 && !std::same_as<TFDecl, FIsTrue >
126 && !std::same_as<TFDecl, FClone >
129 && !std::same_as<TFDecl, FAppend<character,lang::HeapAllocator> >
132 void Set(
typename TFDecl::Signature impl )
133 {
return setCustom(
typeid(TFDecl),
reinterpret_cast<void*
>( impl ) ); }
139 #if (ALIB_MONOMEM && ALIB_CONTAINERS && ALIB_DEBUG) || DOXYGEN
161 ALIB_DBG( ,
bool isInvocation ))
const;
180struct CustomFunctionKey {
181 const FunctionTable* Parent;
182 const std::type_info&
Type;
183 CustomFunctionKey(
const FunctionTable* parent,
const std::type_info& type )
184 : Parent(parent),
Type (type ) {}
187struct CustomFunctionMapped {
188 void* Implementation;
189 ALIB_DBG(uinteger DbgCntInvocations; )
191 CustomFunctionMapped(
void* implementation ): Implementation (implementation)
192ALIB_DBG(,DbgCntInvocations (0 ) ) {}
195struct CustomFunctionHash {
196 std::size_t operator()(
const CustomFunctionKey& key)
const {
197 size_t result=
reinterpret_cast<size_t>(key.Parent)
198 ^ key.Type.hash_code();
199 result^= (result << 21 );
200 result^= (result >> 11);
204struct CustomFunctionEqualTo {
205 bool operator()(
const CustomFunctionKey& lhs,
const CustomFunctionKey& rhs)
const {
206 return lhs.Parent == rhs.Parent
207 && lhs.Type == rhs.Type;
210#if ALIB_MONOMEM && ALIB_CONTAINERS
212 CustomFunctionKey, CustomFunctionMapped,
214 CustomFunctionEqualTo > customFunctionMap;
216extern std::unordered_map< CustomFunctionKey, CustomFunctionMapped,
218 CustomFunctionEqualTo > customFunctionMap;
296 const std::type_info& elementType,
298 unsigned int placeholderUsage )
371template<
typename TMapped,
bool TIsArray>
373 ,
public Singleton< VTableUnoptimized<TMapped, TIsArray> >
386 :
VTable( !TIsArray ? typeid(TMapped)
387 : typeid(TMapped[1]),
389 !TIsArray ? typeid(void)
393 : std::is_pointer_v<TMapped>
395 : std::is_enum_v<TMapped>
401 #if ALIB_DEBUG_BOXING
408#if ALIB_DEBUG_BOXING || DOXYGEN
462template<
typename TMapped,
bool TIsArray>
477#if ALIB_DEBUG && !DOXYGEN
479# if ALIB_MONOMEM && ALIB_CONTAINERS
484 extern std::unordered_set< lang::TypeFunctors::Key, lang::TypeFunctors::Hash, lang::TypeFunctors::EqualTo> DbgKnownCustomFunctions;
485 extern std::unordered_map< lang::TypeFunctors::Key, detail::VTable*, lang::TypeFunctors::Hash, lang::TypeFunctors::EqualTo> DbgKnownVTables;
486 extern std::unordered_map< lang::TypeFunctors::Key, detail::VTable*, lang::TypeFunctors::Hash, lang::TypeFunctors::EqualTo> DbgKnownVTablesArray;
488extern ALIB_DLL void DbgLockMaps(
bool doLock );
496DOX_MARKER([DOX_BOXING_OPTIMIZE_DECLARE_2])
498DOX_MARKER([DOX_BOXING_OPTIMIZE_DECLARE_2])
constexpr VTableUnoptimized()
static T & GetSingleton()
#define ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE(TMapped, Identifier)
ALIB_DLL void DbgCheckIsInitialized()
void DbgRegisterVTable(detail::VTable *vtable, detail::VTable::DbgFactoryType productionType)
ALIB_DLL void DbgCheckRegistration(detail::VTable *vtable, bool increaseUsageCounter)
This namespace implements internals of namespace alib::boxing.
FunctionTable DEFAULT_FUNCTIONS
The default box-functions set.
constexpr unsigned SizeTraits
std::conditional_t< ArrayTraits< T, nchar >::Access !=Policy::NONE, nchar, std::conditional_t< ArrayTraits< T, wchar >::Access !=Policy::NONE, wchar, std::conditional_t< ArrayTraits< T, xchar >::Access !=Policy::NONE, xchar, void > > > Type
containers::HashSet< TAllocator, T, THash, TEqual, THashCaching, TRecycling > HashSet
Type alias in namespace alib. See type definition alib::containers::HashSet.
singletons::Singleton< T > Singleton
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
containers::HashMap< TAllocator, TKey, TMapped, THash, TEqual, THashCaching, TRecycling > HashMap
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
lang::uinteger uinteger
Type alias in namespace alib.
boxing::FAppend< TChar, TAllocator > FAppend
Type alias in namespace alib.
bool(*)(const Box &self) Signature
static constexpr detail::VTable * Get()
ALIB_DLL void setCustom(const std::type_info &rtti, void *implementation)
uinteger DbgCntInvocationsFHashcode
Debug-compilation counter for the number of invocations.
uinteger DbgCntInvocationsFIsTrue
Debug-compilation counter for the number of invocations.
void Set(typename TFDecl::Signature implementation)
TFDecl::Signature Get(bool isInvocation) const
FIsNotNull::Signature fIsNotNull
Entry for built-in function FIsNotNull.
FAppend< character, lang::HeapAllocator > ::Signature fAppend
< Entry for built-in function FAppend.
uinteger DbgCntInvocationsFIsLess
Debug-compilation counter for the number of invocations.
FIsTrue::Signature fIsTrue
Entry for built-in function FIsTrue.
FIsLess::Signature fIsLess
Entry for built-in function FIsLess.
ALIB_DLL void * getCustom(const std::type_info &rtti, bool isInvocation) const
FEquals::Signature fEquals
Entry for built-in function FEquals.
uinteger DbgCntInvocationsFIsNotNull
Debug-compilation counter for the number of invocations.
uinteger DbgCntInvocationsFEquals
Debug-compilation counter for the number of invocations.
FClone::Signature fClone
Entry for built-in function FClone.
uinteger DbgCntInvocationsFClone
Debug-compilation counter for the number of invocations.
uinteger DbgCntInvocationsFAppend
Debug-compilation counter for the number of invocations.
FHashcode::Signature fHashcode
Entry for built-in function FHashcode.
static ALIB_DLL void Shutdown()
Needs to be called only in debug versions to shut down internal hashtables cleanly.
The custom function hash.
FunctionTable Functions
Box-functions attached with BootstrapRegister.
const unsigned int PlaceholderUsage
const std::type_info & ElementType
VTable(const std::type_info &type, const std::type_info &elementType, MappingType mapping, unsigned int placeholderUsage)
DbgFactoryType DbgProduction
Debug information.
const MappingType Mapping
@ Static
A static VTable is in place.
@ Unregistered
Not registered, yet.
const std::type_info & Type