|
@@ -9,6 +9,8 @@
|
|
|
|
|
|
#include <AzCore/std/containers/array.h>
|
|
#include <AzCore/std/containers/array.h>
|
|
#include <AzCore/Preprocessor/Enum.h>
|
|
#include <AzCore/Preprocessor/Enum.h>
|
|
|
|
+#include <AzCore/std/ranges/join_with_view.h>
|
|
|
|
+#include <AzCore/std/ranges/reverse_view.h>
|
|
#include <AzCore/std/typetraits/is_pointer.h>
|
|
#include <AzCore/std/typetraits/is_pointer.h>
|
|
#include <AzCore/std/typetraits/is_const.h>
|
|
#include <AzCore/std/typetraits/is_const.h>
|
|
#include <AzCore/std/typetraits/is_enum.h>
|
|
#include <AzCore/std/typetraits/is_enum.h>
|
|
@@ -215,17 +217,16 @@ namespace AZ
|
|
template <template <typename, auto, typename> class> constexpr bool false_v6 = false;
|
|
template <template <typename, auto, typename> class> constexpr bool false_v6 = false;
|
|
|
|
|
|
template<typename T>
|
|
template<typename T>
|
|
- inline const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ inline constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
return AzTypeInfo<T>::template Uuid<AZ::GenericTypeIdTag>();
|
|
return AzTypeInfo<T>::template Uuid<AZ::GenericTypeIdTag>();
|
|
}
|
|
}
|
|
|
|
|
|
template<template<typename...> class T>
|
|
template<template<typename...> class T>
|
|
- inline const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ inline constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
static_assert(false_v1<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
static_assert(false_v1<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
- static const AZ::TypeId s_uuid = AZ::TypeId::CreateNull();
|
|
|
|
- return s_uuid;
|
|
|
|
|
|
+ return {};
|
|
}
|
|
}
|
|
#if defined(AZ_COMPILER_MSVC)
|
|
#if defined(AZ_COMPILER_MSVC)
|
|
// There is a bug with the MSVC compiler when using the 'auto' keyword here. It appears that MSVC is unable to distinguish between a template
|
|
// There is a bug with the MSVC compiler when using the 'auto' keyword here. It appears that MSVC is unable to distinguish between a template
|
|
@@ -234,44 +235,38 @@ namespace AZ
|
|
#else
|
|
#else
|
|
template<template<auto...> class T>
|
|
template<template<auto...> class T>
|
|
#endif // defined(AZ_COMPILER_MSVC)
|
|
#endif // defined(AZ_COMPILER_MSVC)
|
|
- inline const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ inline constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
static_assert(false_v2<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
static_assert(false_v2<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
- static const AZ::TypeId s_uuid = AZ::TypeId::CreateNull();
|
|
|
|
- return s_uuid;
|
|
|
|
|
|
+ return {};
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
template<template<typename, auto> class T>
|
|
template<template<typename, auto> class T>
|
|
- inline const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ inline constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
static_assert(false_v3<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
static_assert(false_v3<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
- static const AZ::TypeId s_uuid = AZ::TypeId::CreateNull();
|
|
|
|
- return s_uuid;
|
|
|
|
|
|
+ return {};
|
|
}
|
|
}
|
|
|
|
|
|
template<template<typename, typename, auto> class T>
|
|
template<template<typename, typename, auto> class T>
|
|
- inline const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ inline constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
static_assert(false_v4<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
static_assert(false_v4<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
- static const AZ::TypeId s_uuid = AZ::TypeId::CreateNull();
|
|
|
|
- return s_uuid;
|
|
|
|
|
|
+ return {};
|
|
}
|
|
}
|
|
|
|
|
|
template<template<typename, typename, typename, auto> class T>
|
|
template<template<typename, typename, typename, auto> class T>
|
|
- inline const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ inline constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
static_assert(false_v5<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
static_assert(false_v5<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
- static const AZ::TypeId s_uuid = AZ::TypeId::CreateNull();
|
|
|
|
- return s_uuid;
|
|
|
|
|
|
+ return {};
|
|
}
|
|
}
|
|
|
|
|
|
template<template<typename, auto, typename> class T>
|
|
template<template<typename, auto, typename> class T>
|
|
- inline const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ inline constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
static_assert(false_v6<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
static_assert(false_v6<T>, "Missing specialization for this template. Make sure it's registered for type info support.");
|
|
- static const AZ::TypeId s_uuid = AZ::TypeId::CreateNull();
|
|
|
|
- return s_uuid;
|
|
|
|
|
|
+ return {};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -326,67 +321,72 @@ namespace AZ
|
|
*destination = 0;
|
|
*destination = 0;
|
|
}
|
|
}
|
|
|
|
|
|
- template<class... Tn>
|
|
|
|
- struct AggregateTypes;
|
|
|
|
|
|
+ constexpr AZStd::string_view TypeNameSeparator = ", ";
|
|
|
|
|
|
- template<class T1, class... Tn>
|
|
|
|
- struct AggregateTypes<T1, Tn...>
|
|
|
|
|
|
+ template<class... Tn>
|
|
|
|
+ struct AggregateTypes
|
|
{
|
|
{
|
|
- static constexpr void TypeNameWithSeparator(char* buffer, size_t bufferSize)
|
|
|
|
- {
|
|
|
|
- constexpr const char* separator = ", ";
|
|
|
|
- AzTypeInfoSafeCat(buffer, bufferSize, separator);
|
|
|
|
- AzTypeInfoSafeCat(buffer, bufferSize, AzTypeInfo<T1>::Name());
|
|
|
|
- AggregateTypes<Tn...>::TypeNameWithSeparator(buffer, bufferSize);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- static constexpr void TypeName(char* buffer, size_t bufferSize)
|
|
|
|
- {
|
|
|
|
- AzTypeInfoSafeCat(buffer, bufferSize, AzTypeInfo<T1>::Name());
|
|
|
|
- AggregateTypes<Tn...>::TypeNameWithSeparator(buffer, bufferSize);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
|
|
- static AZ::TypeId Uuid()
|
|
|
|
|
|
+ static constexpr auto TypeName()
|
|
{
|
|
{
|
|
- const AZ::TypeId tail = AggregateTypes<Tn...>::template Uuid<TypeIdResolverTag>();
|
|
|
|
- if (!tail.IsNull())
|
|
|
|
|
|
+ if constexpr (sizeof...(Tn) == 0)
|
|
{
|
|
{
|
|
- // Avoid accumulating a null uuid, since it affects the result.
|
|
|
|
- return AzTypeInfo<T1>::template Uuid<TypeIdResolverTag>() + tail;
|
|
|
|
|
|
+ return AZStd::string_view{};
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- return AzTypeInfo<T1>::template Uuid<TypeIdResolverTag>();
|
|
|
|
|
|
+ constexpr AZStd::fixed_string<1024> typeNameAggregate = []()
|
|
|
|
+ {
|
|
|
|
+ constexpr auto typeNames = AZStd::to_array({ AZStd::string_view(AzTypeInfo<Tn>::Name())... });
|
|
|
|
+ return AZStd::fixed_string<1024>(AZStd::from_range, typeNames | AZStd::views::join_with(TypeNameSeparator));
|
|
|
|
+ }();
|
|
|
|
+
|
|
|
|
+ // resize down the aggregate type name to the exact size
|
|
|
|
+ return AZStd::fixed_string<typeNameAggregate.size()>(typeNameAggregate);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- };
|
|
|
|
-
|
|
|
|
- template<>
|
|
|
|
- struct AggregateTypes<>
|
|
|
|
- {
|
|
|
|
- static constexpr void TypeNameWithSeparator(char*, size_t)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
- static constexpr void TypeName(char*, size_t)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
|
|
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
- static AZ::TypeId Uuid()
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
- return AZ::TypeId::CreateNull();
|
|
|
|
|
|
+ if constexpr (sizeof...(Tn) == 0)
|
|
|
|
+ {
|
|
|
|
+ return {};
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ constexpr auto typeIds = AZStd::to_array<AZ::TypeId>({ AzTypeInfo<Tn>::template Uuid<TypeIdResolverTag>()... });
|
|
|
|
+ if (typeIds.empty())
|
|
|
|
+ {
|
|
|
|
+ return {};
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ AZ::TypeId aggregateTypeId = typeIds.back();
|
|
|
|
+
|
|
|
|
+ // perform binary right fold over all the type ids, by combining them
|
|
|
|
+ // two elements at a time from the end of the array to the beginning
|
|
|
|
+ // Skip over the last element and reverse the span
|
|
|
|
+ for (const AZ::TypeId& prevTypeId : AZStd::span(typeIds.data(), typeIds.size() - 1) | AZStd::views::reverse)
|
|
|
|
+ {
|
|
|
|
+ if (!aggregateTypeId.IsNull())
|
|
|
|
+ {
|
|
|
|
+ // Avoid accumulating a null uuid, since it affects the result.
|
|
|
|
+ aggregateTypeId = prevTypeId + aggregateTypeId;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ // Otherwise replace the aggregate type id with the previous typeid
|
|
|
|
+ aggregateTypeId = prevTypeId;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return aggregateTypeId;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- using TypeIdHolder = AZ::TypeId;
|
|
|
|
|
|
|
|
// Represents the "*" typeid that can be combined with non-pointer types T to form a unique T* typeid
|
|
// Represents the "*" typeid that can be combined with non-pointer types T to form a unique T* typeid
|
|
- inline static const AZ::TypeId& PointerTypeId()
|
|
|
|
- {
|
|
|
|
- static TypeIdHolder s_uuid("{35C8A027-FE00-4769-AE36-6997CFFAF8AE}");
|
|
|
|
- return s_uuid;
|
|
|
|
- }
|
|
|
|
|
|
+ inline constexpr AZ::TypeId PointerTypeId_v{ "{35C8A027-FE00-4769-AE36-6997CFFAF8AE}" };
|
|
|
|
|
|
template<typename T>
|
|
template<typename T>
|
|
constexpr const char* GetTypeName()
|
|
constexpr const char* GetTypeName()
|
|
@@ -394,51 +394,55 @@ namespace AZ
|
|
return AZ::AzTypeInfo<T>::Name();
|
|
return AZ::AzTypeInfo<T>::Name();
|
|
}
|
|
}
|
|
|
|
|
|
- template<int N, bool Recursion = false>
|
|
|
|
|
|
+ template<int N, bool MoreDigits = (N >= 10)>
|
|
struct NameBufferSize
|
|
struct NameBufferSize
|
|
{
|
|
{
|
|
- static constexpr int Size = 1 + NameBufferSize<N / 10, true>::Size;
|
|
|
|
|
|
+ static constexpr int Size = 1 + NameBufferSize<N / 10>::Size;
|
|
};
|
|
};
|
|
- template<> struct NameBufferSize<0, false> { static constexpr const int Size = 2; };
|
|
|
|
- template<> struct NameBufferSize<0, true> { static constexpr const int Size = 1; };
|
|
|
|
|
|
+ template<int N> struct NameBufferSize<N, false> { static constexpr int Size = 1; };
|
|
|
|
|
|
// IntTypeName provides Compile time Variable template for c-string
|
|
// IntTypeName provides Compile time Variable template for c-string
|
|
// of a converted unsigned integer value
|
|
// of a converted unsigned integer value
|
|
template<AZStd::size_t N>
|
|
template<AZStd::size_t N>
|
|
- inline constexpr AZStd::array<char, NameBufferSize<N>::Size> IntTypeName = []() constexpr
|
|
|
|
- -> AZStd::array<char, NameBufferSize<N>::Size>
|
|
|
|
|
|
+ inline constexpr AZStd::fixed_string<NameBufferSize<N>::Size> IntTypeName = []() constexpr
|
|
{
|
|
{
|
|
- using BufferType = AZStd::array<char, NameBufferSize<N>::Size>;
|
|
|
|
- BufferType buffer{};
|
|
|
|
- // Fill the buffer from the end with stringified
|
|
|
|
- // conversions of each digit
|
|
|
|
- // The buffer is exactly the size to store a null-terminated string
|
|
|
|
- // of the integer converted to a string
|
|
|
|
- size_t index = buffer.size() - 1;
|
|
|
|
- for (size_t value = N; index > 0; value /= 10)
|
|
|
|
|
|
+ using BufferType = AZStd::fixed_string<NameBufferSize<N>::Size>;
|
|
|
|
+ BufferType numberString;
|
|
|
|
+ auto FillDigitsFromEnd = [](char* buffer, size_t bufferSize)
|
|
{
|
|
{
|
|
- buffer[--index] = '0' + (value % 10);
|
|
|
|
- }
|
|
|
|
- return buffer;
|
|
|
|
|
|
+ // Fill the buffer from the end with stringified
|
|
|
|
+ // conversions of each digit
|
|
|
|
+ // The buffer is exactly the size to store the integer converted to a string
|
|
|
|
+ size_t index = bufferSize;
|
|
|
|
+ for (size_t value = N; index > 0; value /= 10)
|
|
|
|
+ {
|
|
|
|
+ buffer[--index] = '0' + (value % 10);
|
|
|
|
+ }
|
|
|
|
+ return bufferSize;
|
|
|
|
+ };
|
|
|
|
+ numberString.resize_and_overwrite(numberString.max_size(), FillDigitsFromEnd);
|
|
|
|
+ return numberString;
|
|
}();
|
|
}();
|
|
|
|
|
|
template<AZStd::size_t N>
|
|
template<AZStd::size_t N>
|
|
constexpr const char* GetTypeName()
|
|
constexpr const char* GetTypeName()
|
|
{
|
|
{
|
|
- return IntTypeName<N>.data();
|
|
|
|
|
|
+ return IntTypeName<N>.c_str();
|
|
}
|
|
}
|
|
|
|
|
|
template<typename T, typename TypeIdResolverTag>
|
|
template<typename T, typename TypeIdResolverTag>
|
|
- const AZ::TypeId& GetTypeId()
|
|
|
|
|
|
+ constexpr AZ::TypeId GetTypeId()
|
|
{
|
|
{
|
|
return AZ::AzTypeInfo<T>::template Uuid<TypeIdResolverTag>();
|
|
return AZ::AzTypeInfo<T>::template Uuid<TypeIdResolverTag>();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ template<AZStd::size_t N>
|
|
|
|
+ inline constexpr AZ::TypeId NumericTypeId_v = AZ::TypeId::CreateName(GetTypeName<N>());
|
|
|
|
+
|
|
template<AZStd::size_t N, typename>
|
|
template<AZStd::size_t N, typename>
|
|
- const AZ::TypeId& GetTypeId()
|
|
|
|
|
|
+ constexpr AZ::TypeId GetTypeId()
|
|
{
|
|
{
|
|
- static AZ::TypeId uuid = AZ::TypeId::CreateName(GetTypeName<N>());
|
|
|
|
- return uuid;
|
|
|
|
|
|
+ return NumericTypeId_v<N>;
|
|
}
|
|
}
|
|
|
|
|
|
} // namespace Internal
|
|
} // namespace Internal
|
|
@@ -484,7 +488,7 @@ namespace AZ
|
|
return T::TYPEINFO_Name();
|
|
return T::TYPEINFO_Name();
|
|
}
|
|
}
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
- static const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
static_assert(AZ::Internal::HasAZTypeInfoIntrusive<T>,
|
|
static_assert(AZ::Internal::HasAZTypeInfoIntrusive<T>,
|
|
"You should use AZ_TYPE_INFO or AZ_RTTI in your class/struct, or use AZ_TYPE_INFO_SPECIALIZE() externally. "
|
|
"You should use AZ_TYPE_INFO or AZ_RTTI in your class/struct, or use AZ_TYPE_INFO_SPECIALIZE() externally. "
|
|
@@ -510,7 +514,11 @@ namespace AZ
|
|
template <class T>
|
|
template <class T>
|
|
struct AzTypeInfo<T, true /* is_enum */>
|
|
struct AzTypeInfo<T, true /* is_enum */>
|
|
{
|
|
{
|
|
|
|
+ private:
|
|
typedef typename AZStd::RemoveEnum<T>::type UnderlyingType;
|
|
typedef typename AZStd::RemoveEnum<T>::type UnderlyingType;
|
|
|
|
+ // Used to provide a reference to a Uuid with a null value = {00000000-0000-0000-0000-000000000000}
|
|
|
|
+ inline static constexpr AZ::TypeId s_nullTypeId_v;
|
|
|
|
+ public:
|
|
static constexpr const char* Name()
|
|
static constexpr const char* Name()
|
|
{
|
|
{
|
|
if constexpr (AZ::HasAzEnumTraits_v<T>)
|
|
if constexpr (AZ::HasAzEnumTraits_v<T>)
|
|
@@ -522,8 +530,9 @@ namespace AZ
|
|
return "[enum]";
|
|
return "[enum]";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
- static const AZ::TypeId& Uuid() { static AZ::TypeId nullUuid = AZ::TypeId::CreateNull(); return nullUuid; }
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid() { return s_nullTypeId_v; }
|
|
static constexpr TypeTraits GetTypeTraits()
|
|
static constexpr TypeTraits GetTypeTraits()
|
|
{
|
|
{
|
|
TypeTraits typeTraits{};
|
|
TypeTraits typeTraits{};
|
|
@@ -541,13 +550,13 @@ namespace AZ
|
|
};
|
|
};
|
|
|
|
|
|
template<class T, class U>
|
|
template<class T, class U>
|
|
- inline bool operator==(AzTypeInfo<T> const& lhs, AzTypeInfo<U> const& rhs)
|
|
|
|
|
|
+ constexpr inline bool operator==(AzTypeInfo<T> const& lhs, AzTypeInfo<U> const& rhs)
|
|
{
|
|
{
|
|
return lhs.Uuid() == rhs.Uuid();
|
|
return lhs.Uuid() == rhs.Uuid();
|
|
}
|
|
}
|
|
|
|
|
|
template<class T, class U>
|
|
template<class T, class U>
|
|
- inline bool operator!=(AzTypeInfo<T> const& lhs, AzTypeInfo<U> const& rhs)
|
|
|
|
|
|
+ constexpr inline bool operator!=(AzTypeInfo<T> const& lhs, AzTypeInfo<U> const& rhs)
|
|
{
|
|
{
|
|
return lhs.Uuid() != rhs.Uuid();
|
|
return lhs.Uuid() != rhs.Uuid();
|
|
}
|
|
}
|
|
@@ -579,11 +588,14 @@ namespace AZ
|
|
template<> \
|
|
template<> \
|
|
struct AzTypeInfo<_ClassName, AZStd::is_enum<_ClassName>::value> \
|
|
struct AzTypeInfo<_ClassName, AZStd::is_enum<_ClassName>::value> \
|
|
{ \
|
|
{ \
|
|
- static constexpr const char* Name() { return #_ClassName; } \
|
|
|
|
|
|
+ private: \
|
|
|
|
+ static inline constexpr AZ::TypeId s_classUuid{_ClassUuid}; \
|
|
|
|
+ public: \
|
|
|
|
+ static constexpr const char* Name() { return #_ClassName; } \
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag> \
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag> \
|
|
- static const AZ::TypeId& Uuid() { \
|
|
|
|
- static AZ::Internal::TypeIdHolder s_uuid(_ClassUuid); \
|
|
|
|
- return s_uuid; \
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid() \
|
|
|
|
+ { \
|
|
|
|
+ return s_classUuid; \
|
|
} \
|
|
} \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
{ \
|
|
{ \
|
|
@@ -595,9 +607,9 @@ namespace AZ
|
|
} \
|
|
} \
|
|
static constexpr size_t Size() \
|
|
static constexpr size_t Size() \
|
|
{ \
|
|
{ \
|
|
- return AZ::Internal::TypeInfoSizeof<_ClassName>::Size(); \
|
|
|
|
|
|
+ return AZ::Internal::TypeInfoSizeof<_ClassName>::Size(); \
|
|
} \
|
|
} \
|
|
- static bool Specialized() { return true; } \
|
|
|
|
|
|
+ static constexpr bool Specialized() { return true; } \
|
|
};
|
|
};
|
|
|
|
|
|
// specialize for function pointers
|
|
// specialize for function pointers
|
|
@@ -616,37 +628,34 @@ namespace AZ
|
|
// is returned from the compile time calculations
|
|
// is returned from the compile time calculations
|
|
constexpr auto combineTypeNameBuffer = []() constexpr
|
|
constexpr auto combineTypeNameBuffer = []() constexpr
|
|
{
|
|
{
|
|
- using CombineBufferType = AZStd::array<char, 1024>;
|
|
|
|
- CombineBufferType typeName{};
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), "{");
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), AZ::AzTypeInfo<R>::Name());
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), "(");
|
|
|
|
- AZ::Internal::AggregateTypes<Args...>::TypeName(typeName.data(), typeName.size());
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), ")}");
|
|
|
|
|
|
+ using CombineBufferType = AZStd::fixed_string<1024>;
|
|
|
|
+ CombineBufferType typeName{ '{' };
|
|
|
|
+ typeName += AZ::AzTypeInfo<R>::Name();
|
|
|
|
+ typeName += '(';
|
|
|
|
+ typeName += AZ::Internal::AggregateTypes<Args...>::TypeName();
|
|
|
|
+ typeName += ")}";
|
|
return typeName;
|
|
return typeName;
|
|
}();
|
|
}();
|
|
|
|
|
|
- // Create a buffer that can store the exact number of characters for the type name + NUL
|
|
|
|
- constexpr size_t NameLength = AZStd::char_traits<char>::length(combineTypeNameBuffer.data());
|
|
|
|
- AZStd::array<char, NameLength + 1> resultBuffer{};
|
|
|
|
- AZStd::copy(combineTypeNameBuffer.begin(), combineTypeNameBuffer.begin() + NameLength, resultBuffer.begin());
|
|
|
|
- return resultBuffer;
|
|
|
|
|
|
+ // Round up to the Next Power of 2 to reduce the number of fixed_string template instantiations
|
|
|
|
+ return AZStd::fixed_string<AZ::AlignUpToPowerOfTwo(combineTypeNameBuffer.size())>(combineTypeNameBuffer);
|
|
}();
|
|
}();
|
|
constexpr const char* operator()() const
|
|
constexpr const char* operator()() const
|
|
{
|
|
{
|
|
- return TypeName.data();
|
|
|
|
|
|
+ return TypeName.c_str();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+ template<class TypeIdResolverTag>
|
|
|
|
+ static inline constexpr TypeId s_uuid_v = AZ::Internal::AggregateTypes<R, Args...>::template Uuid<TypeIdResolverTag>();
|
|
public:
|
|
public:
|
|
static constexpr const char* Name()
|
|
static constexpr const char* Name()
|
|
{
|
|
{
|
|
return TypeNameInternal{}();
|
|
return TypeNameInternal{}();
|
|
}
|
|
}
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
- static const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
- static AZ::Internal::TypeIdHolder s_uuid(AZ::Internal::AggregateTypes<R, Args...>::template Uuid<TypeIdResolverTag>());
|
|
|
|
- return s_uuid;
|
|
|
|
|
|
+ return s_uuid_v<TypeIdResolverTag>;
|
|
}
|
|
}
|
|
static constexpr TypeTraits GetTypeTraits()
|
|
static constexpr TypeTraits GetTypeTraits()
|
|
{
|
|
{
|
|
@@ -734,40 +743,36 @@ namespace AZ
|
|
{
|
|
{
|
|
constexpr auto combineTypeNameBuffer = []() constexpr
|
|
constexpr auto combineTypeNameBuffer = []() constexpr
|
|
{
|
|
{
|
|
- using CombineBufferType = AZStd::array<char, 1024>;
|
|
|
|
- CombineBufferType typeName{};
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), "{");
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), AZ::AzTypeInfo<R>::Name());
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), "(");
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), AZ::AzTypeInfo<C>::Name());
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), "::*)");
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), "(");
|
|
|
|
- AZ::Internal::AggregateTypes<Args...>::TypeName(typeName.data(), typeName.size());
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), ")}");
|
|
|
|
|
|
+ using CombineBufferType = AZStd::fixed_string<1024>;
|
|
|
|
+ CombineBufferType typeName{ '{' };
|
|
|
|
+ typeName += AZ::AzTypeInfo<R>::Name();
|
|
|
|
+ typeName += '(';
|
|
|
|
+ typeName += AZ::AzTypeInfo<C>::Name();
|
|
|
|
+ typeName += "::*)(";
|
|
|
|
+ typeName += AZ::Internal::AggregateTypes<Args...>::TypeName();
|
|
|
|
+ typeName += ")}";
|
|
return typeName;
|
|
return typeName;
|
|
}();
|
|
}();
|
|
|
|
|
|
- // Create a buffer that can store the exact number of characters for the type name + NUL
|
|
|
|
- constexpr size_t NameLength = AZStd::char_traits<char>::length(combineTypeNameBuffer.data());
|
|
|
|
- AZStd::array<char, NameLength + 1> resultBuffer{};
|
|
|
|
- AZStd::copy(combineTypeNameBuffer.begin(), combineTypeNameBuffer.begin() + NameLength, resultBuffer.begin());
|
|
|
|
- return resultBuffer;
|
|
|
|
|
|
+ // Round up to the Next Power of 2 to reduce the number of fixed_string template instantiations
|
|
|
|
+ return AZStd::fixed_string<AZ::AlignUpToPowerOfTwo(combineTypeNameBuffer.size())>(combineTypeNameBuffer);
|
|
}();
|
|
}();
|
|
constexpr const char* operator()() const
|
|
constexpr const char* operator()() const
|
|
{
|
|
{
|
|
- return TypeName.data();
|
|
|
|
|
|
+ return TypeName.c_str();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+ template<class TypeIdResolverTag>
|
|
|
|
+ inline static constexpr AZ::TypeId s_uuid_v{ AZ::Internal::AggregateTypes<R, C, Args...>::template Uuid<TypeIdResolverTag>() };
|
|
public:
|
|
public:
|
|
static constexpr const char* Name()
|
|
static constexpr const char* Name()
|
|
{
|
|
{
|
|
return TypeNameInternal{}();
|
|
return TypeNameInternal{}();
|
|
}
|
|
}
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
- static const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
- static AZ::Internal::TypeIdHolder s_uuid(AZ::Internal::AggregateTypes<R, C, Args...>::template Uuid<TypeIdResolverTag>());
|
|
|
|
- return s_uuid;
|
|
|
|
|
|
+ return s_uuid_v<TypeIdResolverTag>;
|
|
}
|
|
}
|
|
static constexpr TypeTraits GetTypeTraits()
|
|
static constexpr TypeTraits GetTypeTraits()
|
|
{
|
|
{
|
|
@@ -798,37 +803,34 @@ namespace AZ
|
|
{
|
|
{
|
|
constexpr auto combineTypeNameBuffer = []() constexpr
|
|
constexpr auto combineTypeNameBuffer = []() constexpr
|
|
{
|
|
{
|
|
- using CombineBufferType = AZStd::array<char, 1024>;
|
|
|
|
- CombineBufferType typeName{};
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), "{");
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), AZ::AzTypeInfo<R>::Name());
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), " ");
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), AZ::AzTypeInfo<C>::Name());
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), "::*}");
|
|
|
|
|
|
+ using CombineBufferType = AZStd::fixed_string<1024>;
|
|
|
|
+ CombineBufferType typeName{ '{' };
|
|
|
|
+ typeName += AZ::AzTypeInfo<R>::Name();
|
|
|
|
+ typeName += ' ';
|
|
|
|
+ typeName + AZ::AzTypeInfo<C>::Name();
|
|
|
|
+ typeName += "::*}";
|
|
return typeName;
|
|
return typeName;
|
|
}();
|
|
}();
|
|
|
|
|
|
- // Create a buffer that can store the exact number of characters for the type name + NUL
|
|
|
|
- constexpr size_t NameLength = AZStd::char_traits<char>::length(combineTypeNameBuffer.data());
|
|
|
|
- AZStd::array<char, NameLength + 1> resultBuffer{};
|
|
|
|
- AZStd::copy(combineTypeNameBuffer.begin(), combineTypeNameBuffer.begin() + NameLength, resultBuffer.begin());
|
|
|
|
- return resultBuffer;
|
|
|
|
|
|
+ // Round up to the Next Power of 2 to reduce the number of fixed_string template instantiations
|
|
|
|
+ return AZStd::fixed_string<AZ::AlignUpToPowerOfTwo(combineTypeNameBuffer.size())>(combineTypeNameBuffer);
|
|
}();
|
|
}();
|
|
constexpr const char* operator()() const
|
|
constexpr const char* operator()() const
|
|
{
|
|
{
|
|
- return TypeName.data();
|
|
|
|
|
|
+ return TypeName.c_str();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+ template<class TypeIdResolverTag>
|
|
|
|
+ inline static constexpr TypeId s_uuid_v{ AZ::Internal::AggregateTypes<R, C>::template Uuid<TypeIdResolverTag>() };
|
|
public:
|
|
public:
|
|
static constexpr const char* Name()
|
|
static constexpr const char* Name()
|
|
{
|
|
{
|
|
return TypeNameInternal{}();
|
|
return TypeNameInternal{}();
|
|
}
|
|
}
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
template<typename TypeIdResolverTag = CanonicalTypeIdTag>
|
|
- static const AZ::TypeId& Uuid()
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid()
|
|
{
|
|
{
|
|
- static AZ::Internal::TypeIdHolder s_uuid(AZ::Internal::AggregateTypes<R, C>::template Uuid<TypeIdResolverTag>());
|
|
|
|
- return s_uuid;
|
|
|
|
|
|
+ return s_uuid_v<TypeIdResolverTag>;
|
|
}
|
|
}
|
|
static constexpr TypeTraits GetTypeTraits()
|
|
static constexpr TypeTraits GetTypeTraits()
|
|
{
|
|
{
|
|
@@ -854,24 +856,26 @@ namespace AZ
|
|
{ \
|
|
{ \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
{ \
|
|
{ \
|
|
- using CombineBufferType = AZStd::array<char, 1024>; \
|
|
|
|
- CombineBufferType typeName{}; \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), _NamePrefix); \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), AzTypeInfo<_T1>::Name()); \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), _NameSuffix); \
|
|
|
|
|
|
+ using CombineBufferType = AZStd::fixed_string<1024>; \
|
|
|
|
+ CombineBufferType typeName{ _NamePrefix }; \
|
|
|
|
+ typeName += AzTypeInfo<_T1>::Name(); \
|
|
|
|
+ typeName += _NameSuffix; \
|
|
return typeName; \
|
|
return typeName; \
|
|
}(); \
|
|
}(); \
|
|
- /* Create a buffer that can store the exact number of characters for the type name + NUL */ \
|
|
|
|
- constexpr size_t NameLength = AZStd::char_traits<char>::length(combineTypeNameBuffer.data()); \
|
|
|
|
- AZStd::array<char, NameLength + 1> resultBuffer{}; \
|
|
|
|
- AZStd::copy(combineTypeNameBuffer.begin(), combineTypeNameBuffer.begin() + NameLength, resultBuffer.begin()); \
|
|
|
|
- return resultBuffer; \
|
|
|
|
|
|
+ /* Round up to power of 2 to reduce the number of fixed_string template instantiations */ \
|
|
|
|
+ return AZStd::fixed_string<AZ::AlignUpToPowerOfTwo(combineTypeNameBuffer.size())>(combineTypeNameBuffer); \
|
|
}(); \
|
|
}(); \
|
|
constexpr const char* operator()() const \
|
|
constexpr const char* operator()() const \
|
|
{ \
|
|
{ \
|
|
- return TypeName.data(); \
|
|
|
|
|
|
+ return TypeName.c_str(); \
|
|
} \
|
|
} \
|
|
}; \
|
|
}; \
|
|
|
|
+ template<class TypeIdResolverTag> \
|
|
|
|
+ inline static constexpr AZ::TypeId s_uuid_v{ \
|
|
|
|
+ !AZStd::is_same_v<TypeIdResolverTag, PointerRemovedTypeIdTag> \
|
|
|
|
+ && AZStd::is_pointer_v<_Specialization> ? \
|
|
|
|
+ AZ::AzTypeInfo<_T1>::template Uuid<TypeIdResolverTag>() + AZ::Internal::PointerTypeId_v : \
|
|
|
|
+ AZ::AzTypeInfo<_T1>::template Uuid<TypeIdResolverTag>()}; \
|
|
public: \
|
|
public: \
|
|
static constexpr const char* Name() \
|
|
static constexpr const char* Name() \
|
|
{ \
|
|
{ \
|
|
@@ -881,13 +885,10 @@ namespace AZ
|
|
* By default the specialization for pointer types defaults to PointerRemovedTypeIdTag \
|
|
* By default the specialization for pointer types defaults to PointerRemovedTypeIdTag \
|
|
* This allows the current use of AzTypeInfo<T*>::Uuid to still return the typeid of type \
|
|
* This allows the current use of AzTypeInfo<T*>::Uuid to still return the typeid of type \
|
|
*/ \
|
|
*/ \
|
|
- template<typename TypeIdResolverTag = PointerRemovedTypeIdTag> \
|
|
|
|
- static const AZ::TypeId& Uuid() { \
|
|
|
|
- static AZ::Internal::TypeIdHolder s_uuid( \
|
|
|
|
- !AZStd::is_same<TypeIdResolverTag, PointerRemovedTypeIdTag>::value \
|
|
|
|
- && AZStd::is_pointer<_Specialization>::value ? \
|
|
|
|
- AZ::AzTypeInfo<_T1>::template Uuid<TypeIdResolverTag>() + AZ::Internal::PointerTypeId() : AZ::AzTypeInfo<_T1>::template Uuid<TypeIdResolverTag>()); \
|
|
|
|
- return s_uuid; \
|
|
|
|
|
|
+ template<typename Tag = PointerRemovedTypeIdTag> \
|
|
|
|
+ static constexpr AZ::TypeId Uuid() \
|
|
|
|
+ { \
|
|
|
|
+ return s_uuid_v<Tag>; \
|
|
} \
|
|
} \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
{ \
|
|
{ \
|
|
@@ -904,36 +905,36 @@ namespace AZ
|
|
}
|
|
}
|
|
|
|
|
|
// Helper macros to generically specialize template types
|
|
// Helper macros to generically specialize template types
|
|
-#define AZ_TYPE_INFO_INTERNAL_VARIATION_GENERIC(_Generic, _Uuid) \
|
|
|
|
- namespace AzGenericTypeInfo { \
|
|
|
|
- template<> \
|
|
|
|
- inline const AZ::TypeId& Uuid<_Generic>(){ static AZ::Internal::TypeIdHolder s_uuid(_Uuid); return s_uuid; } \
|
|
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_VARIATION_GENERIC(_Generic, _Uuid) \
|
|
|
|
+ namespace AzGenericTypeInfo { \
|
|
|
|
+ template<> \
|
|
|
|
+ inline constexpr AZ::TypeId Uuid<_Generic>(){ return AZ::TypeId(_Uuid); } \
|
|
}
|
|
}
|
|
|
|
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME__TYPE typename
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME__TYPE typename
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME__ARG(A) A
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME__ARG(A) A
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME__UUID(Tag, A) AZ::Internal::GetTypeId< A , Tag >()
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME__UUID(Tag, A) AZ::Internal::GetTypeId< A , Tag >()
|
|
-#define AZ_TYPE_INFO_INTERNAL_TYPENAME__NAME(A) AZ::Internal::AzTypeInfoSafeCat(AZStd::data(typeName), AZStd::size(typeName), AZ::Internal::GetTypeName< A >())
|
|
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_TYPENAME__NAME(A) AZ::Internal::GetTypeName< A >()
|
|
|
|
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS__TYPE class
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS__TYPE class
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS__ARG(A) A
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS__ARG(A) A
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS__UUID(Tag, A) AZ::Internal::GetTypeId< A , Tag >()
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS__UUID(Tag, A) AZ::Internal::GetTypeId< A , Tag >()
|
|
-#define AZ_TYPE_INFO_INTERNAL_CLASS__NAME(A) AZ::Internal::AzTypeInfoSafeCat(AZStd::data(typeName), AZStd::size(typeName), AZ::Internal::GetTypeName< A >())
|
|
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_CLASS__NAME(A) AZ::Internal::GetTypeName< A >()
|
|
|
|
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME_VARARGS__TYPE typename...
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME_VARARGS__TYPE typename...
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME_VARARGS__ARG(A) A...
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME_VARARGS__ARG(A) A...
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME_VARARGS__UUID(Tag, A) AZ::Internal::AggregateTypes< A... >::template Uuid< Tag >()
|
|
#define AZ_TYPE_INFO_INTERNAL_TYPENAME_VARARGS__UUID(Tag, A) AZ::Internal::AggregateTypes< A... >::template Uuid< Tag >()
|
|
-#define AZ_TYPE_INFO_INTERNAL_TYPENAME_VARARGS__NAME(A) AZ::Internal::AggregateTypes< A... >::TypeName(AZStd::data(typeName), AZStd::size(typeName))
|
|
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_TYPENAME_VARARGS__NAME(A) AZ::Internal::AggregateTypes< A... >::TypeName()
|
|
|
|
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS_VARARGS__TYPE class...
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS_VARARGS__TYPE class...
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS_VARARGS__ARG(A) A...
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS_VARARGS__ARG(A) A...
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS_VARARGS__UUID(Tag, A) AZ::Internal::AggregateTypes< A... >::template Uuid< Tag >()
|
|
#define AZ_TYPE_INFO_INTERNAL_CLASS_VARARGS__UUID(Tag, A) AZ::Internal::AggregateTypes< A... >::template Uuid< Tag >()
|
|
-#define AZ_TYPE_INFO_INTERNAL_CLASS_VARARGS__NAME(A) AZ::Internal::AggregateTypes< A... >::TypeName(AZStd::data(typeName), AZStd::size(typeName));
|
|
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_CLASS_VARARGS__NAME(A) AZ::Internal::AggregateTypes< A... >::TypeName()
|
|
|
|
|
|
#define AZ_TYPE_INFO_INTERNAL_AUTO__TYPE auto
|
|
#define AZ_TYPE_INFO_INTERNAL_AUTO__TYPE auto
|
|
#define AZ_TYPE_INFO_INTERNAL_AUTO__ARG(A) A
|
|
#define AZ_TYPE_INFO_INTERNAL_AUTO__ARG(A) A
|
|
#define AZ_TYPE_INFO_INTERNAL_AUTO__UUID(Tag, A) AZ::Internal::GetTypeId< A , Tag >()
|
|
#define AZ_TYPE_INFO_INTERNAL_AUTO__UUID(Tag, A) AZ::Internal::GetTypeId< A , Tag >()
|
|
-#define AZ_TYPE_INFO_INTERNAL_AUTO__NAME(A) AZ::Internal::AzTypeInfoSafeCat(AZStd::data(typeName), AZStd::size(typeName), AZ::Internal::GetTypeName< A >())
|
|
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_AUTO__NAME(A) AZ::Internal::GetTypeName< A >()
|
|
|
|
|
|
#define AZ_TYPE_INFO_INTERNAL_EXPAND_I(NAME, TARGET) NAME##__##TARGET
|
|
#define AZ_TYPE_INFO_INTERNAL_EXPAND_I(NAME, TARGET) NAME##__##TARGET
|
|
#define AZ_TYPE_INFO_INTERNAL_EXPAND(NAME, TARGET) AZ_TYPE_INFO_INTERNAL_EXPAND_I(NAME, TARGET)
|
|
#define AZ_TYPE_INFO_INTERNAL_EXPAND(NAME, TARGET) AZ_TYPE_INFO_INTERNAL_EXPAND_I(NAME, TARGET)
|
|
@@ -953,11 +954,11 @@ namespace AZ
|
|
#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_ARGUMENT_EXPANSION_5(_1, _2, _3, _4, _5) AZ_TYPE_INFO_INTERNAL_TEMPLATE_ARGUMENT_EXPANSION_4(_1, _2, _3, _4), AZ_TYPE_INFO_INTERNAL_EXPAND(_5, ARG)(T5)
|
|
#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_ARGUMENT_EXPANSION_5(_1, _2, _3, _4, _5) AZ_TYPE_INFO_INTERNAL_TEMPLATE_ARGUMENT_EXPANSION_4(_1, _2, _3, _4), AZ_TYPE_INFO_INTERNAL_EXPAND(_5, ARG)(T5)
|
|
#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_ARGUMENT_EXPANSION(...) AZ_MACRO_SPECIALIZE(AZ_TYPE_INFO_INTERNAL_TEMPLATE_ARGUMENT_EXPANSION_, AZ_VA_NUM_ARGS(__VA_ARGS__), (__VA_ARGS__))
|
|
#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_ARGUMENT_EXPANSION(...) AZ_MACRO_SPECIALIZE(AZ_TYPE_INFO_INTERNAL_TEMPLATE_ARGUMENT_EXPANSION_, AZ_VA_NUM_ARGS(__VA_ARGS__), (__VA_ARGS__))
|
|
|
|
|
|
-#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_1(_1) AZ_TYPE_INFO_INTERNAL_EXPAND(_1, NAME)(T1);
|
|
|
|
-#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_2(_1, _2) AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_1(_1) AZ::Internal::AzTypeInfoSafeCat(AZStd::data(typeName), AZStd::size(typeName), ", "); AZ_TYPE_INFO_INTERNAL_EXPAND(_2, NAME)(T2);
|
|
|
|
-#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_3(_1, _2, _3) AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_2(_1, _2) AZ::Internal::AzTypeInfoSafeCat(AZStd::data(typeName), AZStd::size(typeName), ", "); AZ_TYPE_INFO_INTERNAL_EXPAND(_3, NAME)(T3);
|
|
|
|
-#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_4(_1, _2, _3, _4) AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_3(_1, _2, _3) AZ::Internal::AzTypeInfoSafeCat(AZStd::data(typeName), AZStd::size(typeName), ", "); AZ_TYPE_INFO_INTERNAL_EXPAND(_4, NAME)(T4);
|
|
|
|
-#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_5(_1, _2, _3, _4, _5) AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_4(_1, _2, _3, _4) AZ::Internal::AzTypeInfoSafeCat(AZStd::data(typeName), AZStd::size(typeName), ", "); AZ_TYPE_INFO_INTERNAL_EXPAND(_5, NAME)(T5);
|
|
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_1(_1) AZ_TYPE_INFO_INTERNAL_EXPAND(_1, NAME)(T1)
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_2(_1, _2) AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_1(_1), AZ_TYPE_INFO_INTERNAL_EXPAND(_2, NAME)(T2)
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_3(_1, _2, _3) AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_2(_1, _2), AZ_TYPE_INFO_INTERNAL_EXPAND(_3, NAME)(T3)
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_4(_1, _2, _3, _4) AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_3(_1, _2, _3), AZ_TYPE_INFO_INTERNAL_EXPAND(_4, NAME)(T4)
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_5(_1, _2, _3, _4, _5) AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_4(_1, _2, _3, _4), AZ_TYPE_INFO_INTERNAL_EXPAND(_5, NAME)(T5)
|
|
#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION(...) AZ_MACRO_SPECIALIZE(AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_, AZ_VA_NUM_ARGS(__VA_ARGS__), (__VA_ARGS__))
|
|
#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION(...) AZ_MACRO_SPECIALIZE(AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION_, AZ_VA_NUM_ARGS(__VA_ARGS__), (__VA_ARGS__))
|
|
|
|
|
|
#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_UUID_EXPANSION_1(Tag, _1) AZ_TYPE_INFO_INTERNAL_EXPAND(_1, UUID)(Tag, T1)
|
|
#define AZ_TYPE_INFO_INTERNAL_TEMPLATE_UUID_EXPANSION_1(Tag, _1) AZ_TYPE_INFO_INTERNAL_EXPAND(_1, UUID)(Tag, T1)
|
|
@@ -978,22 +979,20 @@ namespace AZ
|
|
{ \
|
|
{ \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
{ \
|
|
{ \
|
|
- using CombineBufferType = AZStd::array<char, 1024>; \
|
|
|
|
- CombineBufferType typeName{}; \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), _Name "<"); \
|
|
|
|
- AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION(__VA_ARGS__) \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), ">"); \
|
|
|
|
|
|
+ using CombineBufferType = AZStd::fixed_string<1024>; \
|
|
|
|
+ CombineBufferType typeName{ _Name "<" }; \
|
|
|
|
+ typeName.append_range(AZStd::to_array<AZStd::string_view>( \
|
|
|
|
+ { AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION(__VA_ARGS__) }) \
|
|
|
|
+ | AZStd::views::join_with(AZ::Internal::TypeNameSeparator)); \
|
|
|
|
+ typeName += '>'; \
|
|
return typeName; \
|
|
return typeName; \
|
|
}(); \
|
|
}(); \
|
|
- /* Create a buffer that can store the exact number of characters for the type name + NUL */ \
|
|
|
|
- constexpr size_t NameLength = AZStd::char_traits<char>::length(combineTypeNameBuffer.data()); \
|
|
|
|
- AZStd::array<char, NameLength + 1> resultBuffer{}; \
|
|
|
|
- AZStd::copy(combineTypeNameBuffer.begin(), combineTypeNameBuffer.begin() + NameLength, resultBuffer.begin()); \
|
|
|
|
- return resultBuffer; \
|
|
|
|
|
|
+ /* Round up to power of 2 to reduce the number of fixed_string template instantiations */ \
|
|
|
|
+ return AZStd::fixed_string<AZ::AlignUpToPowerOfTwo(combineTypeNameBuffer.size())>(combineTypeNameBuffer); \
|
|
}(); \
|
|
}(); \
|
|
constexpr const char* operator()() const \
|
|
constexpr const char* operator()() const \
|
|
{ \
|
|
{ \
|
|
- return TypeName.data(); \
|
|
|
|
|
|
+ return TypeName.c_str(); \
|
|
} \
|
|
} \
|
|
}; \
|
|
}; \
|
|
public: \
|
|
public: \
|
|
@@ -1002,29 +1001,29 @@ namespace AZ
|
|
return TypeNameInternal{}(); \
|
|
return TypeNameInternal{}(); \
|
|
} \
|
|
} \
|
|
private: \
|
|
private: \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::CanonicalTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::CanonicalTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
- static AZ::Internal::TypeIdHolder s_uuid( \
|
|
|
|
|
|
+ return AZ::TypeId( \
|
|
AZ::TypeId(_ClassUuid) + \
|
|
AZ::TypeId(_ClassUuid) + \
|
|
AZ_TYPE_INFO_INTERNAL_TEMPLATE_UUID_EXPANSION(AZ::TypeIdResolverTags::CanonicalTypeIdTag, __VA_ARGS__)); \
|
|
AZ_TYPE_INFO_INTERNAL_TEMPLATE_UUID_EXPANSION(AZ::TypeIdResolverTags::CanonicalTypeIdTag, __VA_ARGS__)); \
|
|
- return s_uuid; \
|
|
|
|
} \
|
|
} \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
- static AZ::Internal::TypeIdHolder s_uuid( \
|
|
|
|
|
|
+ return AZ::TypeId( \
|
|
AZ::TypeId(_ClassUuid) + \
|
|
AZ::TypeId(_ClassUuid) + \
|
|
AZ_TYPE_INFO_INTERNAL_TEMPLATE_UUID_EXPANSION(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag, __VA_ARGS__)); \
|
|
AZ_TYPE_INFO_INTERNAL_TEMPLATE_UUID_EXPANSION(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag, __VA_ARGS__)); \
|
|
- return s_uuid; \
|
|
|
|
} \
|
|
} \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::GenericTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::GenericTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
return AzGenericTypeInfo::Uuid<_Specialization>(); \
|
|
return AzGenericTypeInfo::Uuid<_Specialization>(); \
|
|
} \
|
|
} \
|
|
|
|
+ template<class TypeIdResolverTag> \
|
|
|
|
+ inline static constexpr AZ::TypeId s_uuid_v = UuidTag(TypeIdResolverTag{}); \
|
|
public: \
|
|
public: \
|
|
template<typename Tag = AZ::TypeIdResolverTags::CanonicalTypeIdTag> \
|
|
template<typename Tag = AZ::TypeIdResolverTags::CanonicalTypeIdTag> \
|
|
- static const AZ::TypeId& Uuid() \
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid() \
|
|
{ \
|
|
{ \
|
|
- return UuidTag(Tag{}); \
|
|
|
|
|
|
+ return s_uuid_v<Tag>; \
|
|
} \
|
|
} \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
{ \
|
|
{ \
|
|
@@ -1051,22 +1050,20 @@ namespace AZ
|
|
{ \
|
|
{ \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
{ \
|
|
{ \
|
|
- using CombineBufferType = AZStd::array<char, 1024>; \
|
|
|
|
- CombineBufferType typeName{}; \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), #_Specialization "<"); \
|
|
|
|
- AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION(__VA_ARGS__) \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), ">"); \
|
|
|
|
|
|
+ using CombineBufferType = AZStd::fixed_string<1024>; \
|
|
|
|
+ CombineBufferType typeName{ #_Specialization "<" }; \
|
|
|
|
+ typeName.append_range(AZStd::to_array<AZStd::string_view>( \
|
|
|
|
+ { AZ_TYPE_INFO_INTERNAL_TEMPLATE_NAME_EXPANSION(__VA_ARGS__) }) \
|
|
|
|
+ | AZStd::views::join_with(AZ::Internal::TypeNameSeparator)); \
|
|
|
|
+ typeName += '>'; \
|
|
return typeName; \
|
|
return typeName; \
|
|
}(); \
|
|
}(); \
|
|
- /* Create a buffer that can store the exact number of characters for the type name + NUL */ \
|
|
|
|
- constexpr size_t NameLength = AZStd::char_traits<char>::length(combineTypeNameBuffer.data()); \
|
|
|
|
- AZStd::array<char, NameLength + 1> resultBuffer{}; \
|
|
|
|
- AZStd::copy(combineTypeNameBuffer.begin(), combineTypeNameBuffer.begin() + NameLength, resultBuffer.begin()); \
|
|
|
|
- return resultBuffer; \
|
|
|
|
|
|
+ /* Round up to power of 2 to reduce the number of fixed_string template instantiations */ \
|
|
|
|
+ return AZStd::fixed_string<AZ::AlignUpToPowerOfTwo(combineTypeNameBuffer.size())>(combineTypeNameBuffer); \
|
|
}(); \
|
|
}(); \
|
|
constexpr const char* operator()() const \
|
|
constexpr const char* operator()() const \
|
|
{ \
|
|
{ \
|
|
- return TypeName.data(); \
|
|
|
|
|
|
+ return TypeName.c_str(); \
|
|
} \
|
|
} \
|
|
}; \
|
|
}; \
|
|
public: \
|
|
public: \
|
|
@@ -1075,29 +1072,29 @@ namespace AZ
|
|
return TypeNameInternal{}(); \
|
|
return TypeNameInternal{}(); \
|
|
} \
|
|
} \
|
|
private: \
|
|
private: \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::CanonicalTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::CanonicalTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
- static AZ::Internal::TypeIdHolder s_uuid( \
|
|
|
|
|
|
+ return AZ::TypeId( \
|
|
AZ_TYPE_INFO_INTERNAL_TEMPLATE_UUID_EXPANSION(AZ::TypeIdResolverTags::CanonicalTypeIdTag, __VA_ARGS__) \
|
|
AZ_TYPE_INFO_INTERNAL_TEMPLATE_UUID_EXPANSION(AZ::TypeIdResolverTags::CanonicalTypeIdTag, __VA_ARGS__) \
|
|
+ AZ::TypeId(_ClassUuid)); \
|
|
+ AZ::TypeId(_ClassUuid)); \
|
|
- return s_uuid; \
|
|
|
|
} \
|
|
} \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
- static AZ::Internal::TypeIdHolder s_uuid( \
|
|
|
|
|
|
+ return AZ::TypeId( \
|
|
AZ_TYPE_INFO_INTERNAL_TEMPLATE_UUID_EXPANSION(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag, __VA_ARGS__) \
|
|
AZ_TYPE_INFO_INTERNAL_TEMPLATE_UUID_EXPANSION(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag, __VA_ARGS__) \
|
|
+ AZ::TypeId(_ClassUuid)); \
|
|
+ AZ::TypeId(_ClassUuid)); \
|
|
- return s_uuid; \
|
|
|
|
} \
|
|
} \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::GenericTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::GenericTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
return AzGenericTypeInfo::Uuid<_Specialization>(); \
|
|
return AzGenericTypeInfo::Uuid<_Specialization>(); \
|
|
} \
|
|
} \
|
|
|
|
+ template<class TypeIdResolverTag> \
|
|
|
|
+ inline static constexpr AZ::TypeId s_uuid_v = UuidTag(TypeIdResolverTag{}); \
|
|
public: \
|
|
public: \
|
|
template<typename Tag = AZ::TypeIdResolverTags::CanonicalTypeIdTag> \
|
|
template<typename Tag = AZ::TypeIdResolverTags::CanonicalTypeIdTag> \
|
|
- static const AZ::TypeId& Uuid() \
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid() \
|
|
{ \
|
|
{ \
|
|
- return UuidTag(Tag{}); \
|
|
|
|
|
|
+ return s_uuid_v<Tag>; \
|
|
} \
|
|
} \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
{ \
|
|
{ \
|
|
@@ -1110,7 +1107,7 @@ namespace AZ
|
|
{ \
|
|
{ \
|
|
return sizeof(_Specialization<AZ_TYPE_INFO_INTERNAL_TEMPLATE_ARGUMENT_EXPANSION(__VA_ARGS__)>); \
|
|
return sizeof(_Specialization<AZ_TYPE_INFO_INTERNAL_TEMPLATE_ARGUMENT_EXPANSION(__VA_ARGS__)>); \
|
|
} \
|
|
} \
|
|
- static bool Specialized() { return true; } \
|
|
|
|
|
|
+ static constexpr bool Specialized() { return true; } \
|
|
}
|
|
}
|
|
|
|
|
|
#define AZ_TYPE_INFO_INTERNAL_FUNCTION_VARIATION_SPECIALIZATION(_Specialization, _ClassUuid)\
|
|
#define AZ_TYPE_INFO_INTERNAL_FUNCTION_VARIATION_SPECIALIZATION(_Specialization, _ClassUuid)\
|
|
@@ -1124,23 +1121,19 @@ namespace AZ
|
|
{ \
|
|
{ \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
{ \
|
|
{ \
|
|
- using CombineBufferType = AZStd::array<char, 1024>; \
|
|
|
|
- CombineBufferType typeName{}; \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), #_Specialization "<"); \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), AZ::AzTypeInfo<R>::Name()); \
|
|
|
|
- AZ::Internal::AggregateTypes<Args...>::TypeName(typeName.data(), typeName.size()); \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), ">"); \
|
|
|
|
|
|
+ using CombineBufferType = AZStd::fixed_string<1024>; \
|
|
|
|
+ CombineBufferType typeName{ #_Specialization "<" }; \
|
|
|
|
+ typeName += AZ::AzTypeInfo<R>::Name(); \
|
|
|
|
+ typeName += AZ::Internal::AggregateTypes<Args...>::TypeName(); \
|
|
|
|
+ typeName += '>'; \
|
|
return typeName; \
|
|
return typeName; \
|
|
}(); \
|
|
}(); \
|
|
- /* Create a buffer that can store the exact number of characters for the type name + NUL */ \
|
|
|
|
- constexpr size_t NameLength = AZStd::char_traits<char>::length(combineTypeNameBuffer.data()); \
|
|
|
|
- AZStd::array<char, NameLength + 1> resultBuffer{}; \
|
|
|
|
- AZStd::copy(combineTypeNameBuffer.begin(), combineTypeNameBuffer.begin() + NameLength, resultBuffer.begin()); \
|
|
|
|
- return resultBuffer; \
|
|
|
|
|
|
+ /* Round up to power of 2 to reduce the number of fixed_string template instantiations */ \
|
|
|
|
+ return AZStd::fixed_string<AZ::AlignUpToPowerOfTwo(combineTypeNameBuffer.size())>(combineTypeNameBuffer); \
|
|
}(); \
|
|
}(); \
|
|
constexpr const char* operator()() const \
|
|
constexpr const char* operator()() const \
|
|
{ \
|
|
{ \
|
|
- return TypeName.data(); \
|
|
|
|
|
|
+ return TypeName.c_str(); \
|
|
} \
|
|
} \
|
|
}; \
|
|
}; \
|
|
public: \
|
|
public: \
|
|
@@ -1149,29 +1142,29 @@ namespace AZ
|
|
return TypeNameInternal{}(); \
|
|
return TypeNameInternal{}(); \
|
|
} \
|
|
} \
|
|
private: \
|
|
private: \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::CanonicalTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::CanonicalTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
- static AZ::Internal::TypeIdHolder s_uuid( \
|
|
|
|
|
|
+ return AZ::TypeId( \
|
|
AZ::Uuid(_ClassUuid) + AZ::AzTypeInfo<R>::template Uuid<AZ::TypeIdResolverTags::CanonicalTypeIdTag>() + \
|
|
AZ::Uuid(_ClassUuid) + AZ::AzTypeInfo<R>::template Uuid<AZ::TypeIdResolverTags::CanonicalTypeIdTag>() + \
|
|
AZ::Internal::AggregateTypes<Args...>::template Uuid<AZ::TypeIdResolverTags::CanonicalTypeIdTag>()); \
|
|
AZ::Internal::AggregateTypes<Args...>::template Uuid<AZ::TypeIdResolverTags::CanonicalTypeIdTag>()); \
|
|
- return s_uuid; \
|
|
|
|
} \
|
|
} \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
- static AZ::Internal::TypeIdHolder s_uuid( \
|
|
|
|
|
|
+ return AZ::TypeId( \
|
|
AZ::Uuid(_ClassUuid) + AZ::AzTypeInfo<R>::template Uuid<AZ::TypeIdResolverTags::PointerRemovedTypeIdTag>() + \
|
|
AZ::Uuid(_ClassUuid) + AZ::AzTypeInfo<R>::template Uuid<AZ::TypeIdResolverTags::PointerRemovedTypeIdTag>() + \
|
|
AZ::Internal::AggregateTypes<Args...>::template Uuid<AZ::TypeIdResolverTags::PointerRemovedTypeIdTag>()); \
|
|
AZ::Internal::AggregateTypes<Args...>::template Uuid<AZ::TypeIdResolverTags::PointerRemovedTypeIdTag>()); \
|
|
- return s_uuid; \
|
|
|
|
} \
|
|
} \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::GenericTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::GenericTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
return AzGenericTypeInfo::Uuid<_Specialization>(); \
|
|
return AzGenericTypeInfo::Uuid<_Specialization>(); \
|
|
} \
|
|
} \
|
|
|
|
+ template<class TypeIdResolverTag> \
|
|
|
|
+ inline static constexpr AZ::TypeId s_uuid_v = UuidTag(TypeIdResolverTag{}); \
|
|
public: \
|
|
public: \
|
|
template<typename Tag = AZ::TypeIdResolverTags::CanonicalTypeIdTag> \
|
|
template<typename Tag = AZ::TypeIdResolverTags::CanonicalTypeIdTag> \
|
|
- static const AZ::TypeId& Uuid() \
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid() \
|
|
{ \
|
|
{ \
|
|
- return UuidTag(Tag{}); \
|
|
|
|
|
|
+ return s_uuid_v<Tag>; \
|
|
} \
|
|
} \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
{ \
|
|
{ \
|
|
@@ -1184,7 +1177,7 @@ namespace AZ
|
|
{ \
|
|
{ \
|
|
return sizeof(_Specialization<R(Args...)>); \
|
|
return sizeof(_Specialization<R(Args...)>); \
|
|
} \
|
|
} \
|
|
- static bool Specialized() { return true; } \
|
|
|
|
|
|
+ static constexpr bool Specialized() { return true; } \
|
|
}
|
|
}
|
|
|
|
|
|
/* This version of AZ_TYPE_INFO_INTERNAL_VARIATION_SPECIALIZATION_2 only uses the first argument for UUID generation purposes */
|
|
/* This version of AZ_TYPE_INFO_INTERNAL_VARIATION_SPECIALIZATION_2 only uses the first argument for UUID generation purposes */
|
|
@@ -1199,22 +1192,18 @@ namespace AZ
|
|
{ \
|
|
{ \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
{ \
|
|
{ \
|
|
- using CombineBufferType = AZStd::array<char, 1024>; \
|
|
|
|
- CombineBufferType typeName{}; \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), #_Specialization "<"); \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), AZ::AzTypeInfo<_T1>::Name()); \
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), ">"); \
|
|
|
|
|
|
+ using CombineBufferType = AZStd::fixed_string<1024>; \
|
|
|
|
+ CombineBufferType typeName{ #_Specialization "<" }; \
|
|
|
|
+ typeName += AZ::AzTypeInfo<_T1>::Name(); \
|
|
|
|
+ typeName += '>'; \
|
|
return typeName; \
|
|
return typeName; \
|
|
}(); \
|
|
}(); \
|
|
- /* Create a buffer that can store the exact number of characters for the type name + NUL */ \
|
|
|
|
- constexpr size_t NameLength = AZStd::char_traits<char>::length(combineTypeNameBuffer.data()); \
|
|
|
|
- AZStd::array<char, NameLength + 1> resultBuffer{}; \
|
|
|
|
- AZStd::copy(combineTypeNameBuffer.begin(), combineTypeNameBuffer.begin() + NameLength, resultBuffer.begin()); \
|
|
|
|
- return resultBuffer; \
|
|
|
|
|
|
+ /* Round up to power of 2 to reduce the number of fixed_string template instantiations */ \
|
|
|
|
+ return AZStd::fixed_string<AZ::AlignUpToPowerOfTwo(combineTypeNameBuffer.size())>(combineTypeNameBuffer);\
|
|
}(); \
|
|
}(); \
|
|
constexpr const char* operator()() const \
|
|
constexpr const char* operator()() const \
|
|
{ \
|
|
{ \
|
|
- return TypeName.data(); \
|
|
|
|
|
|
+ return TypeName.c_str(); \
|
|
} \
|
|
} \
|
|
}; \
|
|
}; \
|
|
public: \
|
|
public: \
|
|
@@ -1223,29 +1212,29 @@ namespace AZ
|
|
return TypeNameInternal{}(); \
|
|
return TypeNameInternal{}(); \
|
|
} \
|
|
} \
|
|
private: \
|
|
private: \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::CanonicalTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::CanonicalTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
- static AZ::Internal::TypeIdHolder s_uuid( \
|
|
|
|
- AZ::AzTypeInfo<_T1>::template Uuid<AZ::TypeIdResolverTags::CanonicalTypeIdTag>() + \
|
|
|
|
|
|
+ return AZ::TypeId( \
|
|
|
|
+ AZ::AzTypeInfo<_T1>::template Uuid<AZ::TypeIdResolverTags::PointerRemovedTypeIdTag>() + \
|
|
AZ::TypeId(_AddUuid)); \
|
|
AZ::TypeId(_AddUuid)); \
|
|
- return s_uuid; \
|
|
|
|
} \
|
|
} \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::PointerRemovedTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
- static AZ::Internal::TypeIdHolder s_uuid( \
|
|
|
|
|
|
+ return AZ::TypeId( \
|
|
AZ::AzTypeInfo<_T1>::template Uuid<AZ::TypeIdResolverTags::PointerRemovedTypeIdTag>() + \
|
|
AZ::AzTypeInfo<_T1>::template Uuid<AZ::TypeIdResolverTags::PointerRemovedTypeIdTag>() + \
|
|
AZ::TypeId(_AddUuid)); \
|
|
AZ::TypeId(_AddUuid)); \
|
|
- return s_uuid; \
|
|
|
|
} \
|
|
} \
|
|
- static const AZ::TypeId& UuidTag(AZ::TypeIdResolverTags::GenericTypeIdTag) \
|
|
|
|
|
|
+ static constexpr AZ::TypeId UuidTag(AZ::TypeIdResolverTags::GenericTypeIdTag) \
|
|
{ \
|
|
{ \
|
|
return AzGenericTypeInfo::Uuid<_Specialization>(); \
|
|
return AzGenericTypeInfo::Uuid<_Specialization>(); \
|
|
} \
|
|
} \
|
|
|
|
+ template<class TypeIdResolverTag> \
|
|
|
|
+ inline static constexpr AZ::TypeId s_uuid_v = UuidTag(TypeIdResolverTag{}); \
|
|
public: \
|
|
public: \
|
|
template<typename Tag = AZ::TypeIdResolverTags::CanonicalTypeIdTag> \
|
|
template<typename Tag = AZ::TypeIdResolverTags::CanonicalTypeIdTag> \
|
|
- static const AZ::TypeId& Uuid() \
|
|
|
|
|
|
+ static constexpr AZ::TypeId Uuid() \
|
|
{ \
|
|
{ \
|
|
- return UuidTag(Tag{}); \
|
|
|
|
|
|
+ return s_uuid_v<Tag>; \
|
|
} \
|
|
} \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
static constexpr TypeTraits GetTypeTraits() \
|
|
{ \
|
|
{ \
|
|
@@ -1258,7 +1247,7 @@ namespace AZ
|
|
{ \
|
|
{ \
|
|
return sizeof(_Specialization<_T1, _T2>); \
|
|
return sizeof(_Specialization<_T1, _T2>); \
|
|
} \
|
|
} \
|
|
- static bool Specialized() { return true; } \
|
|
|
|
|
|
+ static constexpr bool Specialized() { return true; } \
|
|
}
|
|
}
|
|
|
|
|
|
AZ_TYPE_INFO_INTERNAL_SPECIALIZE(char, "{3AB0037F-AF8D-48ce-BCA0-A170D18B2C03}");
|
|
AZ_TYPE_INFO_INTERNAL_SPECIALIZE(char, "{3AB0037F-AF8D-48ce-BCA0-A170D18B2C03}");
|
|
@@ -1331,39 +1320,34 @@ namespace AZ
|
|
} // namespace AZ
|
|
} // namespace AZ
|
|
|
|
|
|
// Template class type info
|
|
// Template class type info
|
|
-#define AZ_TYPE_INFO_INTERNAL_TEMPLATE(_ClassName, _ClassUuid, ...)\
|
|
|
|
- struct TYPEINFO_Enable{};\
|
|
|
|
- struct TypeNameInternal\
|
|
|
|
- {\
|
|
|
|
|
|
+#define AZ_TYPE_INFO_INTERNAL_TEMPLATE(_ClassName, _ClassUuid, ...) \
|
|
|
|
+ struct TYPEINFO_Enable{}; \
|
|
|
|
+ struct TypeNameInternal \
|
|
|
|
+ { \
|
|
static constexpr auto TypeName = []() constexpr \
|
|
static constexpr auto TypeName = []() constexpr \
|
|
- {\
|
|
|
|
|
|
+ { \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
constexpr auto combineTypeNameBuffer = []() constexpr \
|
|
- {\
|
|
|
|
- using CombineBufferType = AZStd::array<char, 1024>;\
|
|
|
|
- CombineBufferType typeName{};\
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), #_ClassName "<");\
|
|
|
|
- AZ::Internal::AggregateTypes<__VA_ARGS__>::TypeName(typeName.data(), typeName.size());\
|
|
|
|
- AZ::Internal::AzTypeInfoSafeCat(typeName.data(), typeName.size(), ">");\
|
|
|
|
- return typeName;\
|
|
|
|
- }();\
|
|
|
|
- /* Create a buffer that can store the exact number of characters for the type name + NUL */ \
|
|
|
|
- constexpr size_t NameLength = AZStd::char_traits<char>::length(combineTypeNameBuffer.data());\
|
|
|
|
- AZStd::array<char, NameLength + 1> resultBuffer{};\
|
|
|
|
- AZStd::copy(combineTypeNameBuffer.begin(), combineTypeNameBuffer.begin() + NameLength, resultBuffer.begin());\
|
|
|
|
- return resultBuffer;\
|
|
|
|
- }();\
|
|
|
|
|
|
+ { \
|
|
|
|
+ using CombineBufferType = AZStd::fixed_string<1024>; \
|
|
|
|
+ CombineBufferType typeName{ #_ClassName "<" }; \
|
|
|
|
+ typeName += AZ::Internal::AggregateTypes<__VA_ARGS__>::TypeName(); \
|
|
|
|
+ typeName += '>'; \
|
|
|
|
+ return typeName; \
|
|
|
|
+ }(); \
|
|
|
|
+ return AZStd::fixed_string<AZ::AlignUpToPowerOfTwo(combineTypeNameBuffer.size())>(combineTypeNameBuffer); \
|
|
|
|
+ }(); \
|
|
constexpr const char* operator()() const \
|
|
constexpr const char* operator()() const \
|
|
{ \
|
|
{ \
|
|
- return TypeName.data(); \
|
|
|
|
|
|
+ return TypeName.c_str(); \
|
|
} \
|
|
} \
|
|
}; \
|
|
}; \
|
|
static constexpr const char* TYPEINFO_Name() \
|
|
static constexpr const char* TYPEINFO_Name() \
|
|
{ \
|
|
{ \
|
|
return TypeNameInternal{}(); \
|
|
return TypeNameInternal{}(); \
|
|
} \
|
|
} \
|
|
- static const AZ::TypeId& TYPEINFO_Uuid() {\
|
|
|
|
- static AZ::Internal::TypeIdHolder s_uuid(AZ::TypeId(_ClassUuid) + AZ::Internal::AggregateTypes<__VA_ARGS__>::Uuid());\
|
|
|
|
- return s_uuid;\
|
|
|
|
|
|
+ static constexpr AZ::TypeId TYPEINFO_Uuid() \
|
|
|
|
+ { \
|
|
|
|
+ return AZ::TypeId(_ClassUuid) + AZ::Internal::AggregateTypes<__VA_ARGS__>::Uuid(); \
|
|
}
|
|
}
|
|
|
|
|
|
// Template class type info
|
|
// Template class type info
|