Merge branch 'development' of https://github.com/o3de/o3de into daimini/settings-registry-origin-tracking
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Crc.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
|
||||
#include <AzCore/std/containers/unordered_set.h>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define AZCORE_ENTITY_ID_H
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
/** @file
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <type_traits>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
#include <AzCore/std/limits.h>
|
||||
#include <AzCore/std/string/string_view.h>
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace AZ
|
||||
void DebugBreak();
|
||||
#endif
|
||||
void Terminate(int exitCode);
|
||||
void OutputToDebugger(const char* window, const char* message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,11 @@ namespace AZ
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
namespace Platform
|
||||
{
|
||||
void OutputToDebugger(const char* window, const char* message);
|
||||
}
|
||||
|
||||
/// Global instance to the tracer.
|
||||
extern class Trace g_tracer;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/IO/Path/Path_fwd.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Module/Environment.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/std/parallel/shared_mutex.h>
|
||||
#include <AzCore/std/typetraits/is_constructible.h>
|
||||
#include <AzCore/std/typetraits/is_assignable.h>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/base.h>
|
||||
|
||||
#include <AzCore/std/hash.h>
|
||||
#include <AzCore/std/string/string_view.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -108,7 +108,7 @@ namespace AZ
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
template<>
|
||||
template<>
|
||||
struct hash<AZ::Crc32>
|
||||
{
|
||||
size_t operator()(const AZ::Crc32& id) const
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
#include <AzCore/Math/Random_Platform.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/std/containers/array.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Internal/MathTypes.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Internal/MathTypes.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
|
||||
@@ -1006,12 +1006,6 @@ namespace AZ
|
||||
AZ_TYPE_INFO_INTERNAL_FUNCTION_VARIATION_SPECIALIZATION(AZStd::function, "{C9F9C644-CCC3-4F77-A792-F5B5DBCA746E}");
|
||||
} // namespace AZ
|
||||
|
||||
#define AZ_TYPE_INFO_INTERNAL_1(_ClassName) static_assert(false, "You must provide a ClassName,ClassUUID")
|
||||
#define AZ_TYPE_INFO_INTERNAL_2(_ClassName, _ClassUuid) \
|
||||
void TYPEINFO_Enable(){} \
|
||||
static const char* TYPEINFO_Name() { return #_ClassName; } \
|
||||
static const AZ::TypeId& TYPEINFO_Uuid() { static AZ::TypeId s_uuid(_ClassUuid); return s_uuid; }
|
||||
|
||||
// Template class type info
|
||||
#define AZ_TYPE_INFO_INTERNAL_TEMPLATE(_ClassName, _ClassUuid, ...)\
|
||||
void TYPEINFO_Enable() {}\
|
||||
@@ -1050,39 +1044,11 @@ namespace AZ
|
||||
#define AZ_TYPE_INFO_INTERNAL_17 AZ_TYPE_INFO_INTERNAL_TEMPLATE
|
||||
#define AZ_TYPE_INFO_INTERNAL(...) AZ_MACRO_SPECIALIZE(AZ_TYPE_INFO_INTERNAL_, AZ_VA_NUM_ARGS(__VA_ARGS__), (__VA_ARGS__))
|
||||
|
||||
#define AZ_TYPE_INFO_1 AZ_TYPE_INFO_INTERNAL_1
|
||||
#define AZ_TYPE_INFO_2 AZ_TYPE_INFO_INTERNAL_2
|
||||
#define AZ_TYPE_INFO_3 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_4 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_5 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_6 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_7 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_8 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_9 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_10 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_11 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_12 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_13 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_14 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_15 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_16 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
#define AZ_TYPE_INFO_17 AZ_TYPE_INFO_INTERNAL_TEMPLATE_DEPRECATED
|
||||
|
||||
// Fall-back for the original version of AZ_TYPE_INFO that accepted template arguments. This should not be used, unless
|
||||
// to fix issues where AZ_TYPE_INFO was incorrectly used and the old UUID has to be maintained.
|
||||
#define AZ_TYPE_INFO_LEGACY AZ_TYPE_INFO_INTERNAL
|
||||
|
||||
/**
|
||||
* Use this macro inside a class to allow it to be identified across modules and serialized (in different contexts).
|
||||
* The expected input is the class and the assigned uuid as a string or an instance of a uuid.
|
||||
* Example:
|
||||
* class MyClass
|
||||
* {
|
||||
* public:
|
||||
* AZ_TYPE_INFO(MyClass, "{BD5B1568-D232-4EBF-93BD-69DB66E3773F}");
|
||||
* ...
|
||||
*/
|
||||
#define AZ_TYPE_INFO(...) AZ_MACRO_SPECIALIZE(AZ_TYPE_INFO_, AZ_VA_NUM_ARGS(__VA_ARGS__), (__VA_ARGS__))
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
|
||||
/**
|
||||
* Use this macro outside a class to allow it to be identified across modules and serialized (in different contexts).
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Uuid.h>
|
||||
#include <AzCore/std/typetraits/is_enum.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
using TypeId = AZ::Uuid;
|
||||
}
|
||||
|
||||
#define AZ_TYPE_INFO_INTERNAL_1(_ClassName) static_assert(false, "You must provide a ClassName,ClassUUID")
|
||||
#define AZ_TYPE_INFO_INTERNAL_2(_ClassName, _ClassUuid) \
|
||||
void TYPEINFO_Enable(){} \
|
||||
static const char* TYPEINFO_Name() { return #_ClassName; } \
|
||||
static const AZ::TypeId& TYPEINFO_Uuid() { static AZ::TypeId s_uuid(_ClassUuid); return s_uuid; }
|
||||
|
||||
#define AZ_TYPE_INFO_1 AZ_TYPE_INFO_INTERNAL_1
|
||||
#define AZ_TYPE_INFO_2 AZ_TYPE_INFO_INTERNAL_2
|
||||
|
||||
/**
|
||||
* Use this macro inside a class to allow it to be identified across modules and serialized (in different contexts).
|
||||
* The expected input is the class and the assigned uuid as a string or an instance of a uuid.
|
||||
* Example:
|
||||
* class MyClass
|
||||
* {
|
||||
* public:
|
||||
* AZ_TYPE_INFO(MyClass, "{BD5B1568-D232-4EBF-93BD-69DB66E3773F}");
|
||||
* ...
|
||||
*/
|
||||
#define AZ_TYPE_INFO(...) AZ_MACRO_SPECIALIZE(AZ_TYPE_INFO_, AZ_VA_NUM_ARGS(__VA_ARGS__), (__VA_ARGS__))
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define AZCORE_DATA_OVERLAY_H
|
||||
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <AzCore/Serialization/Json/BaseJsonSerializer.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <AzCore/Serialization/Json/BaseJsonSerializer.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <AzCore/Serialization/Json/BaseJsonSerializer.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
|
||||
@@ -434,6 +434,7 @@ set(FILES
|
||||
Preprocessor/Sequences.h
|
||||
RTTI/RTTI.h
|
||||
RTTI/TypeInfo.h
|
||||
RTTI/TypeInfoSimple.h
|
||||
RTTI/ReflectContext.h
|
||||
RTTI/ReflectContext.cpp
|
||||
RTTI/ReflectionManager.h
|
||||
|
||||
@@ -51,88 +51,86 @@
|
||||
# define azvscprintf(_format, _va_list) _vscprintf(_format, _va_list)
|
||||
# define azscwprintf _scwprintf
|
||||
# define azvscwprintf _vscwprintf
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok_s(_buffer, _delim, _context)
|
||||
# define azstrcat strcat_s
|
||||
# define azstrncat strncat_s
|
||||
# define strtoll _strtoi64
|
||||
# define strtoull _strtoui64
|
||||
# define azsscanf sscanf_s
|
||||
# define azstrcpy strcpy_s
|
||||
# define azstrncpy strncpy_s
|
||||
# define azstricmp _stricmp
|
||||
# define azstrnicmp _strnicmp
|
||||
# define azisfinite _finite
|
||||
# define azltoa _ltoa_s
|
||||
# define azitoa _itoa_s
|
||||
# define azui64toa _ui64toa_s
|
||||
# define azswscanf swscanf_s
|
||||
# define azwcsicmp _wcsicmp
|
||||
# define azwcsnicmp _wcsnicmp
|
||||
# define azmemicmp _memicmp
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok_s(_buffer, _delim, _context)
|
||||
# define azstrcat(_dest, _destSize, _src) strcat_s(_dest, _destSize, _src)
|
||||
# define azstrncat(_dest, _destSize, _src, _count) strncat_s(_dest, _destSize, _src, _count)
|
||||
# define strtoll _strtoi64
|
||||
# define strtoull _strtoui64
|
||||
# define azsscanf sscanf_s
|
||||
# define azstrcpy(_dest, _destSize, _src) strcpy_s(_dest, _destSize, _src)
|
||||
# define azstrncpy(_dest, _destSize, _src, _count) strncpy_s(_dest, _destSize, _src, _count)
|
||||
# define azstricmp _stricmp
|
||||
# define azstrnicmp _strnicmp
|
||||
# define azisfinite _finite
|
||||
# define azltoa _ltoa_s
|
||||
# define azitoa _itoa_s
|
||||
# define azui64toa _ui64toa_s
|
||||
# define azswscanf swscanf_s
|
||||
# define azwcsicmp _wcsicmp
|
||||
# define azwcsnicmp _wcsnicmp
|
||||
|
||||
// note: for cross-platform compatibility, do not use the return value of azfopen. On Windows, it's an errno_t and 0 indicates success. On other platforms, the return value is a FILE*, and a 0 value indicates failure.
|
||||
# define azfopen fopen_s
|
||||
# define azfscanf fscanf_s
|
||||
# define azfopen(_fp, _filename, _attrib) fopen_s(_fp, _filename, _attrib)
|
||||
# define azfscanf fscanf_s
|
||||
|
||||
# define azsprintf(_buffer, ...) sprintf_s(_buffer, AZ_ARRAY_SIZE(_buffer), __VA_ARGS__)
|
||||
# define azstrlwr _strlwr_s
|
||||
# define azvsprintf vsprintf_s
|
||||
# define azwcscpy wcscpy_s
|
||||
# define azstrtime _strtime_s
|
||||
# define azstrdate _strdate_s
|
||||
# define azlocaltime(time, result) localtime_s(result, time)
|
||||
# define azsprintf(_buffer, ...) sprintf_s(_buffer, AZ_ARRAY_SIZE(_buffer), __VA_ARGS__)
|
||||
# define azstrlwr _strlwr_s
|
||||
# define azvsprintf vsprintf_s
|
||||
# define azwcscpy wcscpy_s
|
||||
# define azstrtime _strtime_s
|
||||
# define azstrdate _strdate_s
|
||||
# define azlocaltime(time, result) localtime_s(result, time)
|
||||
#else
|
||||
# define azsnprintf snprintf
|
||||
# define azvsnprintf vsnprintf
|
||||
# define azsnprintf snprintf
|
||||
# define azvsnprintf vsnprintf
|
||||
# if AZ_TRAIT_COMPILER_DEFINE_AZSWNPRINTF_AS_SWPRINTF
|
||||
# define azsnwprintf swprintf
|
||||
# define azvsnwprintf vswprintf
|
||||
# define azsnwprintf swprintf
|
||||
# define azvsnwprintf vswprintf
|
||||
# else
|
||||
# define azsnwprintf snwprintf
|
||||
# define azvsnwprintf vsnwprintf
|
||||
# define azsnwprintf snwprintf
|
||||
# define azvsnwprintf vsnwprintf
|
||||
# endif
|
||||
# define azscprintf(...) azsnprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscprintf(_format, _va_list) azvsnprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azscwprintf(...) azsnwprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscwprintf(_format, _va_list) azvsnwprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok(_buffer, _delim)
|
||||
# define azstrcat(_dest, _destSize, _src) strcat(_dest, _src)
|
||||
# define azstrncat(_dest, _destSize, _src, _count) strncat(_dest, _src, _count)
|
||||
# define azsscanf sscanf
|
||||
# define azstrcpy(_dest, _destSize, _src) strcpy(_dest, _src)
|
||||
# define azstrncpy(_dest, _destSize, _src, _count) strncpy(_dest, _src, _count)
|
||||
# define azstricmp strcasecmp
|
||||
# define azstrnicmp strncasecmp
|
||||
# define azscprintf(...) azsnprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscprintf(_format, _va_list) azvsnprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azscwprintf(...) azsnwprintf(nullptr, static_cast<size_t>(0), __VA_ARGS__);
|
||||
# define azvscwprintf(_format, _va_list) azvsnwprintf(nullptr, static_cast<size_t>(0), _format, _va_list);
|
||||
# define azstrtok(_buffer, _size, _delim, _context) strtok(_buffer, _delim)
|
||||
# define azstrcat(_dest, _destSize, _src) strcat(_dest, _src)
|
||||
# define azstrncat(_dest, _destSize, _src, _count) strncat(_dest, _src, _count)
|
||||
# define azsscanf sscanf
|
||||
# define azstrcpy(_dest, _destSize, _src) strcpy(_dest, _src)
|
||||
# define azstrncpy(_dest, _destSize, _src, _count) strncpy(_dest, _src, _count)
|
||||
# define azstricmp strcasecmp
|
||||
# define azstrnicmp strncasecmp
|
||||
# if defined(NDK_REV_MAJOR) && NDK_REV_MAJOR < 16
|
||||
# define azisfinite __isfinitef
|
||||
# define azisfinite __isfinitef
|
||||
# else
|
||||
# define azisfinite isfinite
|
||||
# define azisfinite isfinite
|
||||
# endif
|
||||
# define azltoa(_value, _buffer, _size, _radix) ltoa(_value, _buffer, _radix)
|
||||
# define azitoa(_value, _buffer, _size, _radix) itoa(_value, _buffer, _radix)
|
||||
# define azui64toa(_value, _buffer, _size, _radix) _ui64toa(_value, _buffer, _radix)
|
||||
# define azswscanf swscanf
|
||||
# define azwcsicmp wcsicmp
|
||||
# define azwcsnicmp wcsnicmp
|
||||
# define azmemicmp memicmp
|
||||
# define azltoa(_value, _buffer, _size, _radix) ltoa(_value, _buffer, _radix)
|
||||
# define azitoa(_value, _buffer, _size, _radix) itoa(_value, _buffer, _radix)
|
||||
# define azui64toa(_value, _buffer, _size, _radix) _ui64toa(_value, _buffer, _radix)
|
||||
# define azswscanf swscanf
|
||||
# define azwcsicmp wcscasecmp
|
||||
# define azwcsnicmp wcsnicmp
|
||||
|
||||
// note: for cross-platform compatibility, do not use the return value of azfopen. On Windows, it's an errno_t and 0 indicates success. On other platforms, the return value is a FILE*, and a 0 value indicates failure.
|
||||
# define azfopen(_fp, _filename, _attrib) *(_fp) = fopen(_filename, _attrib)
|
||||
# define azfscanf fscanf
|
||||
# define azfopen(_fp, _filename, _attrib) *(_fp) = fopen(_filename, _attrib)
|
||||
# define azfscanf fscanf
|
||||
|
||||
# define azsprintf sprintf
|
||||
# define azstrlwr(_buffer, _size) strlwr(_buffer)
|
||||
# define azvsprintf vsprintf
|
||||
# define azwcscpy(_dest, _size, _buffer) wcscpy(_dest, _buffer)
|
||||
# define azstrtime _strtime
|
||||
# define azstrdate _strdate
|
||||
# define azlocaltime localtime_r
|
||||
# define azsprintf sprintf
|
||||
# define azstrlwr(_buffer, _size) strlwr(_buffer)
|
||||
# define azvsprintf vsprintf
|
||||
# define azwcscpy(_dest, _size, _buffer) wcscpy(_dest, _buffer)
|
||||
# define azstrtime _strtime
|
||||
# define azstrdate _strdate
|
||||
# define azlocaltime localtime_r
|
||||
#endif
|
||||
|
||||
#if AZ_TRAIT_USE_POSIX_STRERROR_R
|
||||
# define azstrerror_s(_dst, _num, _err) strerror_r(_err, _dst, _num)
|
||||
# define azstrerror_s(_dst, _num, _err) strerror_r(_err, _dst, _num)
|
||||
#else
|
||||
# define azstrerror_s strerror_s
|
||||
# define azstrerror_s strerror_s
|
||||
#endif
|
||||
|
||||
#define AZ_INVALID_POINTER reinterpret_cast<void*>(0x0badf00dul)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <AzCore/std/base.h>
|
||||
#include <AzCore/std/typetraits/integral_constant.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/TypeInfoSimple.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <AzCore/std/typetraits/integral_constant.h>
|
||||
#include <AzCore/std/typetraits/void_t.h>
|
||||
#include <AzCore/std/createdestroy.h>
|
||||
#include <AzCore/std/limits.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <AzCore/std/base.h>
|
||||
#include <AzCore/std/ratio.h>
|
||||
#include <AzCore/std/utils.h>
|
||||
#include <AzCore/std/typetraits/common_type.h>
|
||||
#include <AzCore/std/typetraits/is_convertible.h>
|
||||
#include <AzCore/std/typetraits/is_floating_point.h>
|
||||
|
||||
@@ -5,14 +5,17 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef AZSTD_DEQUE_H
|
||||
#define AZSTD_DEQUE_H 1
|
||||
|
||||
|
||||
#include <AzCore/std/allocator.h>
|
||||
#include <AzCore/std/algorithm.h>
|
||||
#include <AzCore/std/createdestroy.h>
|
||||
#include <AzCore/std/typetraits/aligned_storage.h>
|
||||
#include <AzCore/std/typetraits/alignment_of.h>
|
||||
#include <AzCore/std/typetraits/is_integral.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
@@ -1242,4 +1245,3 @@ namespace AZStd
|
||||
}
|
||||
|
||||
#endif // AZSTD_DEQUE_H
|
||||
#pragma once
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
*/
|
||||
#ifndef AZSTD_LIST_H
|
||||
#define AZSTD_LIST_H 1
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/allocator.h>
|
||||
#include <AzCore/std/algorithm.h>
|
||||
#include <AzCore/std/createdestroy.h>
|
||||
#include <AzCore/std/typetraits/alignment_of.h>
|
||||
#include <AzCore/std/typetraits/is_constructible.h>
|
||||
#include <AzCore/std/typetraits/is_integral.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
@@ -1346,4 +1348,3 @@ namespace AZStd
|
||||
}
|
||||
|
||||
#endif // AZSTD_LIST_H
|
||||
#pragma once
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <AzCore/std/algorithm.h>
|
||||
#include <AzCore/std/createdestroy.h>
|
||||
#include <AzCore/std/utils.h>
|
||||
//#include <AzCore/std/containers/deque.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#ifndef AZSTD_VECTOR_H
|
||||
#define AZSTD_VECTOR_H 1
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/allocator.h>
|
||||
#include <AzCore/std/algorithm.h>
|
||||
#include <AzCore/std/createdestroy.h>
|
||||
#include <AzCore/std/typetraits/alignment_of.h>
|
||||
#include <AzCore/std/typetraits/is_integral.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
@@ -1395,6 +1395,3 @@ namespace AZStd
|
||||
return removedCount;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // AZSTD_VECTOR_H
|
||||
#pragma once
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/std/typetraits/is_function.h>
|
||||
#include <AzCore/std/typetraits/is_trivially_copyable.h>
|
||||
#include <AzCore/std/typetraits/is_void.h>
|
||||
#include <AzCore/std/utils.h> // AZStd::addressof
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/std/typetraits/type_id.h>
|
||||
#include <AzCore/std/typetraits/alignment_of.h>
|
||||
#include <AzCore/std/typetraits/is_member_pointer.h>
|
||||
#include <AzCore/std/typetraits/is_const.h>
|
||||
#include <AzCore/std/typetraits/remove_cvref.h>
|
||||
#include <AzCore/std/createdestroy.h>
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <AzCore/std/function/function_base.h>
|
||||
#include <AzCore/std/function/invoke.h>
|
||||
#include <AzCore/std/typetraits/is_integral.h>
|
||||
#include <AzCore/std/typetraits/remove_cvref.h>
|
||||
#include <AzCore/std/allocator.h>
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/MathUtils.h>
|
||||
#include <AzCore/std/containers/node_handle.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/containers/fixed_vector.h>
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/base.h>
|
||||
#include <AzCore/std/utils.h>
|
||||
#include <AzCore/std/typetraits/integral_constant.h>
|
||||
#include <AzCore/std/typetraits/void_t.h>
|
||||
#include <AzCore/std/typetraits/is_convertible.h>
|
||||
|
||||
#include <AzCore/std/typetraits/is_base_of.h> // use by ConstIteratorCast
|
||||
#include <AzCore/std/typetraits/remove_cv.h>
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/parallel/config.h>
|
||||
#include <AzCore/std/typetraits/conditional.h>
|
||||
#include <AzCore/std/typetraits/is_integral.h>
|
||||
#include <atomic>
|
||||
|
||||
namespace AZStd
|
||||
|
||||
@@ -38,13 +38,13 @@ namespace AZStd
|
||||
|
||||
binary_semaphore(bool initialState = false)
|
||||
{
|
||||
m_event = CreateEvent(nullptr, false, initialState, nullptr);
|
||||
m_event = CreateEventW(nullptr, false, initialState, nullptr);
|
||||
AZ_Assert(m_event != NULL, "CreateEvent error: %d\n", GetLastError());
|
||||
}
|
||||
binary_semaphore(const char* name, bool initialState = false)
|
||||
{
|
||||
(void)name; // name is used only for debug, if we pass it to the semaphore it will become named semaphore
|
||||
m_event = CreateEvent(nullptr, false, initialState, nullptr);
|
||||
m_event = CreateEventW(nullptr, false, initialState, nullptr);
|
||||
AZ_Assert(m_event != NULL, "CreateEvent error: %d\n", GetLastError());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#ifndef AZSTD_SMART_PTR_INTRUSIVE_PTR_H
|
||||
#define AZSTD_SMART_PTR_INTRUSIVE_PTR_H
|
||||
#pragma once
|
||||
|
||||
//
|
||||
// intrusive_ptr.hpp
|
||||
@@ -19,10 +18,10 @@
|
||||
//
|
||||
// See http://www.boost.org/libs/smart_ptr/intrusive_ptr.html for documentation.
|
||||
//
|
||||
|
||||
#include <AzCore/std/smart_ptr/sp_convertible.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <AzCore/std/smart_ptr/sp_convertible.h>
|
||||
#include <AzCore/std/typetraits/is_abstract.h>
|
||||
#include <AzCore/std/typetraits/typetraits.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
@@ -112,7 +111,7 @@ namespace AZStd
|
||||
CountPolicy::add_ref(px);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
~intrusive_ptr()
|
||||
{
|
||||
if (px != 0)
|
||||
@@ -120,7 +119,7 @@ namespace AZStd
|
||||
CountPolicy::release(px);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class U>
|
||||
enable_if_t<is_convertible<U*, T*>::value, intrusive_ptr&> operator=(intrusive_ptr<U> const& rhs)
|
||||
{
|
||||
@@ -157,28 +156,28 @@ namespace AZStd
|
||||
this_type(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
intrusive_ptr& operator=(T* rhs)
|
||||
{
|
||||
this_type(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void reset()
|
||||
{
|
||||
this_type().swap(*this);
|
||||
}
|
||||
|
||||
|
||||
void reset(T* rhs)
|
||||
{
|
||||
this_type(rhs).swap(*this);
|
||||
}
|
||||
|
||||
|
||||
T* get() const
|
||||
{
|
||||
return px;
|
||||
}
|
||||
|
||||
|
||||
T& operator*() const
|
||||
{
|
||||
AZ_Assert(px != 0, "You can't dereference a null pointer");
|
||||
@@ -298,6 +297,3 @@ namespace AZStd
|
||||
|
||||
// operator<< - not supported
|
||||
} // namespace AZStd
|
||||
|
||||
#endif // #ifndef AZSTD_SMART_PTR_INTRUSIVE_PTR_H
|
||||
#pragma once
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <wctype.h>
|
||||
@@ -30,41 +31,93 @@ namespace AZStd
|
||||
template<size_t Size = sizeof(wchar_t)>
|
||||
struct WCharTPlatformConverter
|
||||
{
|
||||
template<class Allocator1>
|
||||
static inline void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator1>& dest, const wchar_t* first, const wchar_t* last)
|
||||
static_assert(Size == size_t{ 2 } || Size == size_t{ 4 }, "only wchar_t types of size 2 or 4 can be converted to utf8");
|
||||
|
||||
template<class Allocator>
|
||||
static inline void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator>& dest, AZStd::wstring_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
Utf8::Unchecked::utf16to8(first, last, AZStd::back_inserter(dest));
|
||||
Utf8::Unchecked::utf16to8(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
Utf8::Unchecked::utf32to8(first, last, AZStd::back_inserter(dest));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Workaround to defer static_assert evaluation until this function is invoked by using the template parameter
|
||||
using StringType = AZStd::basic_string<string::value_type, string::traits_type, Allocator1>;
|
||||
static_assert(!AZStd::is_same_v<StringType, StringType>, "only wchar_t types of size 2 or 4 can be converted to utf8");
|
||||
Utf8::Unchecked::utf32to8(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
}
|
||||
|
||||
template<class Allocator1>
|
||||
static inline void to_wstring(AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator1>& dest, const char* first, const char* last)
|
||||
template<size_t MaxElementCount>
|
||||
static inline void to_string(AZStd::basic_fixed_string<string::value_type, MaxElementCount, string::traits_type>& dest, AZStd::wstring_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
Utf8::Unchecked::utf8to16(first, last, AZStd::back_inserter(dest));
|
||||
Utf8::Unchecked::utf16to8(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
Utf8::Unchecked::utf8to32(first, last, AZStd::back_inserter(dest));
|
||||
Utf8::Unchecked::utf32to8(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
static inline char* to_string(char* dest, size_t destSize, AZStd::wstring_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
// Workaround to defer static_assert evaluation until this function is invoked by using the template parameter
|
||||
using StringType = AZStd::basic_string<string::value_type, string::traits_type, Allocator1>;
|
||||
static_assert(!AZStd::is_same_v<StringType, StringType>, "Cannot convert a utf8 string to a wchar_t that isn't size 2 or 4");
|
||||
return Utf8::Unchecked::utf16to8(src.begin(), src.end(), dest, destSize);
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
return Utf8::Unchecked::utf32to8(src.begin(), src.end(), dest, destSize);
|
||||
}
|
||||
}
|
||||
|
||||
static inline size_t to_string_length(AZStd::wstring_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
return Utf8::Unchecked::utf16ToUtf8BytesRequired(src.begin(), src.end());
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
return Utf8::Unchecked::utf32ToUtf8BytesRequired(src.begin(), src.end());
|
||||
}
|
||||
}
|
||||
|
||||
template<class Allocator>
|
||||
static inline void to_wstring(AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator>& dest, AZStd::string_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
Utf8::Unchecked::utf8to16(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
Utf8::Unchecked::utf8to32(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
}
|
||||
|
||||
template<size_t MaxElementCount>
|
||||
static inline void to_wstring(AZStd::basic_fixed_string<wstring::value_type, MaxElementCount, wstring::traits_type>& dest, AZStd::string_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
Utf8::Unchecked::utf8to16(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
Utf8::Unchecked::utf8to32(src.begin(), src.end(), AZStd::back_inserter(dest), dest.max_size());
|
||||
}
|
||||
}
|
||||
|
||||
static inline wchar_t* to_wstring(wchar_t* dest, size_t destSize, AZStd::string_view src)
|
||||
{
|
||||
if constexpr (Size == 2)
|
||||
{
|
||||
return Utf8::Unchecked::utf8to16(src.begin(), src.end(), dest, destSize);
|
||||
}
|
||||
else if constexpr (Size == 4)
|
||||
{
|
||||
return Utf8::Unchecked::utf8to32(src.begin(), src.end(), dest, destSize);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -244,26 +297,32 @@ namespace AZStd
|
||||
inline AZStd::string to_string(long double val) { AZStd::string str; to_string(str, val); return str; }
|
||||
|
||||
// In our engine we assume AZStd::string is Utf8 encoded!
|
||||
template<class Allocator1>
|
||||
void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator1>& dest, const wchar_t* str, size_t srcLen = 0)
|
||||
template<class Allocator>
|
||||
void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator>& dest, AZStd::wstring_view src)
|
||||
{
|
||||
dest.clear();
|
||||
Internal::WCharTPlatformConverter<>::to_string(dest, src);
|
||||
}
|
||||
|
||||
if (srcLen == 0)
|
||||
{
|
||||
srcLen = wcslen(str);
|
||||
}
|
||||
template<size_t MaxElementCount>
|
||||
void to_string(AZStd::basic_fixed_string<string::value_type, MaxElementCount, string::traits_type>& dest, AZStd::wstring_view src)
|
||||
{
|
||||
dest.clear();
|
||||
Internal::WCharTPlatformConverter<>::to_string(dest, src);
|
||||
}
|
||||
|
||||
if (srcLen > 0)
|
||||
inline void to_string(char* dest, size_t destSize, AZStd::wstring_view src)
|
||||
{
|
||||
char* endStr = Internal::WCharTPlatformConverter<>::to_string(dest, destSize, src);
|
||||
if (endStr < (dest + destSize))
|
||||
{
|
||||
Internal::WCharTPlatformConverter<>::to_string(dest, str, str + srcLen);
|
||||
*endStr = '\0'; // null terminator
|
||||
}
|
||||
}
|
||||
|
||||
template<class Allocator1, class Allocator2>
|
||||
void to_string(AZStd::basic_string<string::value_type, string::traits_type, Allocator1>& dest, const AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator2>& src)
|
||||
inline size_t to_string_length(AZStd::wstring_view src)
|
||||
{
|
||||
return to_string(dest, src.c_str(), src.length());
|
||||
return Internal::WCharTPlatformConverter<>::to_string_length(src);
|
||||
}
|
||||
|
||||
template<class Allocator>
|
||||
@@ -362,26 +421,27 @@ namespace AZStd
|
||||
inline AZStd::wstring to_wstring(unsigned long long val) { AZStd::wstring wstr; to_wstring(wstr, val); return wstr; }
|
||||
inline AZStd::wstring to_wstring(long double val) { AZStd::wstring wstr; to_wstring(wstr, val); return wstr; }
|
||||
|
||||
template<class Allocator1>
|
||||
void to_wstring(AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator1>& dest, const char* str, size_t strLen = 0)
|
||||
template<class Allocator>
|
||||
void to_wstring(AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator>& dest, AZStd::string_view src)
|
||||
{
|
||||
dest.clear();
|
||||
|
||||
if (strLen == 0)
|
||||
{
|
||||
strLen = strlen(str);
|
||||
}
|
||||
|
||||
if (strLen > 0)
|
||||
{
|
||||
Internal::WCharTPlatformConverter<>::to_wstring(dest, str, str + strLen);
|
||||
}
|
||||
Internal::WCharTPlatformConverter<>::to_wstring(dest, src);
|
||||
}
|
||||
|
||||
template<class Allocator1, class Allocator2>
|
||||
void to_wstring(AZStd::basic_string<wstring::value_type, wstring::traits_type, Allocator1>& dest, const AZStd::basic_string<string::value_type, string::traits_type, Allocator2>& src)
|
||||
template<size_t MaxElementCount>
|
||||
void to_wstring(AZStd::basic_fixed_string<wstring::value_type, MaxElementCount, wstring::traits_type>& dest, AZStd::string_view src)
|
||||
{
|
||||
return to_wstring(dest, src.c_str(), src.length());
|
||||
dest.clear();
|
||||
Internal::WCharTPlatformConverter<>::to_wstring(dest, src);
|
||||
}
|
||||
|
||||
inline void to_wstring(wchar_t* dest, size_t destSize, AZStd::string_view src)
|
||||
{
|
||||
wchar_t* endWStr = Internal::WCharTPlatformConverter<>::to_wstring(dest, destSize, src);
|
||||
if (endWStr < (dest + destSize))
|
||||
{
|
||||
*endWStr = '\0'; // null terminator
|
||||
}
|
||||
}
|
||||
|
||||
// Convert a range of chars to lower case
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/std/base.h>
|
||||
#include <AzCore/std/iterator.h>
|
||||
#include <AzCore/std/allocator.h>
|
||||
#include <AzCore/std/algorithm.h>
|
||||
#include <AzCore/std/typetraits/alignment_of.h>
|
||||
#include <AzCore/std/typetraits/is_integral.h>
|
||||
|
||||
|
||||
@@ -8,15 +8,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/std/algorithm.h>
|
||||
#include <AzCore/std/createdestroy.h>
|
||||
#include <AzCore/std/iterator.h>
|
||||
#include <AzCore/std/hash.h>
|
||||
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
namespace StringInternal
|
||||
{
|
||||
constexpr size_t min_size(size_t left, size_t right) { return (left < right) ? left : right; }
|
||||
|
||||
template<class Traits, class CharT, class SizeT>
|
||||
constexpr SizeT char_find(const CharT* s, size_t count, CharT ch, SizeT npos = static_cast<SizeT>(-1)) noexcept
|
||||
{
|
||||
@@ -83,7 +84,7 @@ namespace AZStd
|
||||
}
|
||||
|
||||
// Add one to offset so that for loop condition can check against 0 as the breakout condition
|
||||
size_t lastIndex = (AZStd::min)(offset, size - count) + 1;
|
||||
size_t lastIndex = StringInternal::min_size(offset, size - count) + 1;
|
||||
|
||||
for (; lastIndex; --lastIndex)
|
||||
{
|
||||
@@ -576,7 +577,7 @@ namespace AZStd
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
size_type rlen = AZStd::min<size_type>(count, size() - pos);
|
||||
size_type rlen = StringInternal::min_size(count, size() - pos);
|
||||
Traits::copy(dest, data() + pos, rlen);
|
||||
return rlen;
|
||||
}
|
||||
@@ -584,12 +585,12 @@ namespace AZStd
|
||||
constexpr basic_string_view substr(size_type pos = 0, size_type count = npos) const
|
||||
{
|
||||
AZ_Assert(pos <= size(), "Cannot create substring where position is larger than size");
|
||||
return pos > size() ? basic_string_view() : basic_string_view(data() + pos, AZStd::min<size_type>(count, size() - pos));
|
||||
return pos > size() ? basic_string_view() : basic_string_view(data() + pos, StringInternal::min_size(count, size() - pos));
|
||||
}
|
||||
|
||||
constexpr int compare(basic_string_view other) const
|
||||
{
|
||||
size_t cmpSize = AZStd::min<size_type>(size(), other.size());
|
||||
size_t cmpSize = StringInternal::min_size(size(), other.size());
|
||||
int cmpval = cmpSize == 0 ? 0 : Traits::compare(data(), other.data(), cmpSize);
|
||||
if (cmpval == 0)
|
||||
{
|
||||
@@ -891,6 +892,8 @@ namespace AZStd
|
||||
return hash;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
struct hash;
|
||||
template<class Element, class Traits>
|
||||
struct hash<basic_string_view<Element, Traits>>
|
||||
{
|
||||
|
||||
@@ -92,33 +92,58 @@ namespace Utf8::Unchecked
|
||||
return temp;
|
||||
}
|
||||
|
||||
static Iterator to_utf8_sequence(AZ::u32 cp, Iterator result)
|
||||
static Iterator to_utf8_sequence(AZ::u32 cp, Iterator& result, size_t& resultMaxSize)
|
||||
{
|
||||
if (cp < 0x80)
|
||||
{
|
||||
// one octet
|
||||
resultMaxSize -= 1; // no need to check the calling function will exit the loop
|
||||
*(result++) = static_cast<AZ::u8>(cp);
|
||||
}
|
||||
else if (cp < 0x800)
|
||||
{
|
||||
// two octets
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 6) | 0xc0);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
if (resultMaxSize >= 2)
|
||||
{
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 6) | 0xc0);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
resultMaxSize -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultMaxSize = 0;
|
||||
}
|
||||
}
|
||||
else if (cp < 0x10000)
|
||||
{
|
||||
// three octets
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 12) | 0xe0);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
if (resultMaxSize >= 3)
|
||||
{
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 12) | 0xe0);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
resultMaxSize -= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultMaxSize = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// four octets
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 18) | 0xf0);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 12) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
if (resultMaxSize >= 4)
|
||||
{
|
||||
*(result++) = static_cast<AZ::u8>((cp >> 18) | 0xf0);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 12) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>(((cp >> 6) & 0x3f) | 0x80);
|
||||
*(result++) = static_cast<AZ::u8>((cp & 0x3f) | 0x80);
|
||||
resultMaxSize -= 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultMaxSize = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -155,8 +180,99 @@ namespace Utf8::Unchecked
|
||||
};
|
||||
|
||||
template <typename u16bit_iterator, typename Utf8Iterator>
|
||||
Utf8Iterator utf16to8(u16bit_iterator start, u16bit_iterator end, Utf8Iterator result)
|
||||
Utf8Iterator utf16to8(u16bit_iterator start, u16bit_iterator end, Utf8Iterator result, size_t resultMaxSize)
|
||||
{
|
||||
while (start != end && resultMaxSize > 0)
|
||||
{
|
||||
AZ::u32 cp = Utf8::Internal::mask16(*start++);
|
||||
// Take care of surrogate pairs first
|
||||
if (Utf8::Internal::is_lead_surrogate(cp))
|
||||
{
|
||||
AZ::u32 trail_surrogate = Utf8::Internal::mask16(*start++);
|
||||
cp = (cp << 10) + trail_surrogate + Internal::SURROGATE_OFFSET;
|
||||
}
|
||||
octet_iterator<Utf8Iterator>::to_utf8_sequence(cp, result, resultMaxSize);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename Utf8Iterator>
|
||||
u16bit_iterator utf8to16(Utf8Iterator start, Utf8Iterator end, u16bit_iterator result, size_t resultMaxSize)
|
||||
{
|
||||
octet_iterator utf8Start(start);
|
||||
octet_iterator utf8Last(end);
|
||||
while (utf8Start != utf8Last && resultMaxSize > 0)
|
||||
{
|
||||
AZ::u32 cp = *utf8Start++;
|
||||
if (cp > 0xffff)
|
||||
{
|
||||
//make a surrogate pair
|
||||
if (resultMaxSize >= 2)
|
||||
{
|
||||
*result++ = static_cast<AZ::u16>((cp >> 10) + Internal::LEAD_OFFSET);
|
||||
*result++ = static_cast<AZ::u16>((cp & 0x3ff) + Internal::TRAIL_SURROGATE_MIN);
|
||||
resultMaxSize -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultMaxSize = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*result++ = static_cast<AZ::u16>(cp);
|
||||
resultMaxSize -= 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Utf8Iterator, typename u32bit_iterator>
|
||||
Utf8Iterator utf32to8(u32bit_iterator start, u32bit_iterator end, Utf8Iterator result, size_t resultMaxSize)
|
||||
{
|
||||
while (start != end && resultMaxSize > 0)
|
||||
{
|
||||
octet_iterator<Utf8Iterator>::to_utf8_sequence(*start++, result, resultMaxSize);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Utf8Iterator, typename u32bit_iterator>
|
||||
u32bit_iterator utf8to32(Utf8Iterator start, Utf8Iterator end, u32bit_iterator result, size_t resultMaxSize)
|
||||
{
|
||||
octet_iterator utf8Start(start);
|
||||
octet_iterator utf8Last(end);
|
||||
while (utf8Start != utf8Last && resultMaxSize > 0)
|
||||
{
|
||||
*result++ = *utf8Start++;
|
||||
--resultMaxSize;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static constexpr size_t utf8_codepoint_length(AZ::u32 cp)
|
||||
{
|
||||
if (cp < 0x80)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (cp < 0x800)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else if (cp < 0x10000)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator>
|
||||
size_t utf16ToUtf8BytesRequired(u16bit_iterator start, u16bit_iterator end)
|
||||
{
|
||||
size_t bytesRequired = 0;
|
||||
while (start != end)
|
||||
{
|
||||
AZ::u32 cp = Utf8::Internal::mask16(*start++);
|
||||
@@ -166,56 +282,23 @@ namespace Utf8::Unchecked
|
||||
AZ::u32 trail_surrogate = Utf8::Internal::mask16(*start++);
|
||||
cp = (cp << 10) + trail_surrogate + Internal::SURROGATE_OFFSET;
|
||||
}
|
||||
octet_iterator<Utf8Iterator>::to_utf8_sequence(cp, result);
|
||||
bytesRequired += utf8_codepoint_length(cp);
|
||||
}
|
||||
return result;
|
||||
return bytesRequired;
|
||||
}
|
||||
|
||||
template <typename u16bit_iterator, typename Utf8Iterator>
|
||||
u16bit_iterator utf8to16(Utf8Iterator start, Utf8Iterator end, u16bit_iterator result)
|
||||
{
|
||||
octet_iterator utf8Start(start);
|
||||
octet_iterator utf8Last(end);
|
||||
while (utf8Start != utf8Last)
|
||||
{
|
||||
AZ::u32 cp = *utf8Start++;
|
||||
if (cp > 0xffff)
|
||||
{
|
||||
//make a surrogate pair
|
||||
*result++ = static_cast<AZ::u16>((cp >> 10) + Internal::LEAD_OFFSET);
|
||||
*result++ = static_cast<AZ::u16>((cp & 0x3ff) + Internal::TRAIL_SURROGATE_MIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
*result++ = static_cast<AZ::u16>(cp);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Utf8Iterator, typename u32bit_iterator>
|
||||
Utf8Iterator utf32to8(u32bit_iterator start, u32bit_iterator end, Utf8Iterator result)
|
||||
template <typename u32bit_iterator>
|
||||
size_t utf32ToUtf8BytesRequired(u32bit_iterator start, u32bit_iterator end)
|
||||
{
|
||||
size_t bytesRequired = 0;
|
||||
while (start != end)
|
||||
{
|
||||
octet_iterator<Utf8Iterator>::to_utf8_sequence(*start++, result);
|
||||
bytesRequired += utf8_codepoint_length(*start++);
|
||||
}
|
||||
|
||||
return result;
|
||||
return bytesRequired;
|
||||
}
|
||||
|
||||
template <typename Utf8Iterator, typename u32bit_iterator>
|
||||
u32bit_iterator utf8to32(Utf8Iterator start, Utf8Iterator end, u32bit_iterator result)
|
||||
{
|
||||
octet_iterator utf8Start(start);
|
||||
octet_iterator utf8Last(end);
|
||||
while (utf8Start != utf8Last)
|
||||
{
|
||||
*result++ = *utf8Start++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
} // namespace Utf8::Unchecked
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/typetraits/conditional.h>
|
||||
#include <AzCore/std/typetraits/integral_constant.h> // for true_type
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
|
||||
#include <AzCore/std/typetraits/aligned_storage.h>
|
||||
#include <AzCore/std/typetraits/alignment_of.h>
|
||||
#include <AzCore/std/utils.h>
|
||||
#include <AzCore/std/typetraits/conditional.h>
|
||||
#include <AzCore/std/parallel/atomic.h>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
using std::forward;
|
||||
// Extension: static_storage: Used to initialize statics in a thread-safe manner
|
||||
// These are similar to default_delete/no_delete, except they just invoke the destructor (or not)
|
||||
template <class T>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <AzCore/std/typetraits/is_lvalue_reference.h>
|
||||
#include <AzCore/std/typetraits/void_t.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace AZ
|
||||
|
||||
void OutputToDebugger(const char*, const char*)
|
||||
{
|
||||
// std::cout << title << ": " << message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -11,6 +11,7 @@
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/std/parallel/mutex.h>
|
||||
#include <AzCore/std/parallel/condition_variable.h>
|
||||
#include <AzCore/std/parallel/atomic.h>
|
||||
|
||||
namespace AZ::Platform
|
||||
{
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzCore/Debug/TraceMessagesDrillerBus.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -22,7 +24,7 @@ namespace AZ
|
||||
LPTOP_LEVEL_EXCEPTION_FILTER g_previousExceptionHandler = nullptr;
|
||||
#endif
|
||||
|
||||
const int g_maxMessageLength = 4096;
|
||||
constexpr int g_maxMessageLength = 4096;
|
||||
|
||||
namespace Debug
|
||||
{
|
||||
@@ -58,19 +60,18 @@ namespace AZ
|
||||
TerminateProcess(GetCurrentProcess(), exitCode);
|
||||
}
|
||||
|
||||
void OutputToDebugger(const char* window, const char* message)
|
||||
void OutputToDebugger([[maybe_unused]] const char* window, const char* message)
|
||||
{
|
||||
AZ_UNUSED(window);
|
||||
#ifdef _UNICODE
|
||||
wchar_t messageW[g_maxMessageLength];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, messageW, message, g_maxMessageLength - 1) == 0)
|
||||
AZStd::fixed_wstring<g_maxMessageLength> tmpW;
|
||||
if(window)
|
||||
{
|
||||
OutputDebugStringW(messageW);
|
||||
AZStd::to_wstring(tmpW, window);
|
||||
tmpW += L": ";
|
||||
OutputDebugStringW(tmpW.c_str());
|
||||
tmpW.clear();
|
||||
}
|
||||
#else // !_UNICODE
|
||||
OutputDebugString(message);
|
||||
#endif // !_UNICODE
|
||||
AZStd::to_wstring(tmpW, message);
|
||||
OutputDebugStringW(tmpW.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace
|
||||
//=========================================================================
|
||||
DWORD GetAttributes(const char* fileName)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
@@ -39,9 +38,6 @@ namespace
|
||||
{
|
||||
return INVALID_FILE_ATTRIBUTES;
|
||||
}
|
||||
#else //!_UNICODE
|
||||
return GetFileAttributes(fileName);
|
||||
#endif // !_UNICODE
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -51,7 +47,6 @@ namespace
|
||||
//=========================================================================
|
||||
BOOL SetAttributes(const char* fileName, DWORD fileAttributes)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
@@ -62,9 +57,6 @@ namespace
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#else //!_UNICODE
|
||||
return SetFileAttributes(fileName, fileAttributes);
|
||||
#endif // !_UNICODE
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -76,7 +68,6 @@ namespace
|
||||
// * GetLastError() on Windows-like platforms
|
||||
// * errno on Unix platforms
|
||||
//=========================================================================
|
||||
#if defined(_UNICODE)
|
||||
bool CreateDirRecursive(wchar_t* dirPath)
|
||||
{
|
||||
if (CreateDirectoryW(dirPath, nullptr))
|
||||
@@ -112,53 +103,6 @@ namespace
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
bool CreateDirRecursive(char* dirPath)
|
||||
{
|
||||
if (CreateDirectory(dirPath, nullptr))
|
||||
{
|
||||
return true; // Created without error
|
||||
}
|
||||
DWORD error = GetLastError();
|
||||
if (error == ERROR_PATH_NOT_FOUND)
|
||||
{
|
||||
// try to create our parent hierarchy
|
||||
for (size_t i = strlen(dirPath); i > 0; --i)
|
||||
{
|
||||
if (dirPath[i] == '/' || dirPath[i] == '\\')
|
||||
{
|
||||
char delimiter = dirPath[i];
|
||||
dirPath[i] = 0; // null-terminate at the previous slash
|
||||
bool ret = CreateDirRecursive(dirPath);
|
||||
dirPath[i] = delimiter; // restore slash
|
||||
if (ret)
|
||||
{
|
||||
// now that our parent is created, try to create again
|
||||
if (CreateDirectory(dirPath, nullptr))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
DWORD creationError = GetLastError();
|
||||
if (creationError == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
DWORD attributes = GetFileAttributes(dirPath);
|
||||
return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if we reach here then there was no parent folder to create, so we failed for other reasons
|
||||
}
|
||||
else if (error == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
DWORD attributes = GetFileAttributes(dirPath);
|
||||
return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const SystemFile::FileHandleType PlatformSpecificInvalidHandle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
@@ -208,7 +152,6 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
CreatePath(m_fileName.c_str());
|
||||
}
|
||||
|
||||
# ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
m_handle = INVALID_HANDLE_VALUE;
|
||||
@@ -216,9 +159,6 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
{
|
||||
m_handle = CreateFileW(fileNameW, dwDesiredAccess, dwShareMode, 0, dwCreationDisposition, dwFlagsAndAttributes, 0);
|
||||
}
|
||||
# else //!_UNICODE
|
||||
m_handle = CreateFile(m_fileName.c_str(), dwDesiredAccess, dwShareMode, 0, dwCreationDisposition, dwFlagsAndAttributes, 0);
|
||||
# endif // !_UNICODE
|
||||
|
||||
if (m_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -417,7 +357,6 @@ namespace Platform
|
||||
HANDLE hFile;
|
||||
int lastError;
|
||||
|
||||
#ifdef _UNICODE
|
||||
wchar_t filterW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
hFile = INVALID_HANDLE_VALUE;
|
||||
@@ -425,39 +364,28 @@ namespace Platform
|
||||
{
|
||||
hFile = FindFirstFile(filterW, &fd);
|
||||
}
|
||||
#else // !_UNICODE
|
||||
hFile = FindFirstFile(filter, &fd);
|
||||
#endif // !_UNICODE
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
const char* fileName;
|
||||
|
||||
#ifdef _UNICODE
|
||||
char fileNameA[AZ_MAX_PATH_LEN];
|
||||
fileName = NULL;
|
||||
if (wcstombs_s(&numCharsConverted, fileNameA, fd.cFileName, AZ_ARRAY_SIZE(fileNameA) - 1) == 0)
|
||||
{
|
||||
fileName = fileNameA;
|
||||
}
|
||||
#else // !_UNICODE
|
||||
fileName = fd.cFileName;
|
||||
#endif // !_UNICODE
|
||||
|
||||
cb(fileName, (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0);
|
||||
|
||||
// List all the other files in the directory.
|
||||
while (FindNextFile(hFile, &fd) != 0)
|
||||
while (FindNextFileW(hFile, &fd) != 0)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
fileName = NULL;
|
||||
if (wcstombs_s(&numCharsConverted, fileNameA, fd.cFileName, AZ_ARRAY_SIZE(fileNameA) - 1) == 0)
|
||||
{
|
||||
fileName = fileNameA;
|
||||
}
|
||||
#else // !_UNICODE
|
||||
fileName = fd.cFileName;
|
||||
#endif // !_UNICODE
|
||||
|
||||
cb(fileName, (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0);
|
||||
}
|
||||
@@ -483,16 +411,12 @@ namespace Platform
|
||||
{
|
||||
HANDLE handle = nullptr;
|
||||
|
||||
#ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
{
|
||||
handle = CreateFileW(fileNameW, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
}
|
||||
#else // !_UNICODE
|
||||
handle = CreateFileA(fileName, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
#endif // !_UNICODE
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -524,16 +448,12 @@ namespace Platform
|
||||
WIN32_FILE_ATTRIBUTE_DATA data = { 0 };
|
||||
BOOL result = FALSE;
|
||||
|
||||
#ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
{
|
||||
result = GetFileAttributesExW(fileNameW, GetFileExInfoStandard, &data);
|
||||
}
|
||||
#else // !_UNICODE
|
||||
result = GetFileAttributesExA(fileName, GetFileExInfoStandard, &data);
|
||||
#endif // !_UNICODE
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -553,7 +473,6 @@ namespace Platform
|
||||
|
||||
bool Delete(const char* fileName)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
wchar_t fileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, fileNameW, fileName, AZ_ARRAY_SIZE(fileNameW) - 1) == 0)
|
||||
@@ -568,20 +487,12 @@ namespace Platform
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else // !_UNICODE
|
||||
if (DeleteFile(fileName) == 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, fileName, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
#endif // !_UNICODE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Rename(const char* sourceFileName, const char* targetFileName, bool overwrite)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
wchar_t sourceFileNameW[AZ_MAX_PATH_LEN];
|
||||
wchar_t targetFileNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
@@ -598,13 +509,6 @@ namespace Platform
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else // !_UNICODE
|
||||
if (MoveFileEx(sourceFileName, targetFileName, overwrite ? MOVEFILE_REPLACE_EXISTING : 0) == 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, sourceFileName, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
#endif // !_UNICODE
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -639,7 +543,6 @@ namespace Platform
|
||||
{
|
||||
if (dirName)
|
||||
{
|
||||
#if defined(_UNICODE)
|
||||
wchar_t dirPath[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, dirPath, dirName, AZ_ARRAY_SIZE(dirPath) - 1) == 0)
|
||||
@@ -651,18 +554,6 @@ namespace Platform
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#else
|
||||
char dirPath[AZ_MAX_PATH_LEN];
|
||||
if (azstrcpy(dirPath, AZ_ARRAY_SIZE(dirPath), dirName) == 0)
|
||||
{
|
||||
bool success = CreateDirRecursive(dirPath);
|
||||
if (!success)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, dirName, (int)GetLastError());
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -671,16 +562,12 @@ namespace Platform
|
||||
{
|
||||
if (dirName)
|
||||
{
|
||||
#if defined(_UNICODE)
|
||||
wchar_t dirNameW[AZ_MAX_PATH_LEN];
|
||||
size_t numCharsConverted;
|
||||
if (mbstowcs_s(&numCharsConverted, dirNameW, dirName, AZ_ARRAY_SIZE(dirNameW) - 1) == 0)
|
||||
{
|
||||
return RemoveDirectory(dirNameW) != 0;
|
||||
}
|
||||
#else
|
||||
return RemoveDirectory(dirName) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
-5
@@ -98,7 +98,6 @@ namespace AZ
|
||||
|
||||
bool alreadyLoaded = false;
|
||||
|
||||
# ifdef _UNICODE
|
||||
wchar_t fileNameW[MAX_PATH];
|
||||
size_t numCharsConverted;
|
||||
errno_t wcharResult = mbstowcs_s(&numCharsConverted, fileNameW, m_fileName.c_str(), AZ_ARRAY_SIZE(fileNameW) - 1);
|
||||
@@ -114,10 +113,6 @@ namespace AZ
|
||||
m_handle = NULL;
|
||||
return LoadStatus::LoadFailure;
|
||||
}
|
||||
# else //!_UNICODE
|
||||
alreadyLoaded = NULL != GetModuleHandleA(m_fileName.c_str());
|
||||
m_handle = LoadLibraryA(m_fileName.c_str());
|
||||
# endif // !_UNICODE
|
||||
|
||||
if (m_handle)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/std/optional.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -29,7 +30,8 @@ namespace AZ
|
||||
result.m_pathIncludesFilename = true;
|
||||
// Platform specific get exe path: http://stackoverflow.com/a/1024937
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamea
|
||||
const DWORD pathLen = GetModuleFileNameA(nullptr, exeStorageBuffer, static_cast<DWORD>(exeStorageSize));
|
||||
wchar_t pathBufferW[AZ::IO::MaxPathLength] = { 0 };
|
||||
const DWORD pathLen = GetModuleFileNameW(nullptr, pathBufferW, static_cast<DWORD>(AZStd::size(pathBufferW)));
|
||||
const DWORD errorCode = GetLastError();
|
||||
if (pathLen == exeStorageSize && errorCode == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
@@ -39,6 +41,18 @@ namespace AZ
|
||||
{
|
||||
result.m_pathStored = ExecutablePathResult::GeneralError;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t utf8PathSize = AZStd::to_string_length({ pathBufferW, pathLen });
|
||||
if (utf8PathSize >= exeStorageSize)
|
||||
{
|
||||
result.m_pathStored = ExecutablePathResult::BufferSizeNotLargeEnough;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZStd::to_string(exeStorageBuffer, exeStorageSize, pathBufferW);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -71,27 +71,11 @@ extern "C"
|
||||
using LPSECURITY_ATTRIBUTES = SECURITY_ATTRIBUTES*;
|
||||
|
||||
// Semaphore
|
||||
AZ_DLL_IMPORT HANDLE _stdcall CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCSTR lpName);
|
||||
AZ_DLL_IMPORT HANDLE _stdcall CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCWSTR lpName);
|
||||
AZ_DLL_IMPORT BOOL _stdcall ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount);
|
||||
#ifndef CreateSemaphore
|
||||
#ifdef UNICODE
|
||||
#define CreateSemaphore CreateSemaphoreW
|
||||
#else
|
||||
#define CreateSemaphore CreateSemaphoreA
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Event
|
||||
AZ_DLL_IMPORT HANDLE _stdcall CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName);
|
||||
AZ_DLL_IMPORT HANDLE _stdcall CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCWSTR lpName);
|
||||
#ifndef CreateEvent
|
||||
#ifdef UNICODE
|
||||
#define CreateEvent CreateEventW
|
||||
#else
|
||||
#define CreateEvent CreateEventA
|
||||
#endif
|
||||
#endif
|
||||
AZ_DLL_IMPORT BOOL _stdcall SetEvent(HANDLE);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -15,14 +15,14 @@ namespace AZStd
|
||||
{
|
||||
inline semaphore::semaphore(unsigned int initialCount, unsigned int maximumCount)
|
||||
{
|
||||
m_semaphore = CreateSemaphore(NULL, initialCount, maximumCount, 0);
|
||||
m_semaphore = CreateSemaphoreW(NULL, initialCount, maximumCount, 0);
|
||||
AZ_Assert(m_semaphore != NULL, "CreateSemaphore error: %d\n", GetLastError());
|
||||
}
|
||||
|
||||
inline semaphore::semaphore(const char* name, unsigned int initialCount, unsigned int maximumCount)
|
||||
{
|
||||
(void)name; // name is used only for debug, if we pass it to the semaphore it will become named semaphore
|
||||
m_semaphore = CreateSemaphore(NULL, initialCount, maximumCount, 0);
|
||||
m_semaphore = CreateSemaphoreW(NULL, initialCount, maximumCount, 0);
|
||||
AZ_Assert(m_semaphore != NULL, "CreateSemaphore error: %d\n", GetLastError());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -14,8 +15,9 @@ namespace AZ
|
||||
{
|
||||
namespace Platform
|
||||
{
|
||||
void OutputToDebugger(const char*, const char*)
|
||||
void OutputToDebugger([[maybe_unused]] const char* title, [[maybe_unused]] const char* message)
|
||||
{
|
||||
// std::cout << title << ": " << message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,20 +29,19 @@ namespace AZ
|
||||
return errno;
|
||||
}
|
||||
|
||||
void SharedMemory_Mac::ComposeMutexName(char* dest, size_t length, const char* name)
|
||||
void ComposeName(char* dest, size_t length, const char* name, const char* suffix)
|
||||
{
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
|
||||
// sem_open doesn't support paths bigger than 31, so call it s_Mtx.
|
||||
// While this is enough for Profiler, maybe the code should be smarter
|
||||
// and trim the name instead
|
||||
azsnprintf(dest, length, "/tmp/%s_Mtx", name);
|
||||
azsnprintf(dest, length, "/tmp/%s_%s", name, suffix);
|
||||
}
|
||||
|
||||
SharedMemory_Common::CreateResult SharedMemory_Mac::Create(const char* name, unsigned int size, bool openIfCreated)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Mtx");
|
||||
|
||||
m_globalMutex = sem_open(fullName, O_CREAT | O_EXCL, 0600, 1);
|
||||
int error = errno;
|
||||
@@ -59,7 +58,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
// Create the file mapping.
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Data");
|
||||
m_mapHandle = shm_open(fullName, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
error = errno;
|
||||
if (error == EEXIST)
|
||||
@@ -80,7 +79,8 @@ namespace AZ
|
||||
bool SharedMemory_Mac::Open(const char* name)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Mtx");
|
||||
|
||||
m_globalMutex = sem_open(fullName, 0);
|
||||
AZ_Warning("AZSystem", m_globalMutex != nullptr, "Failed to open OS mutex [%s]\n", m_name);
|
||||
@@ -90,7 +90,7 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
ComposeName(fullName, AZ_ARRAY_SIZE(fullName), name, "Data");
|
||||
m_mapHandle = shm_open(fullName, O_RDWR, 0600);
|
||||
if (m_mapHandle == -1)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace AZ
|
||||
|
||||
static int GetLastError();
|
||||
|
||||
void ComposeMutexName(char* dest, size_t length, const char* name);
|
||||
CreateResult Create(const char* name, unsigned int size, bool openIfCreated);
|
||||
bool Open(const char* name);
|
||||
void Close();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
#include <AzCore/Debug/StackTracer.h>
|
||||
#include <AzCore/Math/MathUtils.h>
|
||||
#include <AzCore/Math/Crc.h>
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/std/containers/fixed_vector.h>
|
||||
@@ -90,7 +91,7 @@ namespace AZ {
|
||||
{
|
||||
case CBA_EVENT:
|
||||
evt = (PIMAGEHLP_CBA_EVENT)CallbackData;
|
||||
_tprintf(_T("%s"), (PTSTR)evt->desc);
|
||||
printf("%s", evt->desc);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -300,7 +301,7 @@ namespace AZ {
|
||||
return;
|
||||
}
|
||||
|
||||
const HMODULE hNtDll = GetModuleHandle(_T("ntdll.dll"));
|
||||
const HMODULE hNtDll = GetModuleHandleW(L"ntdll.dll");
|
||||
m_LdrRegisterDllNotification = reinterpret_cast<PLDR_REGISTER_DLL_NOTIFICATION>(GetProcAddress(hNtDll, "LdrRegisterDllNotification"));
|
||||
|
||||
if (m_LdrRegisterDllNotification)
|
||||
@@ -324,7 +325,7 @@ namespace AZ {
|
||||
return;
|
||||
}
|
||||
|
||||
const HMODULE hNtDll = GetModuleHandle(_T("ntdll.dll"));
|
||||
const HMODULE hNtDll = GetModuleHandleW(L"ntdll.dll");
|
||||
m_LdrUnregisterDllNotification = reinterpret_cast<PLDR_UNREGISTER_DLL_NOTIFICATION>(GetProcAddress(hNtDll, "LdrUnregisterDllNotification"));
|
||||
|
||||
if (m_LdrUnregisterDllNotification)
|
||||
@@ -609,8 +610,8 @@ namespace AZ {
|
||||
if (GetFileVersionInfoA(szImg, dwHandle, dwSize, vData) != 0)
|
||||
{
|
||||
UINT len;
|
||||
TCHAR szSubBlock[] = _T("\\");
|
||||
if (VerQueryValue(vData, szSubBlock, (LPVOID*) &fInfo, &len) == 0)
|
||||
TCHAR szSubBlock[] = L"\\";
|
||||
if (VerQueryValueW(vData, szSubBlock, (LPVOID*) &fInfo, &len) == 0)
|
||||
{
|
||||
fInfo = NULL;
|
||||
}
|
||||
@@ -711,7 +712,7 @@ namespace AZ {
|
||||
typedef BOOL (__stdcall * tM32N)(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
|
||||
|
||||
// try both dlls...
|
||||
const TCHAR* dllname[] = { _T("kernel32.dll"), _T("tlhelp32.dll") };
|
||||
const TCHAR* dllname[] = { L"kernel32.dll", L"tlhelp32.dll" };
|
||||
HINSTANCE hToolhelp = NULL;
|
||||
tCT32S pCT32S = NULL;
|
||||
tM32F pM32F = NULL;
|
||||
@@ -822,7 +823,7 @@ namespace AZ {
|
||||
const SIZE_T TTBUFLEN = 8096;
|
||||
int cnt = 0;
|
||||
|
||||
hPsapi = LoadLibrary(_T("psapi.dll"));
|
||||
hPsapi = LoadLibraryW(L"psapi.dll");
|
||||
if (hPsapi == NULL)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -956,10 +957,10 @@ cleanup:
|
||||
// In that scenario, we may try to load and older dbghelp.dll which could cause issues
|
||||
// To overcome this, we try to load dbghelp.dll from the Win 10 SDK folder, if that doesn't
|
||||
// work, load the default.
|
||||
g_dbgHelpDll = LoadLibrary(_T(R"(C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll)"));
|
||||
g_dbgHelpDll = LoadLibraryW(LR"(C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll)");
|
||||
if (g_dbgHelpDll == NULL)
|
||||
{
|
||||
g_dbgHelpDll = LoadLibrary(_T("dbghelp.dll"));
|
||||
g_dbgHelpDll = LoadLibrary(L"dbghelp.dll");
|
||||
}
|
||||
}
|
||||
if (g_dbgHelpDll == NULL)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/std/typetraits/decay.h>
|
||||
#include <AzCore/std/typetraits/is_unsigned.h>
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
namespace AZ::IO
|
||||
{
|
||||
@@ -467,8 +468,10 @@ namespace AZ::IO
|
||||
DWORD createFlags = m_constructionOptions.m_enableUnbufferedReads ? (FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING) : FILE_FLAG_OVERLAPPED;
|
||||
DWORD shareMode = (m_constructionOptions.m_enableSharing || data.m_sharedRead) ? FILE_SHARE_READ: 0;
|
||||
|
||||
file = ::CreateFile(
|
||||
data.m_path.GetAbsolutePath(), // file name
|
||||
AZStd::wstring filenameW;
|
||||
AZStd::to_wstring(filenameW, data.m_path.GetAbsolutePath());
|
||||
file = ::CreateFileW(
|
||||
filenameW.c_str(), // file name
|
||||
FILE_GENERIC_READ, // desired access
|
||||
shareMode, // share mode
|
||||
nullptr, // security attributes
|
||||
@@ -806,7 +809,9 @@ namespace AZ::IO
|
||||
}
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA attributes;
|
||||
if (::GetFileAttributesEx(fileExists.m_path.GetAbsolutePath(), GetFileExInfoStandard, &attributes))
|
||||
AZStd::wstring filenameW;
|
||||
AZStd::to_wstring(filenameW, fileExists.m_path.GetAbsolutePath());
|
||||
if (::GetFileAttributesExW(filenameW.c_str(), GetFileExInfoStandard, &attributes))
|
||||
{
|
||||
if ((attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES) &&
|
||||
((attributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0))
|
||||
@@ -863,7 +868,9 @@ namespace AZ::IO
|
||||
else
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA attributes;
|
||||
if (::GetFileAttributesEx(command.m_path.GetAbsolutePath(), GetFileExInfoStandard, &attributes) &&
|
||||
AZStd::wstring filenameW;
|
||||
AZStd::to_wstring(filenameW, command.m_path.GetAbsolutePath());
|
||||
if (::GetFileAttributesExW(filenameW.c_str(), GetFileExInfoStandard, &attributes) &&
|
||||
(attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES) && ((attributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0))
|
||||
{
|
||||
fileSize.LowPart = attributes.nFileSizeLow;
|
||||
|
||||
+2
-2
@@ -290,7 +290,7 @@ namespace AZ::IO
|
||||
static bool CollectHardwareInfo(HardwareInformation& hardwareInfo, bool addAllDrives, bool reportHardware)
|
||||
{
|
||||
char drives[512];
|
||||
if (::GetLogicalDriveStrings(sizeof(drives) - 1, drives))
|
||||
if (::GetLogicalDriveStringsA(sizeof(drives) - 1, drives))
|
||||
{
|
||||
AZStd::unordered_map<DWORD, DriveInformation> driveMappings;
|
||||
char* driveIt = drives;
|
||||
@@ -318,7 +318,7 @@ namespace AZ::IO
|
||||
deviceName += driveIt;
|
||||
deviceName.erase(deviceName.length() - 1); // Erase the slash.
|
||||
|
||||
HANDLE deviceHandle = ::CreateFile(
|
||||
HANDLE deviceHandle = ::CreateFileA(
|
||||
deviceName.c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
if (deviceHandle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#include <AzCore/IPC/SharedMemory.h>
|
||||
#include <AzCore/std/parallel/spin_mutex.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -20,16 +22,18 @@ namespace AZ
|
||||
{
|
||||
}
|
||||
|
||||
void SharedMemory_Windows::ComposeMutexName(char* dest, size_t length, const char* name)
|
||||
void ComposeName(AZStd::fixed_wstring<256>& dest, const char* name, const wchar_t* suffix)
|
||||
{
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
azsnprintf(dest, length, "%s_Mutex", name);
|
||||
AZStd::to_wstring(dest, name);
|
||||
dest += L"_";
|
||||
dest += suffix;
|
||||
}
|
||||
|
||||
SharedMemory_Common::CreateResult SharedMemory_Windows::Create(const char* name, unsigned int size, bool openIfCreated)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
AZStd::fixed_wstring<256> fullName;
|
||||
ComposeName(fullName, name, L"Mutex");
|
||||
|
||||
// Security attributes
|
||||
SECURITY_ATTRIBUTES secAttr;
|
||||
@@ -41,7 +45,7 @@ namespace AZ
|
||||
SetSecurityDescriptorDacl(secAttr.lpSecurityDescriptor, TRUE, 0, FALSE);
|
||||
|
||||
// Obtain global mutex
|
||||
m_globalMutex = CreateMutex(&secAttr, FALSE, fullName);
|
||||
m_globalMutex = CreateMutexW(&secAttr, FALSE, fullName.c_str());
|
||||
DWORD error = GetLastError();
|
||||
if (m_globalMutex == NULL || (error == ERROR_ALREADY_EXISTS && openIfCreated == false))
|
||||
{
|
||||
@@ -50,8 +54,8 @@ namespace AZ
|
||||
}
|
||||
|
||||
// Create the file mapping.
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
m_mapHandle = CreateFileMapping(INVALID_HANDLE_VALUE, &secAttr, PAGE_READWRITE, 0, size, fullName);
|
||||
ComposeName(fullName, name, L"Data");
|
||||
m_mapHandle = CreateFileMappingW(INVALID_HANDLE_VALUE, &secAttr, PAGE_READWRITE, 0, size, fullName.c_str());
|
||||
error = GetLastError();
|
||||
if (m_mapHandle == NULL || (error == ERROR_ALREADY_EXISTS && openIfCreated == false))
|
||||
{
|
||||
@@ -64,10 +68,11 @@ namespace AZ
|
||||
|
||||
bool SharedMemory_Windows::Open(const char* name)
|
||||
{
|
||||
char fullName[256];
|
||||
ComposeMutexName(fullName, AZ_ARRAY_SIZE(fullName), name);
|
||||
azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name));
|
||||
AZStd::fixed_wstring<256> fullName;
|
||||
ComposeName(fullName, name, L"Mutex");
|
||||
|
||||
m_globalMutex = OpenMutex(SYNCHRONIZE, TRUE, fullName);
|
||||
m_globalMutex = OpenMutex(SYNCHRONIZE, TRUE, fullName.c_str());
|
||||
AZ_Warning("AZSystem", m_globalMutex != NULL, "Failed to open OS mutex [%s]\n", m_name);
|
||||
if (m_globalMutex == NULL)
|
||||
{
|
||||
@@ -75,8 +80,8 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
azsnprintf(fullName, AZ_ARRAY_SIZE(fullName), "%s_Data", name);
|
||||
m_mapHandle = OpenFileMapping(FILE_MAP_WRITE, false, fullName);
|
||||
ComposeName(fullName, name, L"Data");
|
||||
m_mapHandle = OpenFileMapping(FILE_MAP_WRITE, false, fullName.c_str());
|
||||
if (m_mapHandle == NULL)
|
||||
{
|
||||
AZ_TracePrintf("AZSystem", "OpenFileMapping %s failed with error %d\n", m_name, GetLastError());
|
||||
|
||||
@@ -41,9 +41,6 @@ namespace AZ
|
||||
HANDLE m_mapHandle;
|
||||
HANDLE m_globalMutex;
|
||||
int m_lastLockResult;
|
||||
|
||||
private:
|
||||
void ComposeMutexName(char* dest, size_t length, const char* name);
|
||||
};
|
||||
|
||||
using SharedMemory_Platform = SharedMemory_Windows;
|
||||
|
||||
+10
-3
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <AzCore/Math/MathUtils.h>
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -105,11 +106,17 @@ namespace
|
||||
{
|
||||
// Set the text for window title, message, buttons.
|
||||
info = (DlgInfo*)lParam;
|
||||
SetWindowText(hDlg, info->m_title.c_str());
|
||||
SetWindowText(GetDlgItem(hDlg, 0), info->m_message.c_str());
|
||||
AZStd::wstring titleW;
|
||||
AZStd::to_wstring(titleW, info->m_title.c_str());
|
||||
SetWindowTextW(hDlg, titleW.c_str());
|
||||
AZStd::wstring messageW;
|
||||
AZStd::to_wstring(messageW, info->m_message.c_str());
|
||||
SetWindowTextW(GetDlgItem(hDlg, 0), messageW.c_str());
|
||||
for (int i = 0; i < info->m_options.size(); i++)
|
||||
{
|
||||
SetWindowText(GetDlgItem(hDlg, i + 1), info->m_options[i].c_str());
|
||||
AZStd::wstring optionW;
|
||||
AZStd::to_wstring(optionW, info->m_options[i].c_str());
|
||||
SetWindowTextW(GetDlgItem(hDlg, i + 1), optionW.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define UNICODE
|
||||
//#define NOGDICAPMASKS //- CC_*, LC_*, PC_*, CP_*, TC_*, RC_
|
||||
//#define NOVIRTUALKEYCODES //- VK_*
|
||||
//#define NOWINMESSAGES //- WM_*, EM_*, LB_*, CB_*
|
||||
|
||||
@@ -31,13 +31,13 @@ namespace AZ
|
||||
// Query the machine guid generated at install time by windows, which is generated from
|
||||
// hardware signatures. This guid is not enough, because images (AWS) may duplicate this,
|
||||
// so include the hostname/username as well
|
||||
TCHAR machineInfo[MAX_COMPUTERNAME_LENGTH + 1024] = { 0 };
|
||||
ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", 0, KEY_QUERY_VALUE, &key);
|
||||
wchar_t machineInfo[MAX_COMPUTERNAME_LENGTH + 1024] = { 0 };
|
||||
ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_QUERY_VALUE, &key);
|
||||
if (ret == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD dataType = REG_SZ;
|
||||
DWORD dataSize = sizeof(machineInfo);
|
||||
ret = RegQueryValueEx(key, "MachineGuid", 0, &dataType, (LPBYTE)machineInfo, &dataSize);
|
||||
ret = RegQueryValueExW(key, L"MachineGuid", 0, &dataType, (LPBYTE)machineInfo, &dataSize);
|
||||
RegCloseKey(key);
|
||||
}
|
||||
else
|
||||
@@ -45,24 +45,24 @@ namespace AZ
|
||||
AZ_Error("System", false, "Failed to open HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography\\MachineGuid!")
|
||||
}
|
||||
|
||||
TCHAR* hostname = machineInfo + _tcslen(machineInfo);
|
||||
wchar_t* hostname = machineInfo + wcslen(machineInfo);
|
||||
// salt the guid time with ComputerName/UserName
|
||||
DWORD bufCharCount = DWORD(sizeof(machineInfo) - (hostname - machineInfo));
|
||||
if (!::GetComputerName(hostname, &bufCharCount))
|
||||
if (!::GetComputerNameW(hostname, &bufCharCount))
|
||||
{
|
||||
AZ_Error("System", false, "GetComputerName filed with code %d", GetLastError());
|
||||
}
|
||||
|
||||
TCHAR* username = hostname + _tcslen(hostname);
|
||||
wchar_t* username = hostname + wcslen(hostname);
|
||||
bufCharCount = DWORD(sizeof(machineInfo) - (username - machineInfo));
|
||||
if( !GetUserName( username, &bufCharCount ) )
|
||||
if(!GetUserNameW(username, &bufCharCount))
|
||||
{
|
||||
AZ_Error("System",false,"GetUserName filed with code %d",GetLastError());
|
||||
}
|
||||
|
||||
Sha1 hash;
|
||||
AZ::u32 digest[5] = { 0 };
|
||||
hash.ProcessBytes(machineInfo, _tcslen(machineInfo) * sizeof(TCHAR));
|
||||
hash.ProcessBytes(machineInfo, wcslen(machineInfo) * sizeof(TCHAR));
|
||||
hash.GetDigest(digest);
|
||||
s_machineId = digest[0];
|
||||
if (s_machineId == 0)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -15,7 +16,11 @@ namespace AZ::Utils
|
||||
{
|
||||
void NativeErrorMessageBox(const char* title, const char* message)
|
||||
{
|
||||
::MessageBox(0, message, title, MB_OK | MB_ICONERROR);
|
||||
AZStd::wstring wtitle;
|
||||
AZStd::to_wstring(wtitle, title);
|
||||
AZStd::wstring wmessage;
|
||||
AZStd::to_wstring(wmessage, message);
|
||||
::MessageBoxW(0, wmessage.c_str(), wtitle.c_str(), MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPathString GetHomeDirectory()
|
||||
|
||||
+13
-9
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/std/parallel/thread.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
#include <process.h>
|
||||
|
||||
@@ -37,17 +38,20 @@ namespace AZStd
|
||||
// SetThreadDescription was added in 1607 (aka RS1). Since we can't guarantee the user is running 1607 or later, we need to ask for the function from the kernel.
|
||||
using SetThreadDescriptionFunc = HRESULT(WINAPI*)(_In_ HANDLE hThread, _In_ PCWSTR lpThreadDescription);
|
||||
|
||||
auto setThreadDescription = reinterpret_cast<SetThreadDescriptionFunc>(::GetProcAddress(::GetModuleHandle("Kernel32.dll"), "SetThreadDescription"));
|
||||
if (setThreadDescription)
|
||||
HMODULE kernel32Handle = ::GetModuleHandleW(L"Kernel32.dll");
|
||||
if (kernel32Handle)
|
||||
{
|
||||
// Convert the thread name to Unicode
|
||||
wchar_t threadNameW[MAX_PATH];
|
||||
size_t numCharsConverted;
|
||||
errno_t wcharResult = mbstowcs_s(&numCharsConverted, threadNameW, threadName, AZ_ARRAY_SIZE(threadNameW) - 1);
|
||||
if (wcharResult == 0)
|
||||
SetThreadDescriptionFunc setThreadDescription = reinterpret_cast<SetThreadDescriptionFunc>(::GetProcAddress(kernel32Handle, "SetThreadDescription"));
|
||||
if (setThreadDescription)
|
||||
{
|
||||
setThreadDescription(hThread, threadNameW);
|
||||
return true;
|
||||
// Convert the thread name to Unicode
|
||||
AZStd::wstring threadNameW;
|
||||
AZStd::to_wstring(threadNameW, threadName);
|
||||
if (!threadNameW.empty())
|
||||
{
|
||||
setThreadDescription(hThread, threadNameW.c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2051,10 +2051,11 @@ namespace UnitTest
|
||||
|
||||
TEST_F(SmartPtr, IntrusivePtr_DynamicCast)
|
||||
{
|
||||
|
||||
AZStd::intrusive_ptr<RefCountedClass> basePointer = new RefCountedSubclass;
|
||||
|
||||
AZStd::intrusive_ptr<RefCountedSubclass> correctCast = dynamic_pointer_cast<RefCountedSubclass>(basePointer);
|
||||
AZStd::intrusive_ptr<RefCountedSubclassB> wrongCast = dynamic_pointer_cast<RefCountedSubclassB>(basePointer);
|
||||
AZStd::intrusive_ptr<RefCountedSubclass> correctCast = azdynamic_cast<RefCountedSubclass *>(basePointer);
|
||||
AZStd::intrusive_ptr<RefCountedSubclassB> wrongCast = azdynamic_cast<RefCountedSubclassB *>(basePointer);
|
||||
|
||||
EXPECT_TRUE(correctCast.get() == basePointer.get());
|
||||
EXPECT_TRUE(wrongCast.get() == nullptr);
|
||||
|
||||
@@ -628,10 +628,6 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
# pragma warning(push)
|
||||
# pragma warning( disable: 4428 ) // universal-character-name encountered in source
|
||||
#endif // AZ_COMPILER_MSVC
|
||||
TEST_F(String, Algorithms)
|
||||
{
|
||||
string str = string::format("%s %d", "BlaBla", 5);
|
||||
@@ -678,6 +674,7 @@ namespace UnitTest
|
||||
string str1;
|
||||
to_string(str1, wstr);
|
||||
AZ_TEST_ASSERT(str1 == "BlaBla 5");
|
||||
EXPECT_EQ(8, to_string_length(wstr));
|
||||
|
||||
str1 = string::format("%ls", wstr.c_str());
|
||||
AZ_TEST_ASSERT(str1 == "BlaBla 5");
|
||||
@@ -690,6 +687,32 @@ namespace UnitTest
|
||||
wstr1 = wstring::format(L"%hs", str.c_str());
|
||||
AZ_TEST_ASSERT(wstr1 == L"BLABLA 5");
|
||||
|
||||
// wstring to char buffer
|
||||
char strBuffer[9];
|
||||
to_string(strBuffer, 9, wstr1.c_str());
|
||||
AZ_TEST_ASSERT(0 == azstricmp(strBuffer, "BLABLA 5"));
|
||||
EXPECT_EQ(8, to_string_length(wstr1));
|
||||
|
||||
// wstring to char with unicode
|
||||
wstring ws1InfinityEscaped = L"Infinity: \u221E"; // escaped
|
||||
EXPECT_EQ(13, to_string_length(ws1InfinityEscaped));
|
||||
|
||||
// wchar_t buffer to char buffer
|
||||
wchar_t wstrBuffer[9] = L"BLABLA 5";
|
||||
memset(strBuffer, 0, AZ_ARRAY_SIZE(strBuffer));
|
||||
to_string(strBuffer, 9, wstrBuffer);
|
||||
AZ_TEST_ASSERT(0 == azstricmp(strBuffer, "BLABLA 5"));
|
||||
|
||||
// string to wchar_t buffer
|
||||
memset(wstrBuffer, 0, AZ_ARRAY_SIZE(wstrBuffer));
|
||||
to_wstring(wstrBuffer, 9, str1.c_str());
|
||||
AZ_TEST_ASSERT(0 == azwcsicmp(wstrBuffer, L"BlaBla 5"));
|
||||
|
||||
// char buffer to wchar_t buffer
|
||||
memset(wstrBuffer, L' ', AZ_ARRAY_SIZE(wstrBuffer)); // to check that the null terminator is properly placed
|
||||
to_wstring(wstrBuffer, 9, strBuffer);
|
||||
AZ_TEST_ASSERT(0 == azwcsicmp(wstrBuffer, L"BLABLA 5"));
|
||||
|
||||
// wchar UTF16/UTF32 to/from Utf8
|
||||
wstr1 = L"this is a \u20AC \u00A3 test"; // that's a euro and a pound sterling
|
||||
AZStd::to_string(str, wstr1);
|
||||
@@ -1114,11 +1137,6 @@ namespace UnitTest
|
||||
EXPECT_FALSE(other2.Valid());
|
||||
}
|
||||
|
||||
// StringAlgorithmTest-End
|
||||
#if defined(AZ_COMPILER_MSVC)
|
||||
# pragma warning(pop)
|
||||
#endif // AZ_COMPILER_MSVC
|
||||
|
||||
TEST_F(String, ConstString)
|
||||
{
|
||||
string_view cstr1;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace UnitTest
|
||||
int isFoundModule = 0;
|
||||
char expectedNameBuffer[AZ_ARRAY_SIZE(SymbolStorage::ModuleInfo::m_modName)];
|
||||
#if defined(AZCORETEST_DLL_NAME)
|
||||
azstrncpy(expectedNameBuffer, AZCORETEST_DLL_NAME, AZ_ARRAY_SIZE(expectedNameBuffer));
|
||||
azstrncpy(expectedNameBuffer, AZ_ARRAY_SIZE(expectedNameBuffer), AZCORETEST_DLL_NAME, AZ_ARRAY_SIZE(expectedNameBuffer));
|
||||
#else
|
||||
azstrncpy(expectedNameBuffer, "azcoretests.dll", AZ_ARRAY_SIZE(expectedNameBuffer));
|
||||
#endif
|
||||
@@ -65,7 +65,7 @@ namespace UnitTest
|
||||
for (u32 i = 0; i < SymbolStorage::GetNumLoadedModules(); ++i)
|
||||
{
|
||||
char nameBuffer[AZ_ARRAY_SIZE(SymbolStorage::ModuleInfo::m_modName)];
|
||||
azstrncpy(nameBuffer, SymbolStorage::GetModuleInfo(i)->m_fileName, AZ_ARRAY_SIZE(nameBuffer));
|
||||
azstrncpy(nameBuffer, AZ_ARRAY_SIZE(nameBuffer), SymbolStorage::GetModuleInfo(i)->m_fileName, AZ_ARRAY_SIZE(nameBuffer));
|
||||
AZStd::to_lower(nameBuffer, nameBuffer + AZ_ARRAY_SIZE(nameBuffer));
|
||||
|
||||
if (strstr(nameBuffer, expectedNameBuffer))
|
||||
|
||||
@@ -418,7 +418,7 @@ namespace UnitTest
|
||||
|
||||
// Check each operator/= and append overload for success
|
||||
{
|
||||
AZStd::fixed_string<AZ::IO::MaxPathLength> pathString{ "foo" };
|
||||
AZ::IO::FixedMaxPathString pathString{ "foo" };
|
||||
AZ::IO::FixedMaxPath testPath('/');
|
||||
testPath /= AZ::IO::PathView(pathString);
|
||||
testPath /= pathString;
|
||||
@@ -428,7 +428,7 @@ namespace UnitTest
|
||||
EXPECT_STREQ("foo/foo/foo/foo/f", testPath.c_str());
|
||||
}
|
||||
{
|
||||
AZStd::fixed_string<AZ::IO::MaxPathLength> pathString{ "foo" };
|
||||
AZ::IO::FixedMaxPathString pathString{ "foo" };
|
||||
AZ::IO::FixedMaxPath testPath('/');
|
||||
testPath.Append(AZ::IO::PathView(pathString));
|
||||
testPath.Append(pathString);
|
||||
|
||||
Reference in New Issue
Block a user