ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
boxing.prepro.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of the \aliblong.
4///
5/// Copyright 2013-2026 A-Worx GmbH, Germany.
6/// Published under #"mainpage_license".
7//==================================================================================================
8#ifndef HPP_ALIB_BOXING_PP
9#define HPP_ALIB_BOXING_PP
10#pragma once
11#ifndef HPP_ALIB
12# include "alib/alib.prepro.hpp"
13#endif
14
15//##################################################################################################
16// Macros introduced by module ALib.Boxing
17//##################################################################################################
18#if !defined(ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS)
19# define ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS 0
20#endif
21
22#if !defined(ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS)
23# define ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS 0
24#endif
25
26#if !defined(ALIB_FEAT_BOXING_BIJECTIVE_FLOATS)
27# define ALIB_FEAT_BOXING_BIJECTIVE_FLOATS 0
28#endif
29
30#if !ALIB_BOXING
31# define ALIB_DEBUG_BOXING 0
32#else
33# if !defined(ALIB_DEBUG_BOXING)
34# define ALIB_DEBUG_BOXING 0
35# elif !ALIB_DEBUG && ALIB_DEBUG_BOXING
36# undef ALIB_DEBUG_BOXING
37# define ALIB_DEBUG_BOXING 0
38# pragma message "Configuration Macro ALIB_DEBUG_BOXING set (from outside!) while ALIB_DEBUG is not. The macro got disabled."
39# endif
40
41
42#define ALIB_BOXING_CUSTOMIZE(TSource, TMapped, ...) \
43namespace alib::boxing { \
44template<> struct BoxTraits<TSource> { \
45 using Mapping= TMapped; \
46 static constexpr bool IsArray= false; \
47 __VA_ARGS__ \
48}; } \
49
50#define ALIB_BOXING_CUSTOMIZE_ARRAY_TYPE(TSource, TElement, ...) \
51namespace alib::boxing { \
52template<> struct BoxTraits<TSource> { \
53 using Mapping= TElement; \
54 static constexpr bool IsArray= true; \
55 __VA_ARGS__ \
56}; }
57
58
59#define ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING(TSource, TMapped) \
60namespace alib::boxing { \
61template<> struct BoxTraits<TSource> { \
62 using Mapping= TMapped; \
63 static constexpr bool IsArray= false; \
64 static constexpr void Write( Placeholder& box, TSource const & value ) { box.Write( static_cast<TMapped>( value ) ); } \
65 static constexpr TSource Read (const Placeholder& box) { return static_cast<TSource>(box.Read<TMapped>()); } \
66}; }
67
68
69#define ALIB_BOXING_CUSTOMIZE_NOT_UNBOXABLE(TSource, TMapped) \
70namespace alib::boxing { \
71template<> struct BoxTraits<TSource> { \
72 using Mapping= TMapped; \
73 static constexpr bool IsArray= false; \
74 static constexpr void Write( Placeholder& box, TSource const & value ) { box.Write( static_cast<TMapped>( value ) ); } \
75 static constexpr void Read( const Placeholder& box); \
76}; }
77
78
79#define ALIB_BOXING_CUSTOMIZE_ARRAY_TYPE_NON_UNBOXABLE(TSource, TElement, ...) \
80namespace alib::boxing { \
81template<> struct BoxTraits<TSource> { \
82 using Mapping= TElement; \
83 static constexpr bool IsArray= true; \
84 __VA_ARGS__ \
85 static constexpr void Read( const Placeholder& box); \
86}; }
87
88
89#define ALIB_BOXING_CUSTOMIZE_DENY_BOXING(TSource) \
90namespace alib::boxing { \
91template<> struct BoxTraits<TSource> { \
92 using Mapping= NotBoxableTag; \
93 static constexpr bool IsArray= false; \
94 static constexpr void Write( Placeholder& box, TSource const & value ); \
95 static constexpr void Read ( const Placeholder& box); \
96}; }
97
98
99#define ALIB_BOXING_VTABLE_DECLARE( TMapped, Identifier ) \
100ALIB_EXPORT namespace alib::boxing { namespace detail { \
101extern ALIB_DLL VTable SNGLTN_ ## Identifier; } \
102template<> struct VTableOptimizationTraits< TMapped, false > { \
103static constexpr detail::VTable* Get() { return &detail:: SNGLTN_ ## Identifier; } }; } \
104
105#define ALIB_BOXING_VTABLE_DECLARE_ARRAYTYPE( TMapped, Identifier ) \
106ALIB_EXPORT namespace alib::boxing { namespace detail { \
107extern ALIB_DLL VTable SNGLTN_ ## Identifier; } \
108template<> struct VTableOptimizationTraits< TMapped, true > { \
109static constexpr detail::VTable* Get() { return &detail:: SNGLTN_ ## Identifier;} }; } \
110
111#define ALIB_BOXING_VTABLE_DEFINE( TMapped, Identifier ) \
112alib::boxing::detail::VTable alib::boxing::detail::SNGLTN_ ## Identifier \
113( typeid(TMapped), typeid(void) , \
114 std::is_pointer<TMapped>::value \
115 ? VTable::MappingType::Pointer \
116 : std::is_enum<TMapped>::value \
117 ? VTable::MappingType::Enum \
118 : VTable::MappingType::Value , \
119 alib::boxing::SizeTraits<TMapped>); \
120
121#define ALIB_BOXING_VTABLE_DEFINE_ARRAYTYPE( TMapped, Identifier ) \
122alib::boxing::detail::VTable alib::boxing::detail::SNGLTN_ ## Identifier \
123(typeid(TMapped[1]) , typeid(TMapped), VTable::MappingType(sizeof(TMapped)), sizeof(Placeholder)); \
124
125
126#if ALIB_DEBUG_BOXING
127# define ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( Identifier ) \
128alib::boxing::debug::DbgRegisterVTable( &alib::boxing::detail::SNGLTN_ ## Identifier, \
129 alib::boxing::detail::VTable::DbgFactoryType::Static );
130#else
131# define ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER( Identifier )
132#endif
133
134#define ALIB_BOXING_DEFINE_FEQUALS_FOR_COMPARABLE_TYPE( TComparable ) \
135alib::boxing::BootstrapRegister< alib::boxing::FEquals,TComparable>(FEquals::ComparableTypes<TComparable>);
136
137#define ALIB_BOXING_DEFINE_FISLESS_FOR_COMPARABLE_TYPE( TComparable ) \
138alib::boxing::BootstrapRegister< alib::boxing::FIsLess,TComparable>(FIsLess::ComparableTypes<TComparable>);
139
140#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE(TAppendable) \
141alib::boxing::BootstrapRegister<alib::boxing::FAppend<character, alib::lang::HeapAllocator>, TAppendable> \
142 (alib::boxing::FAppend<character, alib::lang::HeapAllocator>::Appendable<TAppendable>);
143
144#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_N(TAppendable) \
145alib::boxing::BootstrapRegister<alib::boxing::FAppend<nchar , alib::lang::HeapAllocator>, TAppendable> \
146 (alib::boxing::FAppend<nchar , alib::lang::HeapAllocator>::Appendable<TAppendable>);
147
148#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_W(TAppendable) \
149alib::boxing::BootstrapRegister<alib::boxing::FAppend<wchar , alib::lang::HeapAllocator>, TAppendable> \
150 (alib::boxing::FAppend<wchar , alib::lang::HeapAllocator>::Appendable<TAppendable>);
151
152#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE_X(TAppendable) \
153alib::boxing::BootstrapRegister<alib::boxing::FAppend<xchar , alib::lang::HeapAllocator>, TAppendable> \
154 (alib::boxing::FAppend<xchar , alib::lang::HeapAllocator>::Appendable<TAppendable>);
155
156#endif
157#endif // HPP_ALIB_BOXING_PP