29#       include <unordered_map> 
   30#       include <unordered_set> 
   38namespace alib {  
namespace boxing { 
namespace detail {
 
   50    extern std::unordered_set<TypeFunctors::Key                 , TypeFunctors::Hash, TypeFunctors::EqualTo>  DbgKnownCustomFunctions;
 
   51           std::unordered_set<TypeFunctors::Key                 , TypeFunctors::Hash, TypeFunctors::EqualTo>  DbgKnownCustomFunctions;
 
   52    extern std::unordered_map<TypeFunctors::Key, detail::VTable*, TypeFunctors::Hash, TypeFunctors::EqualTo>  DbgKnownVTables;
 
   53           std::unordered_map<TypeFunctors::Key, detail::VTable*, TypeFunctors::Hash, TypeFunctors::EqualTo>  DbgKnownVTables;
 
   54    extern std::unordered_map<TypeFunctors::Key, detail::VTable*, TypeFunctors::Hash, TypeFunctors::EqualTo>  DbgKnownVTablesArray;
 
   55           std::unordered_map<TypeFunctors::Key, detail::VTable*, TypeFunctors::Hash, TypeFunctors::EqualTo>  DbgKnownVTablesArray;
 
   62    void DbgLockMaps( 
bool doLock );
 
   63    void DbgLockMaps( 
bool doLock )
 
   69            ALIB_DBG(dbgLock.Dbg.Name= 
"DbgBoxing";)
 
   87                DbgKnownVTables.InsertUnique( std::make_pair( &vtable->
Type, vtable ) );
 
   89                if ( DbgKnownVTables.find( &vtable->
Type ) != DbgKnownVTables.end() )
 
   91                    ALIB_ERROR( 
"BOXING", 
"Double instantiation of VTable of Type: \"",
 
   92                                DbgTypeDemangler( vtable->
Type ).Get(), 
"\"" )
 
   97                DbgKnownVTables.insert(std::make_pair( &vtable->
Type, vtable ) );
 
  104                DbgKnownVTablesArray.InsertUnique(std::make_pair( &vtable->
ElementType, vtable ) );
 
  106                if ( DbgKnownVTablesArray.find( &vtable->
ElementType ) != DbgKnownVTablesArray.end() )
 
  108                    ALIB_ERROR( 
"BOXING", 
"Double instantiation of VTable of Type: \"",
 
  109                                DbgTypeDemangler( vtable->
ElementType ).Get(), 
"[]\"" )
 
  114                DbgKnownVTablesArray.insert(std::make_pair( &vtable->
ElementType, vtable ) );
 
 
  133        while( (idx= 
string.IndexOf(search, startIndex) ) >= 0 )
 
  134            string.Delete( idx, search.Length() );
 
 
  141    A_CHAR( 
"alib::boxing::" ),
 
  147    auto startLength= result.
Length();
 
  149        result <<  vtable->
Type;
 
 
  172                           bool                     isValueTypeCustomized,
 
  173                           bool                     isPointerTypeCustomized,
 
  174                           bool                     fitsToPlaceholder,
 
  175                           bool                     copyConstructible,
 
  176                           bool                     triviallyDestructible,
 
  189        target << indent << 
"Mapped Type:    "; 
typeName(vtable, target ); target << 
" (Enumeration)"  << 
NEW_LINE;
 
  190        target << indent << 
"Customized:     Not customizable (always boxed as enum value type)"       << 
NEW_LINE;
 
  196        bool arrayBoxing  =  vtable->
IsArray();
 
  197        bool srcIsValue   =  !srcIsPointer;
 
  199        target << indent << 
"Mapped Type:    "; 
typeName(vtable, target ); target << 
NEW_LINE;
 
  201        target <<indent << 
"Customized T:   " << isValueTypeCustomized            << 
NEW_LINE;
 
  202        target <<indent << 
"Customized T*:  " << isPointerTypeCustomized          << 
NEW_LINE;
 
  203        target <<indent << 
"Is Unboxable:   " 
  205                   ? (     srcIsValue   && valueBoxing   && isValueTypeCustomized
 
  206                        ?  
"Yes (By customization)" 
  208                        :  srcIsValue   && valueBoxing   && !isValueTypeCustomized
 
  209                        ?  
"Yes (Value fits in placeholder and is copy constructible)" 
  211                        :  srcIsPointer && pointerBoxing && isPointerTypeCustomized
 
  212                        ?  
"Yes (By customization)" 
  214                        :  srcIsPointer && pointerBoxing && !isPointerTypeCustomized && (!copyConstructible || !triviallyDestructible)
 
  215                        ?  
"Yes (Value would not be copy-constructible or trivially destructible)" 
  217                        :  srcIsPointer && pointerBoxing && !isPointerTypeCustomized && !fitsToPlaceholder
 
  218                        ?  
"Yes (Value would not fit to placeholder)" 
  220                        :  srcIsValue   && arrayBoxing   && isValueTypeCustomized
 
  221                        ?  
"Yes (Custom unboxing from array type)" 
  223                        :  srcIsValue   && arrayBoxing   && isPointerTypeCustomized
 
  224                        ?  
"Yes (Unboxing from array type, customized with pointer type)" 
  226                        :  srcIsPointer && arrayBoxing   && isPointerTypeCustomized
 
  227                        ?  
"Yes (Custom unboxing from array type)" 
  229                        :  srcIsPointer && arrayBoxing   && isValueTypeCustomized
 
  230                        ?  
"Yes (Unboxing from array type, customized with value type)" 
  232                        : 
"INTERNAL ERROR IN DBG METHDO: CASE NOT MATCHED (E1)" 
  235                          srcIsValue    && isValueTypeCustomized
 
  236                        ? 
"Forbidden (By customization)" 
  238                        :  srcIsValue   && pointerBoxing && isPointerTypeCustomized
 
  239                        ?  
"Not as value (Pointer type is customized)" 
  241                        :  srcIsValue   && pointerBoxing && !isPointerTypeCustomized  && (!copyConstructible || !triviallyDestructible)
 
  242                        ?  
"Not as value (Not copy-constructible or trivially destructible)" 
  244                        :  srcIsValue   && pointerBoxing && !isPointerTypeCustomized  && !fitsToPlaceholder
 
  245                        ?  
"Not as value (Does not fit to placeholder)" 
  247                        :  srcIsPointer && isPointerTypeCustomized
 
  248                        ? 
"Forbidden (By customization)" 
  250                        :  srcIsPointer && valueBoxing && isValueTypeCustomized
 
  251                        ?  
"Not as pointer (Value type is customized)" 
  253                        :  srcIsPointer && valueBoxing && !isValueTypeCustomized
 
  254                        ?  
"Not as pointer (Value fits in placeholder and is copy constructible and trivially destructible)" 
  256                        : 
"INTERNAL ERROR IN DBG METHOd: CASE NOT MATCHED (E2)" 
  262                                                ? 
"INTERNAL ERROR IN DBG METHOD: STATIC VTABLE NOT REGISTERED" 
  264                                                ? 
"Dynamic Singleton" 
  265                                                : 
"Static Singleton (Specialized T_VTableFactory)" 
  272                       "BOXING", 
"Error occurred describing type" )
 
  277    String256 headline; headline << 
'\n' << indent << 
"Associated Specialized Functions:";
 
  278    String256 indent2;  indent2  << indent << indent;
 
  279    dumpFunctions( functions, target, headline, indent2, tmpStrings );
 
 
  298    for( 
int theSakeOfAutoTabs= 0 ; theSakeOfAutoTabs < 2 ; ++theSakeOfAutoTabs )
 
  301        dumpFunctions( input, result, headline, indent, tmpStrings );
 
 
  315    for( 
auto& type : input )
 
  318    std::sort( tmpStrings.begin(), tmpStrings.end(),
 
  319               [] (std::tuple<String, uinteger>& a,
 
  320                   std::tuple<String, uinteger>& b )
 
  322                    return std::get<0>(a).template CompareTo<CHK, lang::Case::Ignore>( std::get<0>(b) ) < 0;
 
  331    args.
Add( indent, 
"{}  {!ATab5}{:>2})\n", 
nullptr, 
'(', 
nullptr );
 
  332    for( 
auto& nameAndUse : tmpStrings )
 
  334        args[2]= std::get<0>(nameAndUse);
 
  335        args[4]= std::get<1>(nameAndUse) != (std::numeric_limits<uinteger>::max)()
 
  336                 ? 
Box( std::get<1>(nameAndUse) )
 
  337                 : 
Box( 
"No default implementation" );
 
 
  358    for( 
int theSakeOfAutoTabs= 0 ; theSakeOfAutoTabs < 2 ; ++theSakeOfAutoTabs )
 
  363        dumpVTables( result, vtableNames, staticVtables , includeFunctions );
 
 
  373                             bool                                            includeFunctions )
 
  376    result << ( staticVtables ? 
A_CHAR(
"Mapped types with static VTables")
 
  377                              : 
A_CHAR(
"Mapped types with dynamic VTables") );
 
  378    if( includeFunctions )
 
  379            result <<  
A_CHAR(
" and their associated specialized functions");
 
  386    detail::DbgLockMaps(
true);
 
  387        for( 
int i= 0 ; i <  2; ++i )
 
  388            for( 
auto& it : ( i == 0 ? detail::DbgKnownVTables : detail::DbgKnownVTablesArray) )
 
  400                        temp << 
"  ATTENTION: Unregistered customized VTable!!! This is an Error";
 
  402                    vtableNames.
Add( temp, it.second );
 
  405    detail::DbgLockMaps(
false);
 
  407    std::sort( vtableNames.begin(), vtableNames.end(),
 
  412                    Substring lhs= std::get<0>(a); lhs.TrimStart().ConsumeToken(
' '); lhs.TrimStart();
 
  413                    Substring rhs= std::get<0>(b); rhs.TrimStart().ConsumeToken(
' '); rhs.TrimStart();
 
  414                    return lhs.CompareTo<CHK, lang::Case::Ignore>( rhs ) < 0;
 
  420    std::vector<std::pair<const std::type_info*,uinteger>>   tempFunctions;
 
  421    for( 
auto& vtable: vtableNames )
 
  423        result << std::get<0>(vtable)  << 
NEW_LINE;
 
  424        if( includeFunctions )
 
 
  442    for( 
int theSakeOfAutoTabs= 0 ; theSakeOfAutoTabs < 2 ; ++theSakeOfAutoTabs )
 
  453        (result << 
"Known Function Declarators And Usage Of Default Implementation:" 
  457        #if ALIB_DEBUG_CONTAINERS 
  458            (result << 
NEW_LINE << 
"Metrics Of Custom Function Implementation HashMap: " 
 
ALIB_API void Reset(Snapshot snapshot=Snapshot())
TAString & DeleteStart(integer regionLength)
integer IndexOf(TChar needle, integer startIdx=0) const
constexpr bool IsNotEmpty() const
constexpr integer Length() const
bool StartsWith(const TString &needle) const
#define IF_ALIB_THREADS(...)
#define ALIB_LOCK_RECURSIVE_WITH(lock)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_CALLER_PRUNED
void DbgRegisterVTable(detail::VTable *vtable, detail::VTable::DbgFactoryType productionType)
@ Left
Chooses left alignment.
ALIB_API MonoAllocator GLOBAL_ALLOCATOR
ALIB_API RecursiveLock GLOBAL_ALLOCATOR_LOCK
LocalString< 64 > String64
Type alias name for TLocalString<character,64>.
containers::HashSet< TAllocator, T, THash, TEqual, THashCaching, TRecycling > HashSet
Type alias in namespace alib. See type definition alib::containers::HashSet.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
threads::RecursiveLock RecursiveLock
Type alias in namespace alib.
constexpr String NULL_STRING
A nulled string of the default character type.
boxing::Box Box
Type alias in namespace alib.
void DbgAssertSingleThreaded()
lang::integer integer
Type alias in namespace alib.
containers::HashMap< TAllocator, TKey, TMapped, THash, TEqual, THashCaching, TRecycling > HashMap
Type alias in namespace alib.
static ALIB_API void dumpVTables(AString &target, detail::DbgStringTable< const detail::VTable * > &vtableNames, bool staticVtables, bool includeFunctions)
static ALIB_API AString & removeNamespaces(AString &string, integer startIndex)
static ALIB_API std::vector< std::pair< const std::type_info *, uinteger > > GetKnownFunctionTypes()
static std::vector< std::pair< const std::type_info *, uinteger > > GetSpecificFunctionTypes(const detail::VTable *vtable)
static ALIB_API alib::AString DumpFunctions(const std::vector< std::pair< const std::type_info *, uinteger > > &input, const String &headline=EMPTY_STRING, const String &indent=EMPTY_STRING)
static ALIB_API void DumpCustomFunctionHashMapMetrics(AString &target, bool detailedBucketList)
static ALIB_API void typeInfo(AString &target, const detail::VTable *vtable, const String &indent, bool srcIsPointer, bool isValueTypeCustomized, bool isPointerTypeCustomized, bool fitsToPlaceholder, bool copyConstructible, bool triviallyDestructible, bool isUnboxable)
static ALIB_API void dumpFunctions(const std::vector< std::pair< const std::type_info *, uinteger > > &input, AString &output, const String &headline, const String &indent, detail::DbgStringTable< uinteger > &tmpStrings)
static ALIB_API void getFunctionTypes(const detail::FunctionTable &input, std::vector< std::pair< const std::type_info *, uinteger > > &output)
static ALIB_API void typeName(const detail::VTable *vtable, AString &result)
static ALIB_API AString DumpAll()
static ALIB_API std::vector< String > RemovableNamespaces
See method removeNamespaces. Pre-initialized with "alib::".
static ALIB_API AString DumpVTables(bool staticVtables, bool includeFunctions=false)
String & Add(const String &src, TArgs &&... args)
std::tuple< String, TAssociatedTypes... > ElementType
Shortcut to the std::tuple-type that instantiations of this template class store.
DbgFactoryType DbgProduction
Debug information.
const std::type_info & Type
@ Static
A static VTable is in place.
@ Unregistered
Not registered, yet.
@ Dynamic
The VTable is created dynamically from templated type VTableTT.
const MappingType Mapping
const std::type_info & ElementType