Merge branch 'development' into Prefab/DestroyGameEntitySupport

Signed-off-by: srikappa-amzn <srikappa@amazon.com>
This commit is contained in:
srikappa-amzn
2021-09-28 06:57:38 -07:00
1501 changed files with 34384 additions and 17743 deletions
@@ -266,7 +266,7 @@ namespace AZ
_ComponentClass::RTTI_Type().ToString<AZStd::string>().c_str(), descriptor->GetName(), _ComponentClass::RTTI_TypeName()); \
return nullptr; \
} \
else if (descriptor->GetName() != _ComponentClass::RTTI_TypeName()) \
if (descriptor->GetName() != _ComponentClass::RTTI_TypeName()) \
{ \
AZ_Error("Component", false, "The same component UUID (%s) / name (%s) was registered twice. This isn't allowed, " \
"it can cause lifetime management issues / crashes.\nThis situation can happen by declaring a component " \
@@ -1251,6 +1251,8 @@ namespace AZ
return AZ::SettingsRegistryInterface::VisitResponse::Continue;
}
using SettingsRegistryInterface::Visitor::Visit;
void Visit(AZStd::string_view path, AZStd::string_view valueName, AZ::SettingsRegistryInterface::Type, bool value) override
{
// By default the auto load option is true
@@ -196,14 +196,14 @@ namespace AZ
//////////////////////////////////////////////////////////////////////////
// ComponentApplicationRequests
void RegisterComponentDescriptor(const ComponentDescriptor* descriptor) override final;
void UnregisterComponentDescriptor(const ComponentDescriptor* descriptor) override final;
void RegisterEntityAddedEventHandler(EntityAddedEvent::Handler& handler) override final;
void RegisterEntityRemovedEventHandler(EntityRemovedEvent::Handler& handler) override final;
void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler& handler) override final;
void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler& handler) override final;
void SignalEntityActivated(Entity* entity) override final;
void SignalEntityDeactivated(Entity* entity) override final;
void RegisterComponentDescriptor(const ComponentDescriptor* descriptor) final;
void UnregisterComponentDescriptor(const ComponentDescriptor* descriptor) final;
void RegisterEntityAddedEventHandler(EntityAddedEvent::Handler& handler) final;
void RegisterEntityRemovedEventHandler(EntityRemovedEvent::Handler& handler) final;
void RegisterEntityActivatedEventHandler(EntityActivatedEvent::Handler& handler) final;
void RegisterEntityDeactivatedEventHandler(EntityDeactivatedEvent::Handler& handler) final;
void SignalEntityActivated(Entity* entity) final;
void SignalEntityDeactivated(Entity* entity) final;
bool AddEntity(Entity* entity) override;
bool RemoveEntity(Entity* entity) override;
bool DeleteEntity(const EntityId& id) override;
@@ -207,12 +207,6 @@ namespace AZ
ActivateComponent(**it);
}
// Cache the transform interface to the transform interface
// Generally this pattern is not recommended unless for component event buses
// As we have a guarantee (by design) that components can't change during active state)
// Even though technically they can connect disconnect from the bus.
m_transform = TransformBus::FindFirstHandler(m_id);
SetState(State::Active);
EBUS_EVENT_ID(m_id, EntityBus, OnEntityActivated, m_id);
@@ -1330,6 +1324,19 @@ namespace AZ
return *processSignature;
}
AZ::TransformInterface* Entity::GetTransform() const
{
// Lazy evaluation of the cached entity transform.
if(!m_transform)
{
// Generally this pattern is not recommended unless for component event buses
// As we have a guarantee (by design) that components can't change during active state)
// Even though technically they can connect disconnect from the bus.
m_transform = TransformBus::FindFirstHandler(m_id);
}
return m_transform;
}
//=========================================================================
// MakeId
// Ids must be unique across a project at authoring time. Runtime doesn't matter
@@ -362,10 +362,9 @@ namespace AZ
//! @return The Process Signature of the local machine.
static AZ::u32 GetProcessSignature();
/// @cond EXCLUDE_DOCS
//! @deprecated Use the TransformBus to communicate with the TransformInterface.
inline TransformInterface* GetTransform() const { return m_transform; }
/// @endcond
//! Gets the TransformInterface for the entity.
//! @return The TransformInterface for the entity.
TransformInterface* GetTransform() const;
//! Sorts an entity's components based on the dependencies between components.
//! If all dependencies are met, the required services can be activated
@@ -414,7 +413,7 @@ namespace AZ
//! A cached pointer to the transform interface.
//! We recommend using AZ::TransformBus and caching locally instead of accessing
//! the transform interface directly through this pointer.
TransformInterface* m_transform;
mutable TransformInterface* m_transform;
//! A user-friendly name for the entity. This makes error messages easier to read.
AZStd::string m_name;
@@ -86,6 +86,7 @@ namespace AZ
class AssetTreeNodeBase
{
public:
virtual ~AssetTreeNodeBase() = default;
virtual const AssetPrimaryInfo* GetAssetPrimaryInfo() const = 0;
virtual AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetPrimaryInfo* info) = 0;
};
@@ -94,6 +95,7 @@ namespace AZ
class AssetTreeBase
{
public:
virtual ~AssetTreeBase() = default;
virtual AssetTreeNodeBase& GetRoot() = 0;
};
@@ -101,6 +103,7 @@ namespace AZ
class AssetAllocationTableBase
{
public:
virtual ~AssetAllocationTableBase() = default;
virtual AssetTreeNodeBase* FindAllocation(void* ptr) const = 0;
};
}
@@ -31,6 +31,8 @@ namespace AZ
{
}
~AssetTreeNode() override = default;
const AssetPrimaryInfo* GetAssetPrimaryInfo() const override
{
return m_primaryinfo;
@@ -67,6 +69,8 @@ namespace AZ
class AssetTree : public AssetTreeBase
{
public:
~AssetTree() override = default;
AssetTreeNodeBase& GetRoot() override
{
return m_rootAssets;
@@ -99,6 +103,7 @@ namespace AZ
AllocationTable(mutex_type& mutex) : m_mutex(mutex)
{
}
~AllocationTable() override = default;
AssetTreeNodeBase* FindAllocation(void* ptr) const override
{
@@ -19,7 +19,7 @@ namespace AZ::Debug
class BudgetTracker
{
public:
AZ_RTTI(BudgetTracker, "{E14A746D-BFFE-4C02-90FB-4699B79864A5}");
AZ_TYPE_INFO(BudgetTracker, "{E14A746D-BFFE-4C02-90FB-4699B79864A5}");
static Budget* GetBudgetFromEnvironment(const char* budgetName, uint32_t crc);
~BudgetTracker();
@@ -59,6 +59,20 @@ namespace AZStd
namespace AZ::Debug
{
// interface for externally defined profiler systems
class Profiler
{
public:
AZ_RTTI(Profiler, "{3E5D6329-72D1-41BA-9158-68A349D1A4D5}");
Profiler() = default;
virtual ~Profiler() = default;
// support for the extra macro args (e.g. format strings) will come in a later PR
virtual void BeginRegion(const Budget* budget, const char* eventName) = 0;
virtual void EndRegion(const Budget* budget) = 0;
};
class ProfileScope
{
public:
@@ -6,6 +6,8 @@
*
*/
#include <AzCore/Interface/Interface.h>
namespace AZ::Debug
{
template<typename... T>
@@ -22,9 +24,11 @@ namespace AZ::Debug
PIXBeginEvent(PIX_COLOR_INDEX(budget->Crc() & 0xff), eventName, args...);
#endif
budget->BeginProfileRegion();
// TODO: injecting instrumentation for other profilers
// NOTE: external profiler registration won't occur inline in a header necessarily in this manner, but the exact mechanism
// will be introduced in a future PR
if (auto profiler = AZ::Interface<Profiler>::Get(); profiler)
{
profiler->BeginRegion(budget, eventName);
}
#endif
}
@@ -39,6 +43,10 @@ namespace AZ::Debug
#if defined(USE_PIX)
PIXEndEvent();
#endif
if (auto profiler = AZ::Interface<Profiler>::Get(); profiler)
{
profiler->EndRegion(budget);
}
#endif
}
@@ -28,21 +28,21 @@ namespace AZ
protected:
//////////////////////////////////////////////////////////////////////////
// Driller
virtual const char* GroupName() const { return "SystemDrillers"; }
virtual const char* GetName() const { return "TraceMessagesDriller"; }
virtual const char* GetDescription() const { return "Handles all system messages like Assert, Exception, Error, Warning, Printf, etc."; }
virtual void Start(const Param* params = NULL, int numParams = 0);
virtual void Stop();
const char* GroupName() const override { return "SystemDrillers"; }
const char* GetName() const override { return "TraceMessagesDriller"; }
const char* GetDescription() const override { return "Handles all system messages like Assert, Exception, Error, Warning, Printf, etc."; }
void Start(const Param* params = NULL, int numParams = 0) override;
void Stop() override;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// TraceMessagesDrillerBus
/// Triggered when a AZ_Assert failed. This is terminating event! (the code will break, crash).
virtual void OnAssert(const char* message);
virtual void OnException(const char* message);
virtual void OnError(const char* window, const char* message);
virtual void OnWarning(const char* window, const char* message);
virtual void OnPrintf(const char* window, const char* message);
void OnAssert(const char* message) override;
void OnException(const char* message) override;
void OnError(const char* window, const char* message) override;
void OnWarning(const char* window, const char* message) override;
void OnPrintf(const char* window, const char* message) override;
//////////////////////////////////////////////////////////////////////////
};
} // namespace Debug
@@ -443,7 +443,7 @@ namespace AZ
const unsigned char* GetData() const { return m_data.data(); }
unsigned int GetDataSize() const { return static_cast<unsigned int>(m_data.size()); }
inline void Reset() { m_data.clear(); }
virtual void WriteBinary(const void* data, unsigned int dataSize)
void WriteBinary(const void* data, unsigned int dataSize) override
{
m_data.insert(m_data.end(), reinterpret_cast<const unsigned char*>(data), reinterpret_cast<const unsigned char*>(data) + dataSize);
}
@@ -489,7 +489,7 @@ namespace AZ
}
unsigned int GetDataLeft() const { return static_cast<unsigned int>(m_dataEnd - m_data); }
virtual unsigned int ReadBinary(void* data, unsigned int maxDataSize)
unsigned int ReadBinary(void* data, unsigned int maxDataSize) override
{
AZ_Assert(m_data != nullptr, "You must call SetData function, before you can read data!");
AZ_Assert(data != nullptr && maxDataSize > 0, "We must have a valid pointer and max data size!");
@@ -523,7 +523,7 @@ namespace AZ
bool Open(const char* fileName, int mode, int platformFlags = 0);
void Close();
virtual void WriteBinary(const void* data, unsigned int dataSize);
void WriteBinary(const void* data, unsigned int dataSize) override;
};
/**
@@ -540,7 +540,7 @@ namespace AZ
DrillerInputFileStream();
~DrillerInputFileStream();
bool Open(const char* fileName, int mode, int platformFlags = 0);
virtual unsigned int ReadBinary(void* data, unsigned int maxDataSize);
unsigned int ReadBinary(void* data, unsigned int maxDataSize) override;
void Close();
};
+1
View File
@@ -1717,6 +1717,7 @@ AZ_POP_DISABLE_WARNING
{
EBusRouterNode<typename EBus::InterfaceType> m_routerNode;
public:
virtual ~EBusNestedVersionRouter() = default;
template<class Container>
void BusRouterConnect(Container& container, int order = 0);
@@ -98,21 +98,21 @@ namespace AZ
/// Return compressor type id.
static AZ::u32 TypeId();
virtual AZ::u32 GetTypeId() const { return TypeId(); }
AZ::u32 GetTypeId() const override { return TypeId(); }
/// Called when we open a stream to Read for the first time. Data contains the first. dataSize <= m_maxHeaderSize.
virtual bool ReadHeaderAndData(CompressorStream* stream, AZ::u8* data, unsigned int dataSize);
bool ReadHeaderAndData(CompressorStream* stream, AZ::u8* data, unsigned int dataSize) override;
/// Called when we are about to start writing to a compressed stream.
virtual bool WriteHeaderAndData(CompressorStream* stream);
bool WriteHeaderAndData(CompressorStream* stream) override;
/// Forwarded function from the Device when we from a compressed stream.
virtual SizeType Read(CompressorStream* stream, SizeType byteSize, SizeType offset, void* buffer);
SizeType Read(CompressorStream* stream, SizeType byteSize, SizeType offset, void* buffer) override;
/// Forwarded function from the Device when we write to a compressed stream.
virtual SizeType Write(CompressorStream* stream, SizeType byteSize, const void* data, SizeType offset = SizeType(-1));
SizeType Write(CompressorStream* stream, SizeType byteSize, const void* data, SizeType offset = SizeType(-1)) override;
/// Write a seek point.
virtual bool WriteSeekPoint(CompressorStream* stream);
bool WriteSeekPoint(CompressorStream* stream) override;
/// Set auto seek point even dataSize bytes.
virtual bool StartCompressor(CompressorStream* stream, int compressionLevel, SizeType autoSeekDataSize);
bool StartCompressor(CompressorStream* stream, int compressionLevel, SizeType autoSeekDataSize) override;
/// Called just before we close the stream. All compression data will be flushed and finalized. (You can't add data afterwards).
virtual bool Close(CompressorStream* stream);
bool Close(CompressorStream* stream) override;
protected:
@@ -0,0 +1,200 @@
/*
* 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
*
*/
#include <AzCore/IO/FileReader.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/Path/Path.h>
namespace AZ::IO
{
FileReader::FileReader() = default;
FileReader::FileReader(AZ::IO::FileIOBase* fileIoBase, const char* filePath)
{
Open(fileIoBase, filePath);
}
FileReader::~FileReader()
{
Close();
}
FileReader::FileReader(FileReader&& other)
{
AZStd::swap(m_file, other.m_file);
AZStd::swap(m_fileIoBase, other.m_fileIoBase);
}
FileReader& FileReader::operator=(FileReader&& other)
{
// Close the current file and take over other file
Close();
m_file = AZStd::move(other.m_file);
m_fileIoBase = AZStd::move(other.m_fileIoBase);
other.m_file = AZStd::monostate{};
other.m_fileIoBase = {};
return *this;
}
bool FileReader::Open(AZ::IO::FileIOBase* fileIoBase, const char* filePath)
{
// Close file if the FileReader has an instance open
Close();
if (fileIoBase != nullptr)
{
AZ::IO::HandleType fileHandle;
if (fileIoBase->Open(filePath, IO::OpenMode::ModeRead, fileHandle))
{
m_file = fileHandle;
m_fileIoBase = fileIoBase;
return true;
}
}
else
{
AZ::IO::SystemFile file;
if (file.Open(filePath, IO::SystemFile::OpenMode::SF_OPEN_READ_ONLY))
{
m_file = AZStd::move(file);
return true;
}
}
return false;
}
bool FileReader::IsOpen() const
{
if (auto fileHandle = AZStd::get_if<AZ::IO::HandleType>(&m_file); fileHandle != nullptr)
{
return *fileHandle != AZ::IO::InvalidHandle;
}
else if (auto systemFile = AZStd::get_if<AZ::IO::SystemFile>(&m_file); systemFile != nullptr)
{
return systemFile->IsOpen();
}
return false;
}
void FileReader::Close()
{
if (auto fileHandle = AZStd::get_if<AZ::IO::HandleType>(&m_file); fileHandle != nullptr)
{
if (AZ::IO::FileIOBase* fileIo = m_fileIoBase; fileIo != nullptr)
{
fileIo->Close(*fileHandle);
}
}
m_file = AZStd::monostate{};
m_fileIoBase = {};
}
auto FileReader::Length() const -> SizeType
{
if (auto fileHandle = AZStd::get_if<AZ::IO::HandleType>(&m_file); fileHandle != nullptr)
{
if (SizeType fileSize{}; m_fileIoBase->Size(*fileHandle, fileSize))
{
return fileSize;
}
}
else if (auto systemFile = AZStd::get_if<AZ::IO::SystemFile>(&m_file); systemFile != nullptr)
{
return systemFile->Length();
}
return 0;
}
auto FileReader::Read(SizeType byteSize, void* buffer) -> SizeType
{
if (auto fileHandle = AZStd::get_if<AZ::IO::HandleType>(&m_file); fileHandle != nullptr)
{
if (SizeType bytesRead{}; m_fileIoBase->Read(*fileHandle, buffer, byteSize, false, &bytesRead))
{
return bytesRead;
}
}
else if (auto systemFile = AZStd::get_if<AZ::IO::SystemFile>(&m_file); systemFile != nullptr)
{
return systemFile->Read(byteSize, buffer);
}
return 0;
}
auto FileReader::Tell() const -> SizeType
{
if (auto fileHandle = AZStd::get_if<AZ::IO::HandleType>(&m_file); fileHandle != nullptr)
{
if (SizeType fileOffset{}; m_fileIoBase->Tell(*fileHandle, fileOffset))
{
return fileOffset;
}
}
else if (auto systemFile = AZStd::get_if<AZ::IO::SystemFile>(&m_file); systemFile != nullptr)
{
return systemFile->Tell();
}
return 0;
}
bool FileReader::Seek(AZ::s64 offset, SeekType type)
{
if (auto fileHandle = AZStd::get_if<AZ::IO::HandleType>(&m_file); fileHandle != nullptr)
{
return m_fileIoBase->Seek(*fileHandle, offset, type);
}
else if (auto systemFile = AZStd::get_if<AZ::IO::SystemFile>(&m_file); systemFile != nullptr)
{
systemFile->Seek(offset, static_cast<AZ::IO::SystemFile::SeekMode>(type));
return true;
}
return false;
}
bool FileReader::Eof() const
{
if (auto fileHandle = AZStd::get_if<AZ::IO::HandleType>(&m_file); fileHandle != nullptr)
{
return m_fileIoBase->Eof(*fileHandle);
}
else if (auto systemFile = AZStd::get_if<AZ::IO::SystemFile>(&m_file); systemFile != nullptr)
{
return systemFile->Eof();
}
return false;
}
bool FileReader::GetFilePath(AZ::IO::FixedMaxPath& filePath) const
{
if (auto fileHandle = AZStd::get_if<AZ::IO::HandleType>(&m_file); fileHandle != nullptr)
{
AZ::IO::FixedMaxPathString& pathStringRef = filePath.Native();
if (m_fileIoBase->GetFilename(*fileHandle, pathStringRef.data(), pathStringRef.capacity()))
{
pathStringRef.resize_no_construct(AZStd::char_traits<char>::length(pathStringRef.data()));
return true;
}
}
else if (auto systemFile = AZStd::get_if<AZ::IO::SystemFile>(&m_file); systemFile != nullptr)
{
filePath = systemFile->Name();
return true;
}
return false;
}
}
@@ -0,0 +1,92 @@
/*
* 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/IO/Path/Path_fwd.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/std/containers/variant.h>
namespace AZ::IO
{
class FileIOBase;
enum class SeekType : AZ::u32;
//! Structure which encapsulates delegates File Read operations
//! to either the FileIOBase or SystemFile classes based if a FileIOBase* instance has been supplied
//! to the FileSystemReader class
//! the SettingsRegistry option to use FileIO
class FileReader
{
using HandleType = AZ::u32;
using FileHandleType = AZStd::variant<AZStd::monostate, AZ::IO::SystemFile, HandleType>;
public:
using SizeType = AZ::u64;
//! Creates FileReader instance in the default state with no file opend
FileReader();
~FileReader();
//! Creates a new FileReader instance and attempts to open the file at the supplied path
//! Uses the FileIOBase instance if supplied
//! @param fileIOBase pointer to fileIOBase instance
//! @param null-terminated filePath to open
FileReader(AZ::IO::FileIOBase* fileIoBase, const char* filePath);
//! Takes ownership of the supplied FileReader handle
FileReader(FileReader&& other);
//! Moves ownership of FileReader handle to this instance
FileReader& operator=(FileReader&& other);
//! Opens a File using the FileIOBase instance if non-nullptr
//! Otherwise fall back to use SystemFile
//! @param fileIOBase pointer to fileIOBase instance
//! @param null-terminated filePath to open
//! @return true if the File is opened successfully
bool Open(AZ::IO::FileIOBase* fileIoBase, const char* filePath);
//! Returns true if a file is currently open
//! @return true if the file is open
bool IsOpen() const;
//! Closes the File
void Close();
//! Retrieve the length of the OpenFile
SizeType Length() const;
//! Attempts to read up to byte size bytes into the supplied buffer
//! @param byteSize - Maximum number of bytes to read
//! @param buffer - Buffer to read bytes into
//! @returns the number of bytes read if the file is open, otherwise 0
SizeType Read(SizeType byteSize, void* buffer);
//! Returns the current file offset
//! @returns file offset if the file is open, otherwise 0
SizeType Tell() const;
//! Seeks within the open file to the offset supplied
//! @param offset File offset to seek to
//! @param type parameter to indicate the reference point to start the seek from
//! @returns true if the file is open and the seek succeeded
bool Seek(AZ::s64 offset, SeekType type);
//! Returns true if the file is open and in the EOF state
bool Eof() const;
//! Store the file path of the open file into the output file path parameter
//! The filePath reference is left unmodified, if the path was not stored
//! @return true if the filePath was stored
bool GetFilePath(AZ::IO::FixedMaxPath& filePath) const;
private:
FileHandleType m_file;
AZ::IO::FileIOBase* m_fileIoBase{};
};
}
@@ -160,12 +160,12 @@ void SystemFile::Seek(SeekSizeType offset, SeekMode mode)
Platform::Seek(m_handle, this, offset, mode);
}
SystemFile::SizeType SystemFile::Tell()
SystemFile::SizeType SystemFile::Tell() const
{
return Platform::Tell(m_handle, this);
}
bool SystemFile::Eof()
bool SystemFile::Eof() const
{
return Platform::Eof(m_handle, this);
}
+2 -2
View File
@@ -72,9 +72,9 @@ namespace AZ
/// Seek in current file.
void Seek(SeekSizeType offset, SeekMode mode);
/// Get the cursor position in the current file.
SizeType Tell();
SizeType Tell() const;
/// Is the cursor at the end of the file?
bool Eof();
bool Eof() const;
/// Get the time the file was last modified.
AZ::u64 ModificationTime();
/// Read data from a file synchronous. Return number of bytes actually read in the buffer.
@@ -31,7 +31,7 @@ namespace AZ
{
}
protected:
virtual void Process()
void Process() override
{
m_notifyFlag->store(true, AZStd::memory_order_release);
}
@@ -77,7 +77,7 @@ namespace AZ
: public Sample<Vector3>
{
public:
Vector3 GetInterpolatedValue(TimeType time) override final
Vector3 GetInterpolatedValue(TimeType time) final
{
Vector3 interpolatedValue = m_previousValue;
if (m_targetTimestamp != 0)
@@ -108,7 +108,7 @@ namespace AZ
: public Sample<Quaternion>
{
public:
Quaternion GetInterpolatedValue(TimeType time) override final
Quaternion GetInterpolatedValue(TimeType time) final
{
Quaternion interpolatedValue = m_previousValue;
if (m_targetTimestamp != 0)
@@ -144,7 +144,7 @@ namespace AZ
: public Sample<Vector3>
{
public:
Vector3 GetInterpolatedValue(TimeType /*time*/) override final
Vector3 GetInterpolatedValue(TimeType /*time*/) final
{
return GetTargetValue();
}
@@ -155,7 +155,7 @@ namespace AZ
: public Sample<Quaternion>
{
public:
Quaternion GetInterpolatedValue(TimeType /*time*/) override final
Quaternion GetInterpolatedValue(TimeType /*time*/) final
{
return GetTargetValue();
}
@@ -353,6 +353,7 @@ namespace AZ
Method("CreateFromMatrix3x3AndTranslation", &Transform::CreateFromMatrix3x3AndTranslation)->
Method("CreateUniformScale", &Transform::CreateUniformScale)->
Method("CreateTranslation", &Transform::CreateTranslation)->
Method("CreateLookAt", &Transform::CreateLookAt)->
Method("ConstructFromValuesNumeric", &Internal::ConstructTransformFromValues);
}
}
@@ -48,18 +48,18 @@ namespace AZ
HeapSchema(const Descriptor& desc);
virtual ~HeapSchema();
virtual pointer_type Allocate(size_type byteSize, size_type alignment, int flags, const char* name = 0, const char* fileName = 0, int lineNum = 0, unsigned int suppressStackRecord = 0);
virtual void DeAllocate(pointer_type ptr, size_type byteSize = 0, size_type alignment = 0);
virtual pointer_type ReAllocate(pointer_type ptr, size_type newSize, size_type newAlignment) { (void)ptr; (void)newSize; (void)newAlignment; return NULL; }
virtual size_type Resize(pointer_type ptr, size_type newSize) { (void)ptr; (void)newSize; return 0; }
virtual size_type AllocationSize(pointer_type ptr);
pointer_type Allocate(size_type byteSize, size_type alignment, int flags, const char* name = 0, const char* fileName = 0, int lineNum = 0, unsigned int suppressStackRecord = 0) override;
void DeAllocate(pointer_type ptr, size_type byteSize = 0, size_type alignment = 0) override;
pointer_type ReAllocate(pointer_type ptr, size_type newSize, size_type newAlignment) override { (void)ptr; (void)newSize; (void)newAlignment; return NULL; }
size_type Resize(pointer_type ptr, size_type newSize) override { (void)ptr; (void)newSize; return 0; }
size_type AllocationSize(pointer_type ptr) override;
virtual size_type NumAllocatedBytes() const { return m_used; }
virtual size_type Capacity() const { return m_capacity; }
virtual size_type GetMaxAllocationSize() const;
size_type GetMaxContiguousAllocationSize() const override;
virtual IAllocatorAllocate* GetSubAllocator() { return m_subAllocator; }
virtual void GarbageCollect() {}
size_type NumAllocatedBytes() const override { return m_used; }
size_type Capacity() const override { return m_capacity; }
size_type GetMaxAllocationSize() const override;
size_type GetMaxContiguousAllocationSize() const override;
IAllocatorAllocate* GetSubAllocator() override { return m_subAllocator; }
void GarbageCollect() override {}
private:
AZ_FORCE_INLINE size_type ChunckSize(pointer_type ptr);
@@ -56,22 +56,22 @@ namespace AZ
HphaSchema(const Descriptor& desc);
virtual ~HphaSchema();
virtual pointer_type Allocate(size_type byteSize, size_type alignment, int flags = 0, const char* name = 0, const char* fileName = 0, int lineNum = 0, unsigned int suppressStackRecord = 0);
virtual void DeAllocate(pointer_type ptr, size_type byteSize = 0, size_type alignment = 0);
virtual pointer_type ReAllocate(pointer_type ptr, size_type newSize, size_type newAlignment);
pointer_type Allocate(size_type byteSize, size_type alignment, int flags = 0, const char* name = 0, const char* fileName = 0, int lineNum = 0, unsigned int suppressStackRecord = 0) override;
void DeAllocate(pointer_type ptr, size_type byteSize = 0, size_type alignment = 0) override;
pointer_type ReAllocate(pointer_type ptr, size_type newSize, size_type newAlignment) override;
/// Resizes allocated memory block to the size possible and returns that size.
virtual size_type Resize(pointer_type ptr, size_type newSize);
virtual size_type AllocationSize(pointer_type ptr);
size_type Resize(pointer_type ptr, size_type newSize) override;
size_type AllocationSize(pointer_type ptr) override;
virtual size_type NumAllocatedBytes() const;
virtual size_type Capacity() const;
virtual size_type GetMaxAllocationSize() const;
size_type GetMaxContiguousAllocationSize() const override;
virtual size_type GetUnAllocatedMemory(bool isPrint = false) const;
virtual IAllocatorAllocate* GetSubAllocator() { return m_desc.m_subAllocator; }
size_type NumAllocatedBytes() const override;
size_type Capacity() const override;
size_type GetMaxAllocationSize() const override;
size_type GetMaxContiguousAllocationSize() const override;
size_type GetUnAllocatedMemory(bool isPrint = false) const override;
IAllocatorAllocate* GetSubAllocator() override { return m_desc.m_subAllocator; }
/// Return unused memory to the OS (if we don't use fixed block). Don't call this unless you really need free memory, it is slow.
virtual void GarbageCollect();
void GarbageCollect() override;
private:
// [LY-84974][sconel@][2018-08-10] SliceStrike integration up to CL 671758
@@ -41,18 +41,18 @@ namespace AZ
//---------------------------------------------------------------------
// IAllocatorAllocate
//---------------------------------------------------------------------
virtual pointer_type Allocate(size_type byteSize, size_type alignment, int flags, const char* name = 0, const char* fileName = 0, int lineNum = 0, unsigned int suppressStackRecord = 0) override;
virtual void DeAllocate(pointer_type ptr, size_type byteSize = 0, size_type alignment = 0) override;
virtual pointer_type ReAllocate(pointer_type ptr, size_type newSize, size_type newAlignment) override;
virtual size_type Resize(pointer_type ptr, size_type newSize) override;
virtual size_type AllocationSize(pointer_type ptr) override;
pointer_type Allocate(size_type byteSize, size_type alignment, int flags, const char* name = 0, const char* fileName = 0, int lineNum = 0, unsigned int suppressStackRecord = 0) override;
void DeAllocate(pointer_type ptr, size_type byteSize = 0, size_type alignment = 0) override;
pointer_type ReAllocate(pointer_type ptr, size_type newSize, size_type newAlignment) override;
size_type Resize(pointer_type ptr, size_type newSize) override;
size_type AllocationSize(pointer_type ptr) override;
virtual size_type NumAllocatedBytes() const override;
virtual size_type Capacity() const override;
virtual size_type GetMaxAllocationSize() const override;
virtual size_type GetMaxContiguousAllocationSize() const override;
virtual IAllocatorAllocate* GetSubAllocator() override;
virtual void GarbageCollect() override;
size_type NumAllocatedBytes() const override;
size_type Capacity() const override;
size_type GetMaxAllocationSize() const override;
size_type GetMaxContiguousAllocationSize() const override;
IAllocatorAllocate* GetSubAllocator() override;
void GarbageCollect() override;
private:
typedef void* (*MallocFn)(size_t);
+1 -1
View File
@@ -849,7 +849,7 @@ namespace AZ
return AZ::AllocatorInstance<Parent>::Get().GetUnAllocatedMemory(isPrint);
}
virtual IAllocatorAllocate* GetSubAllocator() override
IAllocatorAllocate* GetSubAllocator() override
{
return AZ::AllocatorInstance<Parent>::Get().GetSubAllocator();
}
@@ -38,24 +38,24 @@ namespace AZ
protected:
//////////////////////////////////////////////////////////////////////////
// Driller
virtual const char* GroupName() const { return "SystemDrillers"; }
virtual const char* GetName() const { return "MemoryDriller"; }
virtual const char* GetDescription() const { return "Reports all allocators and memory allocations."; }
virtual void Start(const Param* params = NULL, int numParams = 0);
virtual void Stop();
const char* GroupName() const override { return "SystemDrillers"; }
const char* GetName() const override { return "MemoryDriller"; }
const char* GetDescription() const override { return "Reports all allocators and memory allocations."; }
void Start(const Param* params = NULL, int numParams = 0) override;
void Stop() override;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// MemoryDrillerBus
virtual void RegisterAllocator(IAllocator* allocator);
virtual void UnregisterAllocator(IAllocator* allocator);
void RegisterAllocator(IAllocator* allocator) override;
void UnregisterAllocator(IAllocator* allocator) override;
virtual void RegisterAllocation(IAllocator* allocator, void* address, size_t byteSize, size_t alignment, const char* name, const char* fileName, int lineNum, unsigned int stackSuppressCount);
virtual void UnregisterAllocation(IAllocator* allocator, void* address, size_t byteSize, size_t alignment, AllocationInfo* info);
virtual void ReallocateAllocation(IAllocator* allocator, void* prevAddress, void* newAddress, size_t newByteSize, size_t newAlignment);
virtual void ResizeAllocation(IAllocator* allocator, void* address, size_t newSize);
void RegisterAllocation(IAllocator* allocator, void* address, size_t byteSize, size_t alignment, const char* name, const char* fileName, int lineNum, unsigned int stackSuppressCount) override;
void UnregisterAllocation(IAllocator* allocator, void* address, size_t byteSize, size_t alignment, AllocationInfo* info) override;
void ReallocateAllocation(IAllocator* allocator, void* prevAddress, void* newAddress, size_t newByteSize, size_t newAlignment) override;
void ResizeAllocation(IAllocator* allocator, void* address, size_t newSize) override;
virtual void DumpAllAllocations();
void DumpAllAllocations() override;
//////////////////////////////////////////////////////////////////////////
void RegisterAllocatorOutput(IAllocator* allocator);
@@ -77,18 +77,18 @@ namespace AZ
//---------------------------------------------------------------------
// IAllocatorAllocate
//---------------------------------------------------------------------
virtual pointer_type Allocate(size_type byteSize, size_type alignment, int flags, const char* name = 0, const char* fileName = 0, int lineNum = 0, unsigned int suppressStackRecord = 0) override;
virtual void DeAllocate(pointer_type ptr, size_type byteSize = 0, size_type alignment = 0) override;
virtual pointer_type ReAllocate(pointer_type ptr, size_type newSize, size_type newAlignment) override;
virtual size_type Resize(pointer_type ptr, size_type newSize) override;
virtual size_type AllocationSize(pointer_type ptr) override;
pointer_type Allocate(size_type byteSize, size_type alignment, int flags, const char* name = 0, const char* fileName = 0, int lineNum = 0, unsigned int suppressStackRecord = 0) override;
void DeAllocate(pointer_type ptr, size_type byteSize = 0, size_type alignment = 0) override;
pointer_type ReAllocate(pointer_type ptr, size_type newSize, size_type newAlignment) override;
size_type Resize(pointer_type ptr, size_type newSize) override;
size_type AllocationSize(pointer_type ptr) override;
virtual size_type NumAllocatedBytes() const override;
virtual size_type Capacity() const override;
virtual size_type GetMaxAllocationSize() const override;
size_type NumAllocatedBytes() const override;
size_type Capacity() const override;
size_type GetMaxAllocationSize() const override;
size_type GetMaxContiguousAllocationSize() const override;
virtual IAllocatorAllocate* GetSubAllocator() override;
virtual void GarbageCollect() override;
IAllocatorAllocate* GetSubAllocator() override;
void GarbageCollect() override;
private:
OverrunDetectionSchemaImpl* m_impl;
+1 -1
View File
@@ -62,7 +62,7 @@ namespace AZ
* DO NOT OVERRIDE. This method will return in the future, but at this point things reflected here are not unreflected for all ReflectContexts (Serialize, Editor, Network, Script, etc.)
* Place all calls to non-component reflect functions inside of a component reflect function to ensure that your types are unreflected.
*/
virtual void Reflect(AZ::ReflectContext*) final { }
void Reflect(AZ::ReflectContext*) {}
/**
* Override to require specific components on the system entity.
@@ -594,8 +594,8 @@ namespace AZ
void SetArgumentName(size_t index, const AZStd::string& name) override;
const AZStd::string* GetArgumentToolTip(size_t index) const override;
void SetArgumentToolTip(size_t index, const AZStd::string& name) override;
virtual void SetDefaultValue(size_t index, BehaviorDefaultValuePtr defaultValue) override;
virtual BehaviorDefaultValuePtr GetDefaultValue(size_t index) const override;
void SetDefaultValue(size_t index, BehaviorDefaultValuePtr defaultValue) override;
BehaviorDefaultValuePtr GetDefaultValue(size_t index) const override;
const BehaviorParameter* GetResult() const override;
void OverrideParameterTraits(size_t index, AZ::u32 addTraits, AZ::u32 removeTraits) override;
+19 -33
View File
@@ -5,8 +5,8 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef AZCORE_RTTI_H
#define AZCORE_RTTI_H
#pragma once
#include <AzCore/RTTI/TypeInfo.h>
#include <AzCore/Module/Environment.h>
@@ -44,21 +44,9 @@ namespace AZ
/// RTTI typeId
typedef void (* RTTI_EnumCallback)(const AZ::TypeId& /*typeId*/, void* /*userData*/);
// Disabling missing override warning because we intentionally want to allow for declaring RTTI base classes that don't impelment RTTI.
#if defined(AZ_COMPILER_CLANG)
# define AZ_PUSH_DISABLE_OVERRIDE_WARNING \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Winconsistent-missing-override\"")
# define AZ_POP_DISABLE_OVERRIDE_WARNING \
_Pragma("clang diagnostic pop")
#else
# define AZ_PUSH_DISABLE_OVERRIDE_WARNING
# define AZ_POP_DISABLE_OVERRIDE_WARNING
#endif
// We require AZ_TYPE_INFO to be declared
#define AZ_RTTI_COMMON() \
AZ_PUSH_DISABLE_OVERRIDE_WARNING \
AZ_PUSH_DISABLE_WARNING(26433, "-Winconsistent-missing-override") \
void RTTI_Enable(); \
virtual inline const AZ::TypeId& RTTI_GetType() const { return RTTI_Type(); } \
virtual inline const char* RTTI_GetTypeName() const { return RTTI_TypeName(); } \
@@ -66,7 +54,7 @@ namespace AZ
virtual void RTTI_EnumTypes(AZ::RTTI_EnumCallback cb, void* userData) { RTTI_EnumHierarchy(cb, userData); } \
static inline const AZ::TypeId& RTTI_Type() { return TYPEINFO_Uuid(); } \
static inline const char* RTTI_TypeName() { return TYPEINFO_Name(); } \
AZ_POP_DISABLE_OVERRIDE_WARNING
AZ_POP_DISABLE_WARNING
//#define AZ_RTTI_1(_1) static_assert(false,"You must provide a valid classUuid!")
@@ -74,8 +62,10 @@ namespace AZ
#define AZ_RTTI_1() AZ_RTTI_COMMON() \
static bool RTTI_IsContainType(const AZ::TypeId& id) { return id == RTTI_Type(); } \
static void RTTI_EnumHierarchy(AZ::RTTI_EnumCallback cb, void* userData) { cb(RTTI_Type(), userData); } \
AZ_PUSH_DISABLE_WARNING(26433, "-Winconsistent-missing-override") \
virtual inline const void* RTTI_AddressOf(const AZ::TypeId& id) const { return (id == RTTI_Type()) ? this : nullptr; } \
virtual inline void* RTTI_AddressOf(const AZ::TypeId& id) { return (id == RTTI_Type()) ? this : nullptr; }
virtual inline void* RTTI_AddressOf(const AZ::TypeId& id) { return (id == RTTI_Type()) ? this : nullptr; } \
AZ_POP_DISABLE_WARNING
/// AZ_RTTI(BaseClass)
#define AZ_RTTI_2(_1) AZ_RTTI_COMMON() \
@@ -85,14 +75,14 @@ namespace AZ
static void RTTI_EnumHierarchy(AZ::RTTI_EnumCallback cb, void* userData) { \
cb(RTTI_Type(), userData); \
AZ::Internal::RttiCaller<_1>::RTTI_EnumHierarchy(cb, userData); } \
AZ_PUSH_DISABLE_OVERRIDE_WARNING \
AZ_PUSH_DISABLE_WARNING(26433, "-Winconsistent-missing-override") \
virtual inline const void* RTTI_AddressOf(const AZ::TypeId& id) const { \
if (id == RTTI_Type()) { return this; } \
return AZ::Internal::RttiCaller<_1>::RTTI_AddressOf(this, id); } \
virtual inline void* RTTI_AddressOf(const AZ::TypeId& id) { \
if (id == RTTI_Type()) { return this; } \
return AZ::Internal::RttiCaller<_1>::RTTI_AddressOf(this, id); } \
AZ_POP_DISABLE_OVERRIDE_WARNING
AZ_POP_DISABLE_WARNING
/// AZ_RTTI(BaseClass1,BaseClass2)
#define AZ_RTTI_3(_1, _2) AZ_RTTI_COMMON() \
@@ -104,7 +94,7 @@ namespace AZ
cb(RTTI_Type(), userData); \
AZ::Internal::RttiCaller<_1>::RTTI_EnumHierarchy(cb, userData); \
AZ::Internal::RttiCaller<_2>::RTTI_EnumHierarchy(cb, userData); } \
AZ_PUSH_DISABLE_OVERRIDE_WARNING \
AZ_PUSH_DISABLE_WARNING(26433, "-Winconsistent-missing-override") \
virtual inline const void* RTTI_AddressOf(const AZ::TypeId& id) const { \
if (id == RTTI_Type()) { return this; } \
const void* r = AZ::Internal::RttiCaller<_1>::RTTI_AddressOf(this, id); if (r) { return r; } \
@@ -113,7 +103,7 @@ namespace AZ
if (id == RTTI_Type()) { return this; } \
void* r = AZ::Internal::RttiCaller<_1>::RTTI_AddressOf(this, id); if (r) { return r; } \
return AZ::Internal::RttiCaller<_2>::RTTI_AddressOf(this, id); } \
AZ_POP_DISABLE_OVERRIDE_WARNING
AZ_POP_DISABLE_WARNING
/// AZ_RTTI(BaseClass1,BaseClass2,BaseClass3)
#define AZ_RTTI_4(_1, _2, _3) AZ_RTTI_COMMON() \
@@ -127,7 +117,7 @@ namespace AZ
AZ::Internal::RttiCaller<_1>::RTTI_EnumHierarchy(cb, userData); \
AZ::Internal::RttiCaller<_2>::RTTI_EnumHierarchy(cb, userData); \
AZ::Internal::RttiCaller<_3>::RTTI_EnumHierarchy(cb, userData); } \
AZ_PUSH_DISABLE_OVERRIDE_WARNING \
AZ_PUSH_DISABLE_WARNING(26433, "-Winconsistent-missing-override") \
virtual inline const void* RTTI_AddressOf(const AZ::TypeId& id) const { \
if (id == RTTI_Type()) { return this; } \
const void* r = AZ::Internal::RttiCaller<_1>::RTTI_AddressOf(this, id); if (r) { return r; } \
@@ -138,7 +128,7 @@ namespace AZ
void* r = AZ::Internal::RttiCaller<_1>::RTTI_AddressOf(this, id); if (r) { return r; } \
r = AZ::Internal::RttiCaller<_2>::RTTI_AddressOf(this, id); if (r) { return r; } \
return AZ::Internal::RttiCaller<_3>::RTTI_AddressOf(this, id); } \
AZ_POP_DISABLE_OVERRIDE_WARNING
AZ_POP_DISABLE_WARNING
/// AZ_RTTI(BaseClass1,BaseClass2,BaseClass3,BaseClass4)
#define AZ_RTTI_5(_1, _2, _3, _4) AZ_RTTI_COMMON() \
@@ -154,7 +144,7 @@ namespace AZ
AZ::Internal::RttiCaller<_2>::RTTI_EnumHierarchy(cb, userData); \
AZ::Internal::RttiCaller<_3>::RTTI_EnumHierarchy(cb, userData); \
AZ::Internal::RttiCaller<_4>::RTTI_EnumHierarchy(cb, userData); } \
AZ_PUSH_DISABLE_OVERRIDE_WARNING \
AZ_PUSH_DISABLE_WARNING(26433, "-Winconsistent-missing-override") \
virtual inline const void* RTTI_AddressOf(const AZ::TypeId& id) const { \
if (id == RTTI_Type()) { return this; } \
const void* r = AZ::Internal::RttiCaller<_1>::RTTI_AddressOf(this, id); if (r) { return r; } \
@@ -167,7 +157,7 @@ namespace AZ
r = AZ::Internal::RttiCaller<_2>::RTTI_AddressOf(this, id); if (r) { return r; } \
r = AZ::Internal::RttiCaller<_3>::RTTI_AddressOf(this, id); if (r) { return r; } \
return AZ::Internal::RttiCaller<_4>::RTTI_AddressOf(this, id); } \
AZ_POP_DISABLE_OVERRIDE_WARNING
AZ_POP_DISABLE_WARNING
/// AZ_RTTI(BaseClass1,BaseClass2,BaseClass3,BaseClass4,BaseClass5)
#define AZ_RTTI_6(_1, _2, _3, _4, _5) AZ_RTTI_COMMON() \
@@ -185,7 +175,7 @@ namespace AZ
AZ::Internal::RttiCaller<_3>::RTTI_EnumHierarchy(cb, userData); \
AZ::Internal::RttiCaller<_4>::RTTI_EnumHierarchy(cb, userData); \
AZ::Internal::RttiCaller<_5>::RTTI_EnumHierarchy(cb, userData); } \
AZ_PUSH_DISABLE_OVERRIDE_WARNING \
AZ_PUSH_DISABLE_WARNING(26433, "-Winconsistent-missing-override") \
virtual inline const void* RTTI_AddressOf(const AZ::TypeId& id) const { \
if (id == RTTI_Type()) { return this; } \
const void* r = AZ::Internal::RttiCaller<_1>::RTTI_AddressOf(this, id); if (r) { return r; } \
@@ -200,7 +190,7 @@ namespace AZ
r = AZ::Internal::RttiCaller<_3>::RTTI_AddressOf(this, id); if (r) { return r; } \
r = AZ::Internal::RttiCaller<_4>::RTTI_AddressOf(this, id); if (r) { return r; } \
return AZ::Internal::RttiCaller<_5>::RTTI_AddressOf(this, id); } \
AZ_POP_DISABLE_OVERRIDE_WARNING
AZ_POP_DISABLE_WARNING
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// MACRO specialization to allow optional parameters for template version of AZ_RTTI
@@ -951,10 +941,7 @@ namespace AZ
{
return AZStd::shared_ptr<DestType>(ptr, castPtr);
}
else
{
return AZStd::shared_ptr<DestType>();
}
return AZStd::shared_ptr<DestType>();
}
// RttiCast specialization for intrusive_ptr.
@@ -1077,7 +1064,6 @@ namespace AZ
{
return AZ::Internal::RttiIsTypeOfIdHelper<U>::Check(id, data, typename HasAZRtti<AZStd::remove_pointer_t<U>>::kind_type());
}
} // namespace AZ
#endif // AZCORE_RTTI_H
#pragma once
@@ -19,8 +19,8 @@ namespace AZ
public:
AZ_COMPONENT(JsonSystemComponent, "{3C2C7234-9512-4E24-86F0-C40865D7EECE}", Component);
void Activate();
void Deactivate();
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* reflectContext);
};
@@ -46,7 +46,8 @@ namespace AZ
public:
AZ_RTTI(JsonUnorderedMapSerializer, "{EF4478D3-1820-4FDB-A7B7-C9711EB41602}", JsonMapSerializer);
AZ_CLASS_ALLOCATOR_DECL;
using JsonMapSerializer::Store;
JsonSerializationResult::Result Store(rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue,
const Uuid& valueTypeId, JsonSerializerContext& context) override;
};
@@ -63,6 +64,7 @@ namespace AZ
const SerializeContext::ClassElement* keyElement, const SerializeContext::ClassElement* valueElement,
const rapidjson::Value& key, const rapidjson::Value& value, JsonDeserializerContext& context) override;
using JsonMapSerializer::Store;
JsonSerializationResult::Result Store(rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue,
const Uuid& valueTypeId, JsonSerializerContext& context) override;
};
@@ -370,6 +370,11 @@ namespace AZ
//! @param applyPatchSettings The ApplyPatchSettings which are using during JSON Merging
virtual void SetApplyPatchSettings(const AZ::JsonApplyPatchSettings& applyPatchSettings) = 0;
virtual void GetApplyPatchSettings(AZ::JsonApplyPatchSettings& applyPatchSettings) = 0;
//! Stores option to indicate whether the FileIOBase instance should be used for file operations
//! @param useFileIo If true the FileIOBase instance will attempted to be used for FileIOBase
//! operations before falling back to use SystemFile
virtual void SetUseFileIO(bool useFileIo) = 0;
};
inline SettingsRegistryInterface::Visitor::~Visitor() = default;
@@ -9,11 +9,15 @@
#include <cctype>
#include <cerrno>
#include <AzCore/Casting/numeric_cast.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/FileReader.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/JSON/error/en.h>
#include <AzCore/NativeUI//NativeUIRequests.h>
#include <AzCore/Serialization/Json/JsonSerialization.h>
#include <AzCore/Serialization/Json/StackedString.h>
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzCore/std/containers/variant.h>
#include <AzCore/std/sort.h>
#include <AzCore/std/parallel/scoped_lock.h>
@@ -131,6 +135,12 @@ namespace AZ
pointer.Create(m_settings, m_settings.GetAllocator()).SetArray();
}
SettingsRegistryImpl::SettingsRegistryImpl(bool useFileIo)
: SettingsRegistryImpl()
{
m_useFileIo = useFileIo;
}
void SettingsRegistryImpl::SetContext(SerializeContext* context)
{
AZStd::scoped_lock lock(m_settingMutex);
@@ -723,15 +733,10 @@ namespace AZ
RegistryFileList fileList;
scratchBuffer->clear();
AZ::IO::FixedMaxPathString folderPath{ path };
constexpr AZStd::string_view pathSeparators{ AZ_CORRECT_AND_WRONG_DATABASE_SEPARATOR };
if (pathSeparators.find_first_of(folderPath.back()) == AZStd::string_view::npos)
{
folderPath.push_back(AZ_CORRECT_DATABASE_SEPARATOR);
}
AZ::IO::FixedMaxPath folderPath{ path };
const size_t platformKeyOffset = folderPath.size();
folderPath.push_back('*');
const size_t platformKeyOffset = folderPath.Native().size();
folderPath /= '*';
Value specialzationArray(kArrayType);
size_t specializationCount = specializations.GetCount();
@@ -741,47 +746,13 @@ namespace AZ
specialzationArray.PushBack(Value(name.data(), aznumeric_caster(name.length()), m_settings.GetAllocator()), m_settings.GetAllocator());
}
pointer.Create(m_settings, m_settings.GetAllocator()).SetObject()
.AddMember(StringRef("Folder"), Value(folderPath.c_str(), aznumeric_caster(folderPath.size()), m_settings.GetAllocator()), m_settings.GetAllocator())
.AddMember(StringRef("Folder"), Value(folderPath.c_str(), aznumeric_caster(folderPath.Native().size()), m_settings.GetAllocator()), m_settings.GetAllocator())
.AddMember(StringRef("Specializations"), AZStd::move(specialzationArray), m_settings.GetAllocator());
auto callback = [this, &fileList, &specializations, &pointer, &folderPath](const char* filename, bool isFile) -> bool
auto CreateSettingsFindCallback = [this, &fileList, &specializations, &pointer, &folderPath](bool isPlatformFile)
{
if (isFile)
{
if (fileList.size() >= MaxRegistryFolderEntries)
{
AZ_Error("Settings Registry", false, "Too many files in registry folder.");
AZStd::scoped_lock lock(m_settingMutex);
pointer.Create(m_settings, m_settings.GetAllocator()).SetObject()
.AddMember(StringRef("Error"), StringRef("Too many files in registry folder."), m_settings.GetAllocator())
.AddMember(StringRef("Path"), Value(folderPath.c_str(), aznumeric_caster(folderPath.size()), m_settings.GetAllocator()), m_settings.GetAllocator())
.AddMember(StringRef("File"), Value(filename, m_settings.GetAllocator()), m_settings.GetAllocator());
return false;
}
fileList.push_back();
RegistryFile& registryFile = fileList.back();
if (!ExtractFileDescription(registryFile, filename, specializations))
{
fileList.pop_back();
}
}
return true;
};
SystemFile::FindFiles(folderPath.c_str(), callback);
if (!platform.empty())
{
// Move the folderPath prefix back to the supplied path before the wildcard
folderPath.erase(platformKeyOffset);
folderPath += PlatformFolder;
folderPath.push_back(AZ_CORRECT_DATABASE_SEPARATOR);
folderPath += platform;
folderPath.push_back(AZ_CORRECT_DATABASE_SEPARATOR);
folderPath.push_back('*');
auto platformCallback = [this, &fileList, &specializations, &pointer, &folderPath](const char* filename, bool isFile) -> bool
return [this, &fileList, &specializations, &pointer, &folderPath, isPlatformFile](AZStd::string_view filename, bool isFile) -> bool
{
if (isFile)
{
@@ -791,8 +762,8 @@ namespace AZ
AZStd::scoped_lock lock(m_settingMutex);
pointer.Create(m_settings, m_settings.GetAllocator()).SetObject()
.AddMember(StringRef("Error"), StringRef("Too many files in registry folder."), m_settings.GetAllocator())
.AddMember(StringRef("Path"), Value(folderPath.c_str(), aznumeric_caster(folderPath.size()), m_settings.GetAllocator()), m_settings.GetAllocator())
.AddMember(StringRef("File"), Value(filename, m_settings.GetAllocator()), m_settings.GetAllocator());
.AddMember(StringRef("Path"), Value(folderPath.c_str(), aznumeric_caster(folderPath.Native().size()), m_settings.GetAllocator()), m_settings.GetAllocator())
.AddMember(StringRef("File"), Value(filename.data(), aznumeric_caster(filename.size()), m_settings.GetAllocator()), m_settings.GetAllocator());
return false;
}
@@ -800,7 +771,7 @@ namespace AZ
RegistryFile& registryFile = fileList.back();
if (ExtractFileDescription(registryFile, filename, specializations))
{
registryFile.m_isPlatformFile = true;
registryFile.m_isPlatformFile = isPlatformFile;
}
else
{
@@ -809,7 +780,42 @@ namespace AZ
}
return true;
};
SystemFile::FindFiles(folderPath.c_str(), platformCallback);
};
struct FindFilesPayload
{
bool m_isPlatformFile{};
AZStd::fixed_vector<AZStd::string_view, 2> m_pathSegmentsToAppend;
};
AZStd::fixed_vector<FindFilesPayload, 2> findFilesPayloads{ {false} };
if (!platform.empty())
{
findFilesPayloads.push_back(FindFilesPayload{ true, { PlatformFolder, platform } });
}
for (const FindFilesPayload& findFilesPayload : findFilesPayloads)
{
// Erase back to initial path
folderPath.Native().erase(platformKeyOffset);
for (AZStd::string_view pathSegmentToAppend : findFilesPayload.m_pathSegmentsToAppend)
{
folderPath /= pathSegmentToAppend;
}
auto findFilesCallback = CreateSettingsFindCallback(findFilesPayload.m_isPlatformFile);
if (AZ::IO::FileIOBase* fileIo = m_useFileIo ? AZ::IO::FileIOBase::GetInstance() : nullptr; fileIo != nullptr)
{
auto FileIoToSystemFileFindFiles = [findFilesCallback = AZStd::move(findFilesCallback), fileIo](const char* filePath) -> bool
{
return findFilesCallback(AZ::IO::PathView(filePath).Filename().Native(), !fileIo->IsDirectory(filePath));
};
fileIo->FindFiles(folderPath.c_str(), "*", FileIoToSystemFileFindFiles);
}
else
{
SystemFile::FindFiles((folderPath / "*").c_str(), findFilesCallback);
}
}
if (!fileList.empty())
@@ -831,16 +837,14 @@ namespace AZ
// Load the registry files in the sorted order.
for (RegistryFile& registryFile : fileList)
{
folderPath.erase(platformKeyOffset); // Erase all characters after the platformKeyOffset
folderPath.Native().erase(platformKeyOffset); // Erase all characters after the platformKeyOffset
if (registryFile.m_isPlatformFile)
{
folderPath += PlatformFolder;
folderPath.push_back(AZ_CORRECT_DATABASE_SEPARATOR);
folderPath += platform;
folderPath.push_back(AZ_CORRECT_DATABASE_SEPARATOR);
folderPath /= PlatformFolder;
folderPath /= platform;
}
folderPath += registryFile.m_relativePath;
folderPath /= registryFile.m_relativePath;
if (!registryFile.m_isPatch)
{
@@ -1027,39 +1031,44 @@ namespace AZ
return false;
}
bool SettingsRegistryImpl::ExtractFileDescription(RegistryFile& output, const char* filename, const Specializations& specializations)
bool SettingsRegistryImpl::ExtractFileDescription(RegistryFile& output, AZStd::string_view filename, const Specializations& specializations)
{
if (!filename || filename[0] == 0)
static constexpr auto PatchExtensionWithDot = AZStd::fixed_string<32>(".") + PatchExtension;
static constexpr auto ExtensionWithDot = AZStd::fixed_string<32>(".") + Extension;
static constexpr AZ::IO::PathView PatchExtensionView(PatchExtensionWithDot);
static constexpr AZ::IO::PathView ExtensionView(ExtensionWithDot);
if (filename.empty())
{
AZ_Error("Settings Registry", false, "Settings file without name found");
return false;
}
AZStd::string_view filePath{ filename };
const size_t filePathSize = filePath.size();
AZ::IO::PathView filePath{ filename };
const size_t filePathSize = filePath.Native().size();
// The filePath.empty() check makes sure that the file extension after the final <dot> isn't added to the output.m_tags
AZStd::optional<AZStd::string_view> pathTag = AZ::StringFunc::TokenizeNext(filePath, '.');
for (; pathTag && !filePath.empty(); pathTag = AZ::StringFunc::TokenizeNext(filePath, '.'))
auto AppendSpecTags = [&output](AZStd::string_view pathTag)
{
output.m_tags.push_back(Specializations::Hash(*pathTag));
}
output.m_tags.push_back(Specializations::Hash(pathTag));
};
AZ::StringFunc::TokenizeVisitor(filePath.Stem().Native(), AppendSpecTags, '.');
// If token is invalid, then the filename has no <dot> characters and therefore no extension
if (pathTag)
if (AZ::IO::PathView fileExtension = filePath.Extension(); !fileExtension.empty())
{
if (pathTag->size() >= AZStd::char_traits<char>::length(PatchExtension) && azstrnicmp(pathTag->data(), PatchExtension, pathTag->size()) == 0)
if (fileExtension == PatchExtensionView)
{
output.m_isPatch = true;
}
else if (pathTag->size() != AZStd::char_traits<char>::length(Extension) || azstrnicmp(pathTag->data(), Extension, pathTag->size()) != 0)
else if (fileExtension != ExtensionView)
{
return false;
}
}
else
{
AZ_Error("Settings Registry", false, R"(Settings file without extension found: "%s")", filename);
AZ_Error("Settings Registry", false, R"(Settings file without extension found: "%.*s")", AZ_STRING_ARG(filename));
return false;
}
@@ -1074,7 +1083,7 @@ namespace AZ
{
if (*currentIt == *(currentIt - 1))
{
AZ_Error("Settings Registry", false, R"(One or more tags are duplicated in registry file "%s")", filename);
AZ_Error("Settings Registry", false, R"(One or more tags are duplicated in registry file "%.*s")", AZ_STRING_ARG(filename));
return false;
}
++currentIt;
@@ -1103,7 +1112,7 @@ namespace AZ
}
else
{
AZ_Error("Settings Registry", false, R"(Found relative path to settings file "%s" is too long.)", filename);
AZ_Error("Settings Registry", false, R"(Found relative path to settings file "%.*s" is too long.)", AZ_STRING_ARG(filename));
return false;
}
}
@@ -1116,8 +1125,8 @@ namespace AZ
Pointer pointer(AZ_SETTINGS_REGISTRY_HISTORY_KEY "/-");
SystemFile file;
if (!file.Open(path, SystemFile::OpenMode::SF_OPEN_READ_ONLY))
FileReader fileReader(m_useFileIo ? AZ::IO::FileIOBase::GetInstance(): nullptr, path);
if (!fileReader.IsOpen())
{
AZ_Error("Settings Registry", false, R"(Unable to open registry file "%s".)", path);
pointer.Create(m_settings, m_settings.GetAllocator()).SetObject()
@@ -1126,7 +1135,7 @@ namespace AZ
return false;
}
u64 fileSize = file.Length();
u64 fileSize = fileReader.Length();
if (fileSize == 0)
{
AZ_Warning("Settings Registry", false, R"(Registry file "%s" is 0 bytes in length. There is no nothing to merge)", path);
@@ -1136,9 +1145,10 @@ namespace AZ
.AddMember(StringRef("Path"), Value(path, m_settings.GetAllocator()), m_settings.GetAllocator());
return false;
}
scratchBuffer.clear();
scratchBuffer.resize_no_construct(fileSize + 1);
if (file.Read(fileSize, scratchBuffer.data()) != fileSize)
if (fileReader.Read(fileSize, scratchBuffer.data()) != fileSize)
{
AZ_Error("Settings Registry", false, R"(Unable to read registry file "%s".)", path);
pointer.Create(m_settings, m_settings.GetAllocator()).SetObject()
@@ -1268,4 +1278,9 @@ namespace AZ
{
applyPatchSettings = m_applyPatchSettings;
}
void SettingsRegistryImpl::SetUseFileIO(bool useFileIo)
{
m_useFileIo = useFileIo;
}
} // namespace AZ
@@ -35,6 +35,10 @@ namespace AZ
static constexpr size_t MaxRegistryFolderEntries = 128;
SettingsRegistryImpl();
//! @param useFileIo - If true attempt to redirect
//! file read operations through the FileIOBase instance first before falling back to SystemFile
//! otherwise always use SystemFile
explicit SettingsRegistryImpl(bool useFileIo);
AZ_DISABLE_COPY_MOVE(SettingsRegistryImpl);
~SettingsRegistryImpl() override = default;
@@ -83,6 +87,8 @@ namespace AZ
void SetApplyPatchSettings(const AZ::JsonApplyPatchSettings& applyPatchSettings) override;
void GetApplyPatchSettings(AZ::JsonApplyPatchSettings& applyPatchSettings) override;
void SetUseFileIO(bool useFileIo) override;
private:
using TagList = AZStd::fixed_vector<size_t, Specializations::MaxCount + 1>;
struct RegistryFile
@@ -104,7 +110,7 @@ namespace AZ
// Compares if lhs is less than rhs in terms of processing order. This can also detect and report conflicts.
bool IsLessThan(bool& collisionFound, const RegistryFile& lhs, const RegistryFile& rhs, const Specializations& specializations,
const rapidjson::Pointer& historyPointer, AZStd::string_view folderPath);
bool ExtractFileDescription(RegistryFile& output, const char* filename, const Specializations& specializations);
bool ExtractFileDescription(RegistryFile& output, AZStd::string_view filename, const Specializations& specializations);
bool MergeSettingsFileInternal(const char* path, Format format, AZStd::string_view rootKey, AZStd::vector<char>& scratchBuffer);
void SignalNotifier(AZStd::string_view jsonPath, Type type);
@@ -119,5 +125,7 @@ namespace AZ
JsonSerializerSettings m_serializationSettings;
JsonDeserializerSettings m_deserializationSettings;
JsonApplyPatchSettings m_applyPatchSettings;
bool m_useFileIo{};
};
} // namespace AZ
@@ -6,6 +6,8 @@
*
*/
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/FileReader.h>
#include <AzCore/IO/GenericStreams.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/IO/TextStreamWriters.h>
@@ -78,6 +80,7 @@ namespace AZ::Internal
struct EnginePathsVisitor : public AZ::SettingsRegistryInterface::Visitor
{
using AZ::SettingsRegistryInterface::Visitor::Visit;
void Visit(
[[maybe_unused]] AZStd::string_view path, AZStd::string_view valueName,
[[maybe_unused]] AZ::SettingsRegistryInterface::Type type, AZStd::string_view value) override
@@ -355,6 +358,7 @@ namespace AZ::SettingsRegistryMergeUtils
: m_settingsSpecialization{ specializations }
{}
using AZ::SettingsRegistryInterface::Visitor::Visit;
void Visit([[maybe_unused]] AZStd::string_view path, AZStd::string_view valueName,
[[maybe_unused]] AZ::SettingsRegistryInterface::Type type, bool value) override
{
@@ -386,8 +390,36 @@ namespace AZ::SettingsRegistryMergeUtils
const ConfigParserSettings& configParserSettings)
{
auto configPath = FindEngineRoot(registry) / filePath;
IO::SystemFile configFile;
if (!configFile.Open(configPath.c_str(), IO::SystemFile::OpenMode::SF_OPEN_READ_ONLY))
IO::FileReader configFile;
bool configFileOpened{};
switch (configParserSettings.m_fileReaderClass)
{
case ConfigParserSettings::FileReaderClass::UseFileIOIfAvailableFallbackToSystemFile:
{
auto fileIo = AZ::IO::FileIOBase::GetInstance();
configFileOpened = configFile.Open(fileIo, configPath.c_str());
break;
}
case ConfigParserSettings::FileReaderClass::UseSystemFileOnly:
{
configFileOpened = configFile.Open(nullptr, configPath.c_str());
break;
}
case ConfigParserSettings::FileReaderClass::UseFileIOOnly:
{
auto fileIo = AZ::IO::FileIOBase::GetInstance();
if (fileIo == nullptr)
{
return false;
}
configFileOpened = configFile.Open(fileIo, configPath.c_str());
break;
}
default:
AZ_Error("SettingsRegistryMergeUtils", false, "An Invalid FileReaderClass enum value has been supplied");
return false;
}
if (!configFileOpened)
{
AZ_Warning("SettingsRegistryMergeUtils", false, R"(Unable to open file "%s")", configPath.c_str());
return false;
@@ -478,7 +510,7 @@ namespace AZ::SettingsRegistryMergeUtils
AZ_Error("SettingsRegistryMergeUtils", false,
R"(The config file "%s" contains a line which is longer than the max line length of %zu.)" "\n"
R"(Parsing will halt. The line content so far is:)" "\n"
R"("%.*s")" "\n", configFile.Name(), configBuffer.max_size(),
R"("%.*s")" "\n", configPath.c_str(), configBuffer.max_size(),
aznumeric_cast<int>(configBuffer.size()), configBuffer.data());
configFileParsed = false;
break;
@@ -761,6 +793,7 @@ namespace AZ::SettingsRegistryMergeUtils
return SettingsRegistryInterface::VisitResponse::Continue;
}
using AZ::SettingsRegistryInterface::Visitor::Visit;
void Visit(AZStd::string_view, [[maybe_unused]] AZStd::string_view valueName, SettingsRegistryInterface::Type, AZStd::string_view value) override
{
if (processingSourcePathKey)
@@ -896,6 +929,7 @@ namespace AZ::SettingsRegistryMergeUtils
struct CommandLineVisitor
: AZ::SettingsRegistryInterface::Visitor
{
using AZ::SettingsRegistryInterface::Visitor::Visit;
void Visit(AZStd::string_view, AZStd::string_view valueName, AZ::SettingsRegistryInterface::Type
, AZStd::string_view value) override
{
@@ -155,6 +155,15 @@ namespace AZ::SettingsRegistryMergeUtils
//! structure which is forwarded to the SettingsRegistryInterface MergeCommandLineArgument function
//! The structure contains a functor which returns true if a character is a valid delimiter
SettingsRegistryInterface::CommandLineArgumentSettings m_commandLineSettings;
//! enumeration to indicate if AZ::IO::FileIOBase should be used to open the config file over AZ::IO::SystemFile
enum class FileReaderClass
{
UseFileIOIfAvailableFallbackToSystemFile,
UseSystemFileOnly,
UseFileIOOnly
};
FileReaderClass m_fileReaderClass = FileReaderClass::UseFileIOIfAvailableFallbackToSystemFile;
};
//! Loads basic configuration files which have structures similar to Windows INI files
//! It is inspired by the Python configparser module: https://docs.python.org/3.10/library/configparser.html
@@ -57,6 +57,7 @@ namespace AZ
MOCK_METHOD1(SetApplyPatchSettings, void(const JsonApplyPatchSettings&));
MOCK_METHOD1(GetApplyPatchSettings, void(JsonApplyPatchSettings&));
MOCK_METHOD1(SetUseFileIO, void(bool));
};
} // namespace AZ
@@ -131,17 +131,23 @@ namespace UnitTest
, public AllocatorsBase
{
public:
// Bring in both const and non-const SetUp and TearDown function into scope to resolve warning 4266
// no override available for virtual member function from base 'benchmark::Fixture'; function is hidden
using ::benchmark::Fixture::SetUp, ::benchmark::Fixture::TearDown;
//Benchmark interface
void SetUp(const ::benchmark::State& st) override
{
AZ_UNUSED(st);
SetupAllocator();
}
void SetUp(::benchmark::State& st) override
{
AZ_UNUSED(st);
SetupAllocator();
}
void TearDown(const ::benchmark::State& st) override
{
AZ_UNUSED(st);
TeardownAllocator();
}
void TearDown(::benchmark::State& st) override
{
AZ_UNUSED(st);
@@ -116,9 +116,9 @@ namespace AZ
//////////////////////////////////////////////////////////////////////////
// UserSettingsBus
virtual AZStd::intrusive_ptr<UserSettings> FindUserSettings(u32 id);
virtual void AddUserSettings(u32 id, UserSettings* settings);
virtual bool Save(const char* settingsPath, SerializeContext* sc);
AZStd::intrusive_ptr<UserSettings> FindUserSettings(u32 id) override;
void AddUserSettings(u32 id, UserSettings* settings) override;
bool Save(const char* settingsPath, SerializeContext* sc) override;
//////////////////////////////////////////////////////////////////////////
static void Reflect(ReflectContext* reflection);
@@ -13,6 +13,7 @@
// the intention is that you only include the customized version of rapidXML through this header, so that
// you can override behavior here.
#include <stdio.h>
#include <rapidxml/rapidxml.h>
#endif // AZCORE_RAPIDXML_RAPIDXML_H_INCLUDED
@@ -166,6 +166,8 @@ set(FILES
IO/FileIO.cpp
IO/FileIO.h
IO/FileIOEventBus.h
IO/FileReader.cpp
IO/FileReader.h
IO/IOUtils.h
IO/IOUtils.cpp
IO/IStreamer.h
@@ -831,7 +831,6 @@ namespace AZStd
// find first element that value is before, using operator<
typename iterator_traits<ForwardIterator>::difference_type count = AZStd::distance(first, last);
typename iterator_traits<ForwardIterator>::difference_type step{};
count = AZStd::distance(first, last);
for (; 0 < count; )
{ // divide and conquer, find half that contains answer
step = count / 2;
@@ -187,7 +187,7 @@ namespace AZStd
: m_f(AZStd::move(f)) {}
thread_info_impl(Internal::thread_move_t<F> f)
: m_f(f) {}
virtual void execute() { m_f(); }
void execute() override { m_f(); }
private:
F m_f;
@@ -129,16 +129,16 @@ namespace AZStd
{
}
virtual void dispose() // nothrow
void dispose() override // nothrow
{
AZStd::checked_delete(px_);
}
virtual void destroy() // nothrow
void destroy() override // nothrow
{
this->~this_type();
a_.deallocate(this, sizeof(this_type), AZStd::alignment_of<this_type>::value);
}
virtual void* get_deleter(Internal::sp_typeinfo const&)
void* get_deleter(Internal::sp_typeinfo const&) override
{
return 0;
}
@@ -176,18 +176,18 @@ namespace AZStd
{
}
virtual void dispose() // nothrow
void dispose() override // nothrow
{
d_(p_);
}
virtual void destroy() // nothrow
void destroy() override // nothrow
{
this->~this_type();
a_.deallocate(this, sizeof(this_type), AZStd::alignment_of<this_type>::value);
}
virtual void* get_deleter(Internal::sp_typeinfo const& ti)
void* get_deleter(Internal::sp_typeinfo const& ti) override
{
return ti == aztypeid(D) ? &reinterpret_cast<char&>(d_) : 0;
}
@@ -96,6 +96,10 @@ namespace AZStd
&& !is_convertible_v<const T&, const Element*>>>
constexpr basic_fixed_string(const T& convertibleToView, size_type rhsOffset, size_type count);
// #12
constexpr basic_fixed_string(AZStd::nullptr_t) = delete;
constexpr operator AZStd::basic_string_view<Element, Traits>() const;
constexpr auto begin() -> iterator;
@@ -120,6 +124,7 @@ namespace AZStd
constexpr auto operator=(const T& convertible_to_view)
-> AZStd::enable_if_t<is_convertible_v<const T&, basic_string_view<Element, Traits>>
&& !is_convertible_v<const T&, const Element*>, basic_fixed_string&>;
constexpr auto operator=(AZStd::nullptr_t) -> basic_fixed_string& = delete;
constexpr auto operator+=(const basic_fixed_string& rhs) -> basic_fixed_string&;
constexpr auto operator+=(const_pointer ptr) -> basic_fixed_string&;
@@ -215,6 +215,7 @@ namespace AZStd
struct ErrorSink
{
virtual ~ErrorSink() = default;
virtual void RegexError(regex_constants::error_type code) = 0;
};
}
@@ -1079,7 +1080,7 @@ namespace AZStd
NodeBase* m_next;
NodeBase* m_previous;
virtual ~NodeBase() { }
virtual ~NodeBase() = default;
};
inline void DestroyNode(NodeBase* node, NodeBase* end = nullptr)
@@ -1758,7 +1759,7 @@ namespace AZStd
return (*this);
}
~basic_regex()
~basic_regex() override
{ // destroy the object
Clear();
}
@@ -2916,7 +2917,7 @@ namespace AZStd
}
template<class ForwardIterator, class Element, class RegExTraits>
inline NodeBase* Builder<ForwardIterator, Element, RegExTraits>::BeginGroup(void)
inline NodeBase* Builder<ForwardIterator, Element, RegExTraits>::BeginGroup()
{ // add group node
return (NewNode(NT_group));
}
@@ -3026,7 +3027,7 @@ namespace AZStd
}
template<class ForwardIterator, class Element, class RegExTraits>
inline RootNode* Builder<ForwardIterator, Element, RegExTraits>::EndPattern(void)
inline RootNode* Builder<ForwardIterator, Element, RegExTraits>::EndPattern()
{ // wrap up
NewNode(NT_end);
return m_root;
@@ -168,6 +168,9 @@ namespace AZStd
{
}
// C++23 overload to prevent initializing a string_view via a nullptr or integer type
constexpr basic_string(AZStd::nullptr_t) = delete;
inline ~basic_string()
{
// destroy the string
@@ -197,6 +200,7 @@ namespace AZStd
inline this_type& operator=(AZStd::basic_string_view<Element, Traits> view) { return assign(view); }
inline this_type& operator=(const_pointer ptr) { return assign(ptr); }
inline this_type& operator=(Element ch) { return assign(1, ch); }
inline this_type& operator=(AZStd::nullptr_t) = delete;
inline this_type& operator+=(const this_type& rhs) { return append(rhs); }
inline this_type& operator+=(const_pointer ptr) { return append(ptr); }
inline this_type& operator+=(Element ch) { return append(1, ch); }
@@ -502,6 +502,9 @@ namespace AZStd
swap(other);
}
// C++23 overload to prevent initializing a string_view via a nullptr or integer type
constexpr basic_string_view(AZStd::nullptr_t) = delete;
constexpr const_reference operator[](size_type index) const { return data()[index]; }
/// Returns value, not reference. If index is out of bounds, 0 is returned (can't be reference).
constexpr value_type at(size_type index) const
@@ -72,6 +72,7 @@ namespace AZ
{
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
bool fileFound = false;
if (AZ::IO::FixedMaxPath projectModulePath;
settingsRegistry->Get(projectModulePath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectConfigurationBinPath))
{
@@ -79,6 +80,23 @@ namespace AZ
if (AZ::IO::SystemFile::Exists(projectModulePath.c_str()))
{
m_fileName.assign(projectModulePath.c_str(), projectModulePath.Native().size());
fileFound = true;
}
}
if (!fileFound)
{
if (AZ::IO::FixedMaxPath installedBinariesPath;
settingsRegistry->Get(installedBinariesPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_InstalledBinaryFolder))
{
if (AZ::IO::FixedMaxPath engineRootFolder;
settingsRegistry->Get(engineRootFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder))
{
installedBinariesPath = engineRootFolder / installedBinariesPath / fullFilePath;
if (AZ::IO::SystemFile::Exists(installedBinariesPath.c_str()))
{
m_fileName.assign(installedBinariesPath.c_str(), installedBinariesPath.Native().size());
}
}
}
}
}
@@ -9,6 +9,7 @@
#include <AzCore/Utils/Utils.h>
#include <cstdlib>
#include <pwd.h>
namespace AZ
{
@@ -39,6 +40,14 @@ namespace AZ
AZ::IO::FixedMaxPath path{homePath};
return path.Native();
}
struct passwd* pass = getpwuid(getuid());
if (pass)
{
AZ::IO::FixedMaxPath path{pass->pw_dir};
return path.Native();
}
return {};
}
@@ -21,7 +21,7 @@ namespace AZ
class WinAPIOverrunDetectionSchema : public OverrunDetectionSchema::PlatformAllocator
{
public:
virtual SystemInformation GetSystemInformation() override
SystemInformation GetSystemInformation() override
{
SystemInformation result;
SYSTEM_INFO info;
@@ -32,7 +32,7 @@ namespace AZ
return result;
}
virtual void* ReserveBytes(size_t amount) override
void* ReserveBytes(size_t amount) override
{
void* result = VirtualAlloc(0, amount, MEM_RESERVE, PAGE_NOACCESS);
@@ -45,12 +45,12 @@ namespace AZ
return result;
}
virtual void ReleaseReservedBytes(void* base) override
void ReleaseReservedBytes(void* base) override
{
VirtualFree(base, 0, MEM_RELEASE);
}
virtual void* CommitBytes(void* base, size_t amount) override
void* CommitBytes(void* base, size_t amount) override
{
void* result = VirtualAlloc(base, amount, MEM_COMMIT, PAGE_READWRITE);
@@ -63,7 +63,7 @@ namespace AZ
return result;
}
virtual void DecommitBytes(void* base, size_t amount) override
void DecommitBytes(void* base, size_t amount) override
{
VirtualFree(base, amount, MEM_DECOMMIT);
}
@@ -267,6 +267,7 @@ namespace AZ::IO
SettingsRegistryInterface::VisitResponse::Continue : SettingsRegistryInterface::VisitResponse::Skip;
}
using SettingsRegistryInterface::Visitor::Visit;
void Visit([[maybe_unused]] AZStd::string_view path, [[maybe_unused]] AZStd::string_view valueName,
[[maybe_unused]] AZ::SettingsRegistryInterface::Type type, AZStd::string_view value) override
{
+1 -15
View File
@@ -1210,9 +1210,6 @@ namespace UnitTest
AZStd::string findStr("Hay");
string_view view3(findStr);
string_view nullptrView4(nullptr);
EXPECT_EQ(emptyView1, nullptrView4);
// copy
const size_t destBufferSize = 32;
@@ -1264,9 +1261,6 @@ namespace UnitTest
AZStd::size_t rfindResult = view3.rfind('a', 2);
EXPECT_EQ(1, rfindResult);
rfindResult = nullptrView4.rfind("");
EXPECT_EQ(string_view::npos, rfindResult);
rfindResult = emptyView1.rfind("");
EXPECT_EQ(string_view::npos, rfindResult);
@@ -1373,17 +1367,11 @@ namespace UnitTest
{
string_view view1("The quick brown fox jumped over the lazy dog");
string_view view2("Needle in Haystack");
string_view nullBeaverView(nullptr);
string_view emptyBeaverView;
string_view superEmptyBeaverView("");
EXPECT_EQ(nullBeaverView, emptyBeaverView);
EXPECT_EQ(superEmptyBeaverView, nullBeaverView);
EXPECT_EQ(emptyBeaverView, superEmptyBeaverView);
EXPECT_EQ(nullBeaverView, "");
EXPECT_EQ(nullBeaverView, nullptr);
EXPECT_EQ("", emptyBeaverView);
EXPECT_EQ(nullptr, superEmptyBeaverView);
EXPECT_EQ("", superEmptyBeaverView);
EXPECT_EQ("The quick brown fox jumped over the lazy dog", view1);
EXPECT_NE("The slow brown fox jumped over the lazy dog", view1);
@@ -1421,8 +1409,6 @@ namespace UnitTest
EXPECT_LE(beaverView, "Busy Beaver");
EXPECT_LE("Likable Beaver", notBeaverView);
EXPECT_LE("Busy Beaver", beaverView);
EXPECT_LE(nullBeaverView, nullBeaverView);
EXPECT_LE(nullBeaverView, lowerBeaverStr);
EXPECT_LE(microBeaverStr, view1);
EXPECT_LE(compareStr, beaverView);
@@ -100,6 +100,7 @@ namespace JsonSerializationTests
AZ::AllocatorInstance<AZ::PoolAllocator>::Destroy();
}
using JsonSerializerConformityTestDescriptor<AZ::Data::Asset<TestAssetData>>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<Asset>();
@@ -0,0 +1,72 @@
/*
* 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
*
*/
#include <AzCore/IO/FileReader.h>
#include <FileIOBaseTestTypes.h>
#include <AzCore/UnitTest/TestTypes.h>
namespace UnitTest
{
template <typename FileIOType>
class FileReaderTestFixture
: public ScopedAllocatorSetupFixture
{
public:
void SetUp() override
{
if constexpr (AZStd::is_same_v<FileIOType, TestFileIOBase>)
{
m_fileIo = AZStd::make_unique<TestFileIOBase>();
}
}
void TearDown() override
{
m_fileIo.reset();
}
protected:
AZStd::unique_ptr<AZ::IO::FileIOBase> m_fileIo{};
};
using FileIOTypes = ::testing::Types<void, TestFileIOBase>;
TYPED_TEST_CASE(FileReaderTestFixture, FileIOTypes);
TYPED_TEST(FileReaderTestFixture, ConstructorWithFilePath_OpensFileSuccessfully)
{
AZ::IO::FileReader fileReader(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename());
EXPECT_TRUE(fileReader.IsOpen());
}
TYPED_TEST(FileReaderTestFixture, Open_OpensFileSucessfully)
{
AZ::IO::FileReader fileReader;
fileReader.Open(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename());
EXPECT_TRUE(fileReader.IsOpen());
}
TYPED_TEST(FileReaderTestFixture, Eof_OnNULDeviceFile_Succeeds)
{
AZ::IO::FileReader fileReader(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename());
EXPECT_TRUE(fileReader.Eof());
}
TYPED_TEST(FileReaderTestFixture, GetFilePath_ReturnsNULDeviceFilename_Succeeds)
{
AZ::IO::FileReader fileReader(this->m_fileIo.get(), AZ::IO::SystemFile::GetNullFilename());
AZ::IO::FixedMaxPath filePath;
EXPECT_TRUE(fileReader.GetFilePath(filePath));
AZ::IO::FixedMaxPath nulFilename{ AZ::IO::SystemFile::GetNullFilename() };
if (this->m_fileIo)
{
EXPECT_TRUE(this->m_fileIo->ResolvePath(nulFilename, nulFilename));
}
EXPECT_EQ(nulFilename, filePath);
}
} // namespace UnitTest
@@ -956,18 +956,8 @@ AZ_POP_DISABLE_WARNING
namespace Benchmark
{
class PathBenchmarkFixture
: public ::benchmark::Fixture
, public ::UnitTest::AllocatorsBase
: public ::UnitTest::AllocatorsBenchmarkFixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
{
::UnitTest::AllocatorsBase::SetupAllocator();
}
void TearDown([[maybe_unused]] const ::benchmark::State& state) override
{
::UnitTest::AllocatorsBase::TeardownAllocator();
}
protected:
AZStd::fixed_vector<const char*, 20> m_appendPaths{ "foo", "bar", "baz", "bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",
"boo/bar/base", "C:\\path\\to\\O3DE", "C", "\\\\", "/", R"(test\\path/with\mixed\separators)" };
+18 -2
View File
@@ -1704,7 +1704,7 @@ namespace Benchmark
static const AZ::u32 MEDIUM_NUMBER_OF_JOBS = 1024;
static const AZ::u32 LARGE_NUMBER_OF_JOBS = 16384;
void SetUp([[maybe_unused]] ::benchmark::State& state) override
void internalSetUp()
{
AllocatorInstance<PoolAllocator>::Create();
AllocatorInstance<ThreadPoolAllocator>::Create();
@@ -1749,8 +1749,16 @@ namespace Benchmark
return randomDepthDistribution(randomDepthGenerator);
});
}
void SetUp(::benchmark::State&) override
{
internalSetUp();
}
void SetUp(const ::benchmark::State&) override
{
internalSetUp();
}
void TearDown([[maybe_unused]] ::benchmark::State& state) override
void internalTearDown()
{
JobContext::SetGlobalContext(nullptr);
@@ -1763,6 +1771,14 @@ namespace Benchmark
AllocatorInstance<ThreadPoolAllocator>::Destroy();
AllocatorInstance<PoolAllocator>::Destroy();
}
void TearDown(::benchmark::State&) override
{
internalTearDown();
}
void TearDown(const ::benchmark::State&) override
{
internalTearDown();
}
protected:
inline void RunCalculatePiJob(AZ::s32 depth, AZ::s8 priority)
@@ -19,8 +19,7 @@ namespace Benchmark
class BM_MathFrustum
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
m_testFrustum = AZ::Frustum(AZ::ViewFrustumAttributes(AZ::Transform::CreateIdentity(), 1.0f, 2.0f * atanf(0.5f), 10.0f, 90.0f));
@@ -40,6 +39,15 @@ namespace Benchmark
return data;
});
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
struct Data
{
@@ -23,8 +23,7 @@ namespace Benchmark
class BM_MathMatrix3x3
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
m_testDataArray.resize(1000);
@@ -44,6 +43,15 @@ namespace Benchmark
return testData;
});
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
struct TestData
{
@@ -21,8 +21,7 @@ namespace Benchmark
class BM_MathMatrix3x4
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const::benchmark::State& state) override
void internalSetUp()
{
m_testDataArray.resize(1000);
@@ -58,6 +57,15 @@ namespace Benchmark
return testData;
});
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
struct TestData
{
@@ -20,8 +20,7 @@ namespace Benchmark
class BM_MathMatrix4x4
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
m_testDataArray.resize(1000);
@@ -41,6 +40,15 @@ namespace Benchmark
return testData;
});
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
struct TestData
{
@@ -19,8 +19,7 @@ namespace Benchmark
class BM_MathObb
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
m_position.Set(1.0f, 2.0f, 3.0f);
m_rotation = AZ::Quaternion::CreateRotationZ(AZ::Constants::QuarterPi);
@@ -28,6 +27,16 @@ namespace Benchmark
m_obb = AZ::Obb::CreateFromPositionRotationAndHalfLengths(m_position, m_rotation, m_halfLengths);
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
AZ::Obb m_obb;
AZ::Vector3 m_position;
AZ::Quaternion m_rotation;
@@ -18,14 +18,7 @@ namespace Benchmark
class BM_MathPlane
: public benchmark::Fixture
{
public:
BM_MathPlane()
{
const unsigned int seed = 1;
rng = std::mt19937_64(seed);
}
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
for (int i = 0; i < m_numIters; ++i)
{
@@ -39,7 +32,7 @@ namespace Benchmark
m_distance = unif(rng);
m_dists.push_back(m_distance);
//set these differently so they don't overlap with same values as other vectors
// set these differently so they don't overlap with same values as other vectors
m_normal = AZ::Vector3(unif(rng), unif(rng), unif(rng));
m_normal.Normalize();
m_distance = unif(rng);
@@ -47,6 +40,21 @@ namespace Benchmark
m_planes.push_back(m_plane);
}
}
public:
BM_MathPlane()
{
const unsigned int seed = 1;
rng = std::mt19937_64(seed);
}
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
AZ::Plane m_plane;
AZ::Vector3 m_normal;
@@ -17,8 +17,7 @@ namespace Benchmark
class BM_MathQuaternion
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
m_quatDataArray.resize(1000);
@@ -42,6 +41,15 @@ namespace Benchmark
return quatData;
});
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
struct QuatData
{
@@ -35,8 +35,7 @@ namespace Benchmark
class BM_MathShapeIntersection
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
m_testDataArray.resize(1000);
@@ -58,6 +57,15 @@ namespace Benchmark
return testData;
});
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
struct TestData
{
@@ -22,8 +22,7 @@ namespace Benchmark
class BM_MathTransform
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
m_testDataArray.resize(1000);
@@ -51,6 +50,15 @@ namespace Benchmark
return testData;
});
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
struct TestData
{
@@ -19,8 +19,7 @@ namespace Benchmark
class BM_MathVector2
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
m_vecDataArray.resize(1000);
@@ -37,6 +36,15 @@ namespace Benchmark
return vecData;
});
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
struct VecData
{
@@ -19,8 +19,7 @@ namespace Benchmark
class BM_MathVector3
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
m_vecDataArray.resize(1000);
@@ -37,6 +36,15 @@ namespace Benchmark
return vecData;
});
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
struct VecData
{
@@ -19,8 +19,7 @@ namespace Benchmark
class BM_MathVector4
: public benchmark::Fixture
{
public:
void SetUp([[maybe_unused]] const ::benchmark::State& state) override
void internalSetUp()
{
m_vecDataArray.resize(1000);
@@ -38,6 +37,15 @@ namespace Benchmark
return vecData;
});
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
struct VecData
{
@@ -120,19 +120,34 @@ namespace Benchmark
class HphaSchemaBenchmarkFixture
: public ::benchmark::Fixture
{
public:
void SetUp(const ::benchmark::State& state) override
void internalSetUp()
{
AZ_UNUSED(state);
AZ::AllocatorInstance<HphaSchema_TestAllocator>::Create();
}
void TearDown(const ::benchmark::State& state) override
void internalTearDown()
{
AZ_UNUSED(state);
AZ::AllocatorInstance<HphaSchema_TestAllocator>::Destroy();
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
void TearDown(const benchmark::State&) override
{
internalTearDown();
}
void TearDown(benchmark::State&) override
{
internalTearDown();
}
static void BM_Allocations(benchmark::State& state, const AllocationSizeArray& allocationArray)
{
AZStd::vector<void*> allocations;
@@ -362,7 +362,7 @@ namespace UnitTest
// Test specific construction case that was failing.
// The constructor calls Name::SetName() which does a move assignment
// Name& Name::operator=(Name&& rhs) was leaving m_view pointing to the m_data in a temporary Name object.
AZ::Name emptyName(AZStd::string_view(nullptr));
AZ::Name emptyName(AZStd::string_view{});
EXPECT_TRUE(emptyName.IsEmpty());
EXPECT_EQ(0, emptyName.GetStringView().data()[0]);
}
@@ -1155,6 +1155,23 @@ namespace Benchmark
{
class StorageDriveWindowsFixture : public benchmark::Fixture
{
void internalTearDown()
{
using namespace AZ::IO;
AZStd::string temp;
m_absolutePath.swap(temp);
delete m_streamer;
m_streamer = nullptr;
SystemFile::Delete(TestFileName);
AZ::IO::FileIOBase::SetInstance(nullptr);
AZ::IO::FileIOBase::SetInstance(m_previousFileIO);
delete m_fileIO;
m_fileIO = nullptr;
}
public:
constexpr static const char* TestFileName = "StreamerBenchmark.bin";
constexpr static size_t FileSize = 64_mib;
@@ -1197,20 +1214,13 @@ namespace Benchmark
}
}
void TearDown([[maybe_unused]] const ::benchmark::State& state) override
void TearDown(const benchmark::State&) override
{
using namespace AZ::IO;
AZStd::string temp;
m_absolutePath.swap(temp);
delete m_streamer;
SystemFile::Delete(TestFileName);
AZ::IO::FileIOBase::SetInstance(nullptr);
AZ::IO::FileIOBase::SetInstance(m_previousFileIO);
delete m_fileIO;
internalTearDown();
}
void TearDown(benchmark::State&) override
{
internalTearDown();
}
void RepeatedlyReadFile(benchmark::State& state)
@@ -35,6 +35,7 @@ namespace JsonSerializationTests
features.m_fixedSizeArray = true;
}
using JsonSerializerConformityTestDescriptor<T>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<T>();
@@ -243,6 +244,7 @@ namespace JsonSerializationTests
])";
}
using ArraySerializerTestDescriptionBase<AZStd::array<BaseClass2*, 4>>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
Base::Reflect(context);
@@ -299,6 +301,7 @@ namespace JsonSerializationTests
AZ::JsonArraySerializer m_serializer;
public:
using BaseJsonSerializerFixture::RegisterAdditional;
void RegisterAdditional(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<Array>();
@@ -60,6 +60,7 @@ namespace JsonSerializationTests
return "[188, 288, 388]";
}
using BasicContainerConformityTestDescriptor<Container>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<Container>();
@@ -133,6 +134,7 @@ namespace JsonSerializationTests
return "[188, 288, 388]";
}
using BasicContainerConformityTestDescriptor<Container>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<Container>();
@@ -225,6 +227,7 @@ namespace JsonSerializationTests
features.m_supportsPartialInitialization = true;
}
using BasicContainerConformityTestDescriptor<Container>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
SimpleClass::Reflect(context, true);
@@ -291,6 +294,7 @@ namespace JsonSerializationTests
using Container = AZStd::vector<SimpleClass>;
using BaseClassContainer = AZStd::vector<AZStd::shared_ptr<BaseClass>>;
using JsonBasicContainerSerializerTests::RegisterAdditional;
void RegisterAdditional(AZStd::unique_ptr<AZ::SerializeContext>& serializeContext) override
{
SimpleClass::Reflect(serializeContext, true);
@@ -352,6 +356,7 @@ namespace JsonSerializationTests
static constexpr size_t ContainerSize = 4;
using Container = AZStd::fixed_vector<int, ContainerSize>;
using JsonBasicContainerSerializerTests::RegisterAdditional;
void RegisterAdditional(AZStd::unique_ptr<AZ::SerializeContext>& serializeContext) override
{
serializeContext->RegisterGenericType<Container>();
@@ -387,6 +392,7 @@ namespace JsonSerializationTests
public:
using Set = AZStd::set<int>;
using JsonBasicContainerSerializerTests::RegisterAdditional;
void RegisterAdditional(AZStd::unique_ptr<AZ::SerializeContext>& serializeContext) override
{
serializeContext->RegisterGenericType<Set>();
@@ -83,6 +83,7 @@ namespace JsonSerializationTests
BaseJsonSerializerFixture::TearDown();
}
using BaseJsonSerializerFixture::RegisterAdditional;
void RegisterAdditional(AZStd::unique_ptr<AZ::SerializeContext>& serializeContext) override
{
serializeContext->Class<BoolPointerWrapper>()
@@ -95,6 +95,7 @@ namespace JsonSerializationTests
BaseJsonSerializerFixture::TearDown();
}
using BaseJsonSerializerFixture::RegisterAdditional;
void RegisterAdditional(AZStd::unique_ptr<AZ::SerializeContext>& serializeContext) override
{
serializeContext->Class<DoublePointerWrapper>()
@@ -44,6 +44,7 @@ namespace JsonSerializationTests
features.m_supportsPartialInitialization = false;
}
using JsonSerializerConformityTestDescriptor<Map>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<Map>();
@@ -247,6 +248,7 @@ namespace JsonSerializationTests
features.m_supportsPartialInitialization = true;
}
using MapBaseTestDescription<T<SimpleClass*, SimpleClass*>, Serializer>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
SimpleClass::Reflect(context, true);
@@ -33,6 +33,7 @@ namespace JsonSerializationTests
return AZStd::make_shared<SmartPointer>();
}
using JsonSerializerConformityTestDescriptor<SmartPointer>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<SmartPointer>();
@@ -102,6 +103,7 @@ namespace JsonSerializationTests
return *lhs == *rhs;
}
using Base::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
SimpleClass::Reflect(context, true);
@@ -176,6 +178,7 @@ namespace JsonSerializationTests
features.m_supportsPartialInitialization = true;
}
using SmartPointerBaseTestDescription<T<BaseClass>>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
SimpleInheritence::Reflect(context, true);
@@ -340,6 +343,7 @@ namespace JsonSerializationTests
features.m_supportsPartialInitialization = true;
}
using SmartPointerBaseTestDescription<T<BaseClass2>>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
MultipleInheritence::Reflect(context, true);
@@ -513,7 +517,8 @@ namespace JsonSerializationTests
public:
using SmartPointer = typename SmartPointerSimpleDerivedClassTestDescription<AZStd::shared_ptr>::SmartPointer;
using InstanceSmartPointer = AZStd::shared_ptr<SimpleInheritence>;
using BaseJsonSerializerFixture::RegisterAdditional;
void RegisterAdditional(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
m_description.Reflect(context);
@@ -72,6 +72,7 @@ namespace JsonSerializationTests
TupleSerializerTestsInternal::ConfigureFeatures(features);
}
using JsonSerializerConformityTestDescriptor<AZStd::pair<int, double>>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->Class<PairPlaceholder>()->Field("pair", &PairPlaceholder::m_pair);
@@ -126,6 +127,7 @@ namespace JsonSerializationTests
TupleSerializerTestsInternal::ConfigureFeatures(features);
}
using JsonSerializerConformityTestDescriptor<Tuple>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<Tuple>();
@@ -344,6 +346,7 @@ namespace JsonSerializationTests
features.m_enableNewInstanceTests = false;
}
using JsonSerializerConformityTestDescriptor::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->Class<TupleClass>()
@@ -477,6 +480,7 @@ namespace JsonSerializationTests
features.m_typeToInject = rapidjson::kNullType;
}
using JsonSerializerConformityTestDescriptor<Tuple>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<Tuple>();
@@ -535,6 +539,7 @@ namespace JsonSerializationTests
BaseJsonSerializerFixture::TearDown();
}
using BaseJsonSerializerFixture::RegisterAdditional;
void RegisterAdditional(AZStd::unique_ptr<AZ::SerializeContext>& serializeContext) override
{
SimpleClass::Reflect(serializeContext, true);
@@ -54,6 +54,7 @@ namespace JsonSerializationTests
features.m_supportsPartialInitialization = false;
}
using JsonSerializerConformityTestDescriptor<AZStd::unordered_set<int>>::Reflect;
void Reflect(AZStd::unique_ptr<AZ::SerializeContext>& context) override
{
context->RegisterGenericType<Set>();
@@ -108,6 +109,7 @@ namespace JsonSerializationTests
context->RegisterGenericType<MultiSet>();
}
using JsonSerializerConformityTestDescriptor<MultiSet>::Reflect;
bool AreEqual(const MultiSet& lhs, const MultiSet& rhs) override
{
return
@@ -139,6 +141,7 @@ namespace JsonSerializationTests
BaseJsonSerializerFixture::TearDown();
}
using BaseJsonSerializerFixture::RegisterAdditional;
void RegisterAdditional(AZStd::unique_ptr<AZ::SerializeContext>& serializeContext) override
{
serializeContext->RegisterGenericType<Set>();
@@ -423,6 +423,8 @@ namespace SettingsRegistryTests
struct : public AZ::SettingsRegistryInterface::Visitor
{
using AZ::SettingsRegistryInterface::Visitor::Visit;
using ValueType [[maybe_unused]] = typename SettingsType<TypeParam>::ValueType;
void Visit([[maybe_unused]] AZStd::string_view path, [[maybe_unused]] AZStd::string_view valueName, AZ::SettingsRegistryInterface::Type type, ValueType value) override
{
@@ -452,6 +454,8 @@ namespace SettingsRegistryTests
struct : public AZ::SettingsRegistryInterface::Visitor
{
using AZ::SettingsRegistryInterface::Visitor::Visit;
using ValueType [[maybe_unused]] = typename SettingsType<TypeParam>::ValueType;
void Visit([[maybe_unused]] AZStd::string_view path, [[maybe_unused]] AZStd::string_view valueName, AZ::SettingsRegistryInterface::Type type, ValueType value) override
{
@@ -482,6 +486,7 @@ namespace SettingsRegistryTests
struct : public AZ::SettingsRegistryInterface::Visitor
{
using AZ::SettingsRegistryInterface::Visitor::Visit;
void Visit([[maybe_unused]] AZStd::string_view path, [[maybe_unused]] AZStd::string_view valueName, AZ::SettingsRegistryInterface::Type type, AZ::s64 value) override
{
EXPECT_EQ(AZ::SettingsRegistryInterface::Type::Integer, type);
@@ -517,6 +522,8 @@ namespace SettingsRegistryTests
EXPECT_TRUE(path.ends_with(valueName));
return AZ::SettingsRegistryInterface::VisitResponse::Continue;
}
using AZ::SettingsRegistryInterface::Visitor::Visit;
void Visit(AZStd::string_view path, AZStd::string_view valueName, AZ::SettingsRegistryInterface::Type , AZStd::string_view)override
{
EXPECT_TRUE(path.ends_with(valueName));
@@ -1510,7 +1517,7 @@ namespace SettingsRegistryTests
m_testFolder->push_back(AZ_CORRECT_DATABASE_SEPARATOR);
*m_testFolder += AZ::SettingsRegistryInterface::RegistryFolder;
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, {}, nullptr);
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, {});
EXPECT_TRUE(result);
EXPECT_EQ(4, counter);
@@ -1552,7 +1559,7 @@ namespace SettingsRegistryTests
m_testFolder->push_back(AZ_CORRECT_DATABASE_SEPARATOR);
*m_testFolder += AZ::SettingsRegistryInterface::RegistryFolder;
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, "Special", nullptr);
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, "Special");
EXPECT_TRUE(result);
EXPECT_EQ(6, counter);
@@ -1591,7 +1598,7 @@ namespace SettingsRegistryTests
m_testFolder->push_back(AZ_CORRECT_DATABASE_SEPARATOR);
*m_testFolder += AZ::SettingsRegistryInterface::RegistryFolder;
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, {}, nullptr);
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, {});
EXPECT_TRUE(result);
EXPECT_EQ(4, counter);
@@ -1632,7 +1639,7 @@ namespace SettingsRegistryTests
m_testFolder->push_back(AZ_CORRECT_DATABASE_SEPARATOR);
*m_testFolder += AZ::SettingsRegistryInterface::RegistryFolder;
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, {}, nullptr);
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, {});
EXPECT_TRUE(result);
EXPECT_EQ(4, counter);
@@ -1665,7 +1672,7 @@ namespace SettingsRegistryTests
m_testFolder->push_back(AZ_CORRECT_DATABASE_SEPARATOR);
*m_testFolder += AZ::SettingsRegistryInterface::RegistryFolder;
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, "Special", nullptr);
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, "Special");
EXPECT_TRUE(result);
EXPECT_EQ(1, counter);
@@ -1715,7 +1722,7 @@ namespace SettingsRegistryTests
TEST_F(SettingsRegistryTest, MergeSettingsFolder_EmptyFolder_ReportsSuccessButNothingAdded)
{
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, {}, nullptr);
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, {});
EXPECT_TRUE(result);
EXPECT_EQ(AZ::SettingsRegistryInterface::Type::Object, m_registry->GetType(AZ_SETTINGS_REGISTRY_HISTORY_KEY "/0")); // Folder and specialization settings.
@@ -1727,7 +1734,7 @@ namespace SettingsRegistryTests
constexpr AZStd::fixed_string<AZ::IO::MaxPathLength + 1> path(AZ::IO::MaxPathLength + 1, 'a');
AZ_TEST_START_TRACE_SUPPRESSION;
bool result = m_registry->MergeSettingsFolder(path, { "editor", "test" }, {}, nullptr);
bool result = m_registry->MergeSettingsFolder(path, { "editor", "test" }, {});
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
EXPECT_FALSE(result);
@@ -1744,7 +1751,7 @@ namespace SettingsRegistryTests
AZ_TEST_START_TRACE_SUPPRESSION;
m_testFolder->push_back(AZ_CORRECT_DATABASE_SEPARATOR);
*m_testFolder += AZ::SettingsRegistryInterface::RegistryFolder;
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, {}, nullptr);
bool result = m_registry->MergeSettingsFolder(*m_testFolder, { "editor", "test" }, {});
EXPECT_GT(::UnitTest::TestRunner::Instance().StopAssertTests(), 0);
EXPECT_FALSE(result);
+21 -3
View File
@@ -551,19 +551,37 @@ namespace Benchmark
{
class TaskGraphBenchmarkFixture : public ::benchmark::Fixture
{
public:
void SetUp(benchmark::State&) override
void internalSetUp()
{
executor = new TaskExecutor;
graph = new TaskGraph;
}
void TearDown(benchmark::State&) override
void internalTearDown()
{
delete graph;
delete executor;
}
public:
void SetUp(const benchmark::State&) override
{
internalSetUp();
}
void SetUp(benchmark::State&) override
{
internalSetUp();
}
void TearDown(const benchmark::State&) override
{
internalTearDown();
}
void TearDown(benchmark::State&) override
{
internalTearDown();
}
TaskDescriptor descriptors[4] = { { "critical", "benchmark", TaskPriority::CRITICAL },
{ "high", "benchmark", TaskPriority::HIGH },
{ "medium", "benchmark", TaskPriority::MEDIUM },
@@ -37,6 +37,7 @@ set(FILES
FileIOBaseTestTypes.h
Geometry2DUtils.cpp
Interface.cpp
IO/FileReaderTests.cpp
IO/Path/PathTests.cpp
IPC.cpp
Jobs.cpp