Merge branch 'development' into cmake/warn_virtual

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-09-09 11:50:40 -07:00
248 changed files with 9491 additions and 10706 deletions
@@ -213,7 +213,7 @@ namespace AZ
void AssetData::Acquire()
{
AZ_Assert(m_useCount >= 0, "AssetData has been deleted")
AZ_Assert(m_useCount >= 0, "AssetData has been deleted");
AcquireWeak();
++m_useCount;
@@ -990,7 +990,7 @@ namespace AZ
template<class T>
u8 Asset<T>::GetFlags() const
{
AZ_Warning("Asset", false, "Deprecated - replaced by GetAutoLoadBehavior")
AZ_Warning("Asset", false, "Deprecated - replaced by GetAutoLoadBehavior");
return static_cast<u8>(m_loadBehavior);
}
@@ -1012,7 +1012,7 @@ namespace AZ
template<class T>
bool Asset<T>::SetFlags(u8 flags)
{
AZ_Warning("Asset", false, "Deprecated - replaced by SetAutoLoadBehavior")
AZ_Warning("Asset", false, "Deprecated - replaced by SetAutoLoadBehavior");
if (!m_assetData)
{
AZ_Assert(flags < static_cast<u8>(AssetLoadBehavior::Count), "Flags value is out of range");
@@ -2132,7 +2132,7 @@ namespace AZ
}
else
{
AZ_Warning("AssetManager", false, "Couldn't find handler for asset %s (%s)", asset.GetId().ToString<AZStd::string>().c_str(), asset.GetHint().c_str())
AZ_Warning("AssetManager", false, "Couldn't find handler for asset %s (%s)", asset.GetId().ToString<AZStd::string>().c_str(), asset.GetHint().c_str());
}
// Notify any dependent jobs.
+12 -12
View File
@@ -8,8 +8,7 @@
#pragma once
#include <AzCore/PlatformDef.h>
#define AZ_VA_HAS_ARGS(...) ""#__VA_ARGS__[0] != 0
#include <AzCore/base.h>
namespace AZ
{
@@ -262,17 +261,18 @@ namespace AZ
#define AZ_VerifyWarning(window, expression, ...) AZ_Warning(window, 0 != (expression), __VA_ARGS__)
#else // !AZ_ENABLE_TRACING
#define AZ_Assert(expression, ...)
#define AZ_Error(window, expression, ...)
#define AZ_ErrorOnce(window, expression, ...)
#define AZ_Warning(window, expression, ...)
#define AZ_WarningOnce(window, expression, ...)
#define AZ_TracePrintf(window, ...)
#define AZ_TracePrintfOnce(window, ...)
#define AZ_Verify(expression, ...) (void)(expression)
#define AZ_VerifyError(window, expression, ...) (void)(expression)
#define AZ_VerifyWarning(window, expression, ...) (void)(expression)
#define AZ_Assert(...) AZ_UNUSED(__VA_ARGS__);
#define AZ_Error(...) AZ_UNUSED(__VA_ARGS__);
#define AZ_ErrorOnce(...) AZ_UNUSED(__VA_ARGS__);
#define AZ_Warning(...) AZ_UNUSED(__VA_ARGS__);
#define AZ_WarningOnce(...) AZ_UNUSED(__VA_ARGS__);
#define AZ_TracePrintf(...) AZ_UNUSED(__VA_ARGS__);
#define AZ_TracePrintfOnce(...) AZ_UNUSED(__VA_ARGS__);
#define AZ_Verify(...) AZ_UNUSED(__VA_ARGS__);
#define AZ_VerifyError(...) AZ_UNUSED(__VA_ARGS__);
#define AZ_VerifyWarning(...) AZ_UNUSED(__VA_ARGS__);
#endif // AZ_ENABLE_TRACING
@@ -693,7 +693,7 @@ namespace AZ
}
else
{
AZ_Assert(m_isPooledString == false && m_isPooledStringCrc32 == false, "This stream requires using of a string pool as the string is send only once and afterwards only the Crc32 is used!")
AZ_Assert(m_isPooledString == false && m_isPooledStringCrc32 == false, "This stream requires using of a string pool as the string is send only once and afterwards only the Crc32 is used!");
}
return srcData;
}
@@ -150,9 +150,7 @@ namespace AZ::IO::IStreamerTypes
private:
AZStd::atomic_int m_lockCounter{ 0 };
#ifdef AZ_ENABLE_TRACING
AZStd::atomic_int m_allocationCounter{ 0 };
#endif
AZ::IAllocatorAllocate& m_allocator;
};
@@ -222,7 +222,7 @@ namespace AZ
int AddRefCount(int value)
{
AZ_Assert(value == 1 || value == -1, "ModRefCount is only for incrementing or decrementing on copy or destruction of ExposedLambda")
AZ_Assert(value == 1 || value == -1, "ModRefCount is only for incrementing or decrementing on copy or destruction of ExposedLambda");
lua_rawgeti(m_lua, LUA_REGISTRYINDEX, m_refCountRegistryIndex);
// Lua: refCount-old
const int refCount = Internal::azlua_tointeger(m_lua, -1) + value;
@@ -240,11 +240,6 @@ namespace AZ
{
IO::SizeType length = stream.GetLength();
if (length > AZ::Utils::DefaultMaxFileSize)
{
return AZ::Failure(AZStd::string{ "Data is too large." });
}
AZStd::vector<char> memoryBuffer;
memoryBuffer.resize_no_construct(static_cast<AZStd::vector<char>::size_type>(static_cast<AZStd::vector<char>::size_type>(length) + 1));
@@ -259,12 +254,12 @@ namespace AZ
return ReadJsonString(AZStd::string_view{memoryBuffer.data(), memoryBuffer.size()});
}
AZ::Outcome<rapidjson::Document, AZStd::string> ReadJsonFile(AZStd::string_view filePath)
AZ::Outcome<rapidjson::Document, AZStd::string> ReadJsonFile(AZStd::string_view filePath, size_t maxFileSize)
{
// Read into memory first and then parse the json, rather than passing a file stream to rapidjson.
// This should avoid creating a large number of micro-reads from the file.
auto readResult = AZ::Utils::ReadFile<AZStd::string>(filePath);
auto readResult = AZ::Utils::ReadFile<AZStd::string>(filePath, maxFileSize);
if(!readResult.IsSuccess())
{
return AZ::Failure(readResult.GetError());
@@ -308,6 +303,55 @@ namespace AZ
return AZ::Success();
}
AZ::Outcome<void, AZStd::string> LoadObjectFromStringByType(void* objectToLoad, const Uuid& classId, AZStd::string_view stream,
const JsonDeserializerSettings* settings)
{
JsonDeserializerSettings loadSettings;
AZStd::string deserializeErrors;
auto prepare = PrepareDeserializerSettings(settings, loadSettings, deserializeErrors);
if (!prepare.IsSuccess())
{
return AZ::Failure(prepare.GetError());
}
auto parseResult = ReadJsonString(stream);
if (!parseResult.IsSuccess())
{
return AZ::Failure(parseResult.GetError());
}
const rapidjson::Document& jsonDocument = parseResult.GetValue();
auto validateResult = ValidateJsonClassHeader(jsonDocument);
if (!validateResult.IsSuccess())
{
return AZ::Failure(validateResult.GetError());
}
const char* className = jsonDocument.FindMember(ClassNameTag)->value.GetString();
// validate class name
auto classData = loadSettings.m_serializeContext->FindClassData(classId);
if (!classData)
{
return AZ::Failure(AZStd::string::format("Try to load class from Id %s", classId.ToString<AZStd::string>().c_str()));
}
if (azstricmp(classData->m_name, className) != 0)
{
return AZ::Failure(AZStd::string::format("Try to load class %s from class %s data", classData->m_name, className));
}
JsonSerializationResult::ResultCode result = JsonSerialization::Load(objectToLoad, classId, jsonDocument.FindMember(ClassDataTag)->value, loadSettings);
if (!WasLoadSuccess(result.GetOutcome()) || !deserializeErrors.empty())
{
return AZ::Failure(deserializeErrors);
}
return AZ::Success();
}
AZ::Outcome<void, AZStd::string> LoadObjectFromStreamByType(void* objectToLoad, const Uuid& classId, IO::GenericStream& stream,
const JsonDeserializerSettings* settings)
{
@@ -70,13 +70,18 @@ namespace AZ
//! Parse json text. Returns a failure with error message if the content is not valid JSON.
AZ::Outcome<rapidjson::Document, AZStd::string> ReadJsonString(AZStd::string_view jsonText);
//! Parse a json file. Returns a failure with error message if the content is not valid JSON.
AZ::Outcome<rapidjson::Document, AZStd::string> ReadJsonFile(AZStd::string_view filePath);
//! Parse a json file. Returns a failure with error message if the content is not valid JSON or if
//! the file size is larger than the max file size provided.
AZ::Outcome<rapidjson::Document, AZStd::string> ReadJsonFile(
AZStd::string_view filePath, size_t maxFileSize = AZStd::numeric_limits<size_t>::max());
//! Parse a json stream. Returns a failure with error message if the content is not valid JSON.
AZ::Outcome<rapidjson::Document, AZStd::string> ReadJsonStream(IO::GenericStream& stream);
//! Load object with known class type
AZ::Outcome<void, AZStd::string> LoadObjectFromStringByType(void* objectToLoad, const Uuid& objectType, AZStd::string_view source,
const JsonDeserializerSettings* settings = nullptr);
AZ::Outcome<void, AZStd::string> LoadObjectFromStreamByType(void* objectToLoad, const Uuid& objectType, IO::GenericStream& stream,
const JsonDeserializerSettings* settings = nullptr);
@@ -293,7 +293,7 @@ namespace AZ
}
AZ_Assert(!keyValues.Empty(), "Intermediate array for associative container can't be empty "
"because an empty array would be stored as an empty default object.")
"because an empty array would be stored as an empty default object.");
if (CanBeConvertedToObject(keyValues))
{
@@ -2300,7 +2300,7 @@ namespace AZ
{
if (classData->m_converter)
{
AZ_Assert(false, "A deprecated element with a data converter was passed to CloneObject, this is not supported.")
AZ_Assert(false, "A deprecated element with a data converter was passed to CloneObject, this is not supported.");
}
// push a dummy node in the stack
cloneData->m_parentStack.push_back();
@@ -110,12 +110,12 @@ namespace AZ::Internal
{
FixedValueString engineName;
settingsRegistry.Get(engineName, engineMonikerKey);
AZ_Warning("SettingsRegistryMergeUtils",engineInfo.m_moniker == engineName,
AZ_Warning("SettingsRegistryMergeUtils", engineInfo.m_moniker == engineName,
R"(The engine name key "%s" mapped to engine path "%s" within the global manifest of "%s")"
R"( does not match the "engine_name" field "%s" in the engine.json)" "\n"
"This engine should be re-registered.",
engineInfo.m_moniker.c_str(), engineInfo.m_path.c_str(), engineManifestPath.c_str(),
engineName.c_str())
engineName.c_str());
engineInfo.m_moniker = engineName;
}
}
@@ -3464,7 +3464,7 @@ namespace AZ
const SliceComponent::DataFlagsPerEntity* SliceComponent::GetCorrectBundleOfDataFlags(EntityId entityId) const
{
// It would be possible to search non-instantiated slices by crawling over lists, but we haven't needed the capability yet.
AZ_Assert(IsInstantiated(), "Data flag access is only permitted after slice is instantiated.")
AZ_Assert(IsInstantiated(), "Data flag access is only permitted after slice is instantiated.");
if (IsInstantiated())
{
+2 -5
View File
@@ -22,10 +22,6 @@ namespace AZ
{
namespace Utils
{
//! Protects from allocating too much memory. The choice of a 1MB threshold is arbitrary.
//! If you need to work with larger files, please use AZ::IO directly instead of these utility functions.
inline constexpr size_t DefaultMaxFileSize = 1024 * 1024;
//! Terminates the application without going through the shutdown procedure.
//! This is used when due to abnormal circumstances the application can no
//! longer continue. On most platforms and in most configurations this will
@@ -115,6 +111,7 @@ namespace AZ
//! Read a file into a string. Returns a failure with error message if the content could not be loaded or if
//! the file size is larger than the max file size provided.
template<typename Container = AZStd::string>
AZ::Outcome<Container, AZStd::string> ReadFile(AZStd::string_view filePath, size_t maxFileSize = DefaultMaxFileSize);
AZ::Outcome<Container, AZStd::string> ReadFile(
AZStd::string_view filePath, size_t maxFileSize = AZStd::numeric_limits<size_t>::max());
}
}
+26 -10
View File
@@ -143,6 +143,9 @@
* example. AZ_VA_NUM_ARGS(x,y,z) -> expands to 3
*/
#ifndef AZ_VA_NUM_ARGS
# define AZ_VA_HAS_ARGS(...) ""#__VA_ARGS__[0] != 0
// we add the zero to avoid the case when we require at least 1 param at the end...
# define AZ_VA_NUM_ARGS(...) AZ_VA_NUM_ARGS_IMPL_((__VA_ARGS__, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
# define AZ_VA_NUM_ARGS_IMPL_(tuple) AZ_VA_NUM_ARGS_IMPL tuple
@@ -170,15 +173,15 @@
// This is a pain they we use macros to call functions (with no params).
// we implement functions for up to 10 params
#define AZ_FUNCTION_CALL_1(_1) _1()
#define AZ_FUNCTION_CALL_2(_1, _2) _1(_2)
#define AZ_FUNCTION_CALL_3(_1, _2, _3) _1(_2, _3)
#define AZ_FUNCTION_CALL_4(_1, _2, _3, _4) _1(_2, _3, _4)
#define AZ_FUNCTION_CALL_5(_1, _2, _3, _4, _5) _1(_2, _3, _4, _5)
#define AZ_FUNCTION_CALL_6(_1, _2, _3, _4, _5, _6) _1(_2, _3, _4, _5, _6)
#define AZ_FUNCTION_CALL_7(_1, _2, _3, _4, _5, _6, _7) _1(_2, _3, _4, _5, _6, _7)
#define AZ_FUNCTION_CALL_8(_1, _2, _3, _4, _5, _6, _7, _8) _1(_2, _3, _4, _5, _6, _7, _8)
#define AZ_FUNCTION_CALL_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) _1(_2, _3, _4, _5, _6, _7, _8, _9)
#define AZ_FUNCTION_CALL_1(_1) _1()
#define AZ_FUNCTION_CALL_2(_1, _2) _1(_2)
#define AZ_FUNCTION_CALL_3(_1, _2, _3) _1(_2, _3)
#define AZ_FUNCTION_CALL_4(_1, _2, _3, _4) _1(_2, _3, _4)
#define AZ_FUNCTION_CALL_5(_1, _2, _3, _4, _5) _1(_2, _3, _4, _5)
#define AZ_FUNCTION_CALL_6(_1, _2, _3, _4, _5, _6) _1(_2, _3, _4, _5, _6)
#define AZ_FUNCTION_CALL_7(_1, _2, _3, _4, _5, _6, _7) _1(_2, _3, _4, _5, _6, _7)
#define AZ_FUNCTION_CALL_8(_1, _2, _3, _4, _5, _6, _7, _8) _1(_2, _3, _4, _5, _6, _7, _8)
#define AZ_FUNCTION_CALL_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) _1(_2, _3, _4, _5, _6, _7, _8, _9)
#define AZ_FUNCTION_CALL_10(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) _1(_2, _3, _4, _5, _6, _7, _8, _9, _10)
// We require at least 1 param FunctionName
@@ -293,7 +296,20 @@ namespace AZ
#define AZ_DEFAULT_COPY_MOVE(_Class) AZ_DEFAULT_COPY(_Class) AZ_DEFAULT_MOVE(_Class)
// Macro that can be used to avoid unreferenced variable warnings
#define AZ_UNUSED(x) (void)x
#define AZ_UNUSED_1(x) (void)(x);
#define AZ_UNUSED_2(x1, x2) AZ_UNUSED_1(x1) AZ_UNUSED_1(x2)
#define AZ_UNUSED_3(x1, x2, x3) AZ_UNUSED_1(x1) AZ_UNUSED_2(x2, x3)
#define AZ_UNUSED_4(x1, x2, x3, x4) AZ_UNUSED_2(x1, x2) AZ_UNUSED_2(x3, x4)
#define AZ_UNUSED_5(x1, x2, x3, x4, x5) AZ_UNUSED_2(x1, x2) AZ_UNUSED_3(x3, x4, x5)
#define AZ_UNUSED_6(x1, x2, x3, x4, x5, x6) AZ_UNUSED_3(x1, x2, x3) AZ_UNUSED_3(x4, x5, x6)
#define AZ_UNUSED_7(x1, x2, x3, x4, x5, x6, x7) AZ_UNUSED_3(x1, x2, x3) AZ_UNUSED_4(x4, x5, x6, x7)
#define AZ_UNUSED_8(x1, x2, x3, x4, x5, x6, x7, x8) AZ_UNUSED_4(x1, x2, x3, x4) AZ_UNUSED_4(x5, x6, x7, x8)
#define AZ_UNUSED_9(x1, x2, x3, x4, x5, x6, x7, x8, x9) AZ_UNUSED_4(x1, x2, x3, x4) AZ_UNUSED_5(x5, x6, x7, x8, x9)
#define AZ_UNUSED_10(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) AZ_UNUSED_5(x1, x2, x3, x4, x5) AZ_UNUSED_5(x6, x7, x8, x9, x10)
#define AZ_UNUSED_11(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) AZ_UNUSED_5(x1, x2, x3, x4, x5) AZ_UNUSED_6(x6, x7, x8, x9, x10, x11)
#define AZ_UNUSED_12(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12) AZ_UNUSED_6(x1, x2, x3, x4, x5, x6) AZ_UNUSED_6(x7, x8, x9, x10, x11, x12)
#define AZ_UNUSED(...) AZ_MACRO_SPECIALIZE(AZ_UNUSED_, AZ_VA_NUM_ARGS(__VA_ARGS__), (__VA_ARGS__))
#define AZ_DEFINE_ENUM_BITWISE_OPERATORS(EnumType) \
inline constexpr EnumType operator | (EnumType a, EnumType b) \