Merge branch 'main' into hasareej_LYN-2475_viewportui_switcher
This commit is contained in:
@@ -302,10 +302,10 @@ def ProcessExpansionRule(sourceFiles, templateFiles, templateCache, outputDir, p
|
||||
# Due to the lack of wildcards in the output file, we've determined we'll glob all matching input files into the template conversion
|
||||
for filename in fnmatch.filter(sourceFiles, inputFiles):
|
||||
dataInputFiles = [os.path.abspath(file) for file in fnmatch.filter(sourceFiles, inputFiles)]
|
||||
outputFileAbsolute = outputFile.replace("$path", ComputeOutputPath(dataInputFiles, projectDir, outputDir))
|
||||
outputFileAbsolute = SanitizePath(outputFileAbsolute)
|
||||
ProcessTemplateConversion(dataInputSet, dataInputFiles, templateFile, outputFileAbsolute, templateCache, dryrun, verbose)
|
||||
outputFiles.append(outputFileAbsolute)
|
||||
outputFileAbsolute = outputFile.replace("$path", ComputeOutputPath(dataInputFiles, projectDir, outputDir))
|
||||
outputFileAbsolute = SanitizePath(outputFileAbsolute)
|
||||
ProcessTemplateConversion(dataInputSet, dataInputFiles, templateFile, outputFileAbsolute, templateCache, dryrun, verbose)
|
||||
outputFiles.append(outputFileAbsolute)
|
||||
except IOError as e:
|
||||
PrintError('%s : error I/O(%s) accessing %s : %s' % (expansionRule, e.errno, e.filename, e.strerror))
|
||||
except:
|
||||
@@ -357,8 +357,7 @@ if __name__ == '__main__':
|
||||
parser.add_argument("expansionRules", help="set of azcg expansion rules for matching data files to template files")
|
||||
parser.add_argument("-n", "--dryrun", action='store_true', help="does not execute autogen, only outputs the set of files that autogen would generate")
|
||||
parser.add_argument("-v", "--verbose", action='store_true', help="output only the set of files that would be generated by an expansion run")
|
||||
parser.add_argument("-p", "--pythonPaths", action='append', nargs='+', default=[""],
|
||||
help="set of additional python paths to use for module imports")
|
||||
parser.add_argument("-p", "--pythonPaths", action='append', nargs='+', default=[""], help="set of additional python paths to use for module imports")
|
||||
|
||||
args = parser.parse_args()
|
||||
pythonPaths = args.pythonPaths
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace AZ
|
||||
bool loadFileToMemory = Get().ShouldLoadFileToMemory(filename);
|
||||
int assetMode = loadFileToMemory ? AASSET_MODE_BUFFER : AASSET_MODE_UNKNOWN;
|
||||
|
||||
asset = AAssetManager_open(Utils::GetAssetManager(), Utils::StripApkPrefix(filename), assetMode);
|
||||
asset = AAssetManager_open(Utils::GetAssetManager(), Utils::StripApkPrefix(filename).c_str(), assetMode);
|
||||
|
||||
if (asset != nullptr)
|
||||
{
|
||||
@@ -192,7 +192,7 @@ namespace AZ
|
||||
{
|
||||
buf->m_offset = buf->m_totalSize - offset;
|
||||
}
|
||||
|
||||
|
||||
if (buf->m_offset > buf->m_totalSize)
|
||||
{
|
||||
buf->m_offset = buf->m_totalSize;
|
||||
@@ -320,12 +320,19 @@ namespace AZ
|
||||
|
||||
bool APKFileHandler::DirectoryOrFileExists(const char* path)
|
||||
{
|
||||
ANDROID_IO_PROFILE_SECTION_ARGS("APK DirOrFileexists");
|
||||
ANDROID_IO_PROFILE_SECTION_ARGS("APK DirOrFileExists");
|
||||
|
||||
AZ::IO::PathView insideApkPathView(Utils::StripApkPrefix(path));
|
||||
AZ::IO::FixedMaxPath insideApkPath(Utils::StripApkPrefix(path));
|
||||
|
||||
AZ::IO::FixedMaxPathString filename{ insideApkPathView.Filename().Native() };
|
||||
AZ::IO::FixedMaxPathString pathToFile{ insideApkPathView.ParentPath().Native() };
|
||||
// Check for the case where the input path is equal to the APK Assets Prefix of /APK
|
||||
// In that case the directory is the "root" of APK assets in which case the directory exist
|
||||
if (insideApkPath.empty() && Utils::IsApkPath(path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPathString filename{ insideApkPath.Filename().Native() };
|
||||
AZ::IO::FixedMaxPathString pathToFile{ insideApkPath.ParentPath().Native() };
|
||||
bool foundFile = false;
|
||||
|
||||
ParseDirectory(pathToFile.c_str(), [&](const char* name)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
|
||||
#include <AzCore/Memory/OSAllocator.h>
|
||||
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -28,9 +28,9 @@ namespace AZ
|
||||
namespace
|
||||
{
|
||||
////////////////////////////////////////////////////////////////
|
||||
const char* GetApkAssetsPrefix()
|
||||
constexpr const char* GetApkAssetsPrefix()
|
||||
{
|
||||
return "/APK/";
|
||||
return "/APK";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,19 +104,14 @@ namespace AZ
|
||||
////////////////////////////////////////////////////////////////
|
||||
bool IsApkPath(const char* filePath)
|
||||
{
|
||||
return (strncmp(filePath, GetApkAssetsPrefix(), 4) == 0); // +3 for "APK", +1 for '/' starting slash
|
||||
return AZ::IO::PathView(filePath).IsRelativeTo(AZ::IO::PathView(GetApkAssetsPrefix()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
const char* StripApkPrefix(const char* filePath)
|
||||
AZ::IO::FixedMaxPath StripApkPrefix(const char* filePath)
|
||||
{
|
||||
const int prefixLength = 5; // +3 for "APK", +2 for '/' on either end
|
||||
if (!IsApkPath(filePath))
|
||||
{
|
||||
return filePath;
|
||||
}
|
||||
|
||||
return filePath + prefixLength;
|
||||
constexpr AZ::IO::PathView apkPrefixView = GetApkAssetsPrefix();
|
||||
return AZ::IO::PathView(filePath).LexicallyProximate(apkPrefixView);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -130,7 +125,7 @@ namespace AZ
|
||||
// first check to see if they are in public storage (application specific)
|
||||
const char* publicAppStorage = GetAppPublicStoragePath();
|
||||
|
||||
OSString path = OSString::format("%s/bootstrap.cfg", publicAppStorage);
|
||||
OSString path = OSString::format("%s/engine.json", publicAppStorage);
|
||||
AZ_TracePrintf("Android::Utils", "Searching for %s\n", path.c_str());
|
||||
|
||||
FILE* f = fopen(path.c_str(), "r");
|
||||
@@ -145,7 +140,7 @@ namespace AZ
|
||||
AAssetManager* mgr = GetAssetManager();
|
||||
if (mgr)
|
||||
{
|
||||
AAsset* asset = AAssetManager_open(mgr, "bootstrap.cfg", AASSET_MODE_UNKNOWN);
|
||||
AAsset* asset = AAssetManager_open(mgr, "engine.json", AASSET_MODE_UNKNOWN);
|
||||
if (asset)
|
||||
{
|
||||
AAsset_close(asset);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/IO/Path/Path_fwd.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
#include <jni.h>
|
||||
@@ -55,7 +56,7 @@ namespace AZ
|
||||
const char* GetObbStoragePath();
|
||||
|
||||
//! Get the dot separated package name for the current application.
|
||||
//! e.g. com.lumberyard.samples for SamplesProject
|
||||
//! e.g. com.o3de.samples for SamplesProject
|
||||
const char* GetPackageName();
|
||||
|
||||
//! Get the app version code (android:versionCode in the manifest).
|
||||
@@ -70,7 +71,7 @@ namespace AZ
|
||||
//! Will first check to verify the argument is an apk asset path and if so
|
||||
//! will strip the prefix from the path.
|
||||
//! \return The pointer position of the relative asset path
|
||||
const char* StripApkPrefix(const char* filePath);
|
||||
AZ::IO::FixedMaxPath StripApkPrefix(const char* filePath);
|
||||
|
||||
//! Searches application storage and the APK for bootstrap.cfg. Will return nullptr
|
||||
//! if bootstrap.cfg is not found.
|
||||
|
||||
@@ -418,16 +418,19 @@ namespace AZ
|
||||
|
||||
void AssetContainer::ListWaitingAssets() const
|
||||
{
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
AZStd::lock_guard<AZStd::recursive_mutex> lock(m_readyMutex);
|
||||
AZ_TracePrintf("AssetContainer", "Waiting on assets:\n");
|
||||
for (auto& thisAsset : m_waitingAssets)
|
||||
{
|
||||
AZ_TracePrintf("AssetContainer", " %s\n",thisAsset.ToString<AZStd::string>().c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void AssetContainer::ListWaitingPreloads(const AssetId& assetId) const
|
||||
void AssetContainer::ListWaitingPreloads([[maybe_unused]] const AssetId& assetId) const
|
||||
{
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
AZStd::lock_guard<AZStd::recursive_mutex> preloadGuard(m_preloadMutex);
|
||||
auto preloadEntry = m_preloadList.find(assetId);
|
||||
if (preloadEntry != m_preloadList.end())
|
||||
@@ -442,6 +445,7 @@ namespace AZ
|
||||
{
|
||||
AZ_TracePrintf("AssetContainer", "%s isn't waiting on any preloads:\n", assetId.ToString<AZStd::string>().c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void AssetContainer::AddWaitingAssets(const AZStd::vector<AssetId>& assetList)
|
||||
|
||||
@@ -90,8 +90,8 @@ namespace AZ::Data
|
||||
// Get the results
|
||||
auto streamer = AZ::Interface<AZ::IO::IStreamer>::Get();
|
||||
AZ::u64 bytesRead = 0;
|
||||
bool result = streamer->GetReadRequestResult(fileHandle, m_buffer, bytesRead,
|
||||
AZ::IO::IStreamerTypes::ClaimMemory::Yes);
|
||||
streamer->GetReadRequestResult(fileHandle, m_buffer, bytesRead,
|
||||
AZ::IO::IStreamerTypes::ClaimMemory::Yes);
|
||||
auto status = streamer->GetRequestStatus(fileHandle);
|
||||
m_loadedSize = aznumeric_cast<size_t>(bytesRead);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Asset/AssetManager.h>
|
||||
#include <AzCore/Asset/AssetJsonSerializer.h>
|
||||
#include <AzCore/Serialization/Json/JsonSerialization.h>
|
||||
#include <AzCore/Serialization/Json/StackedString.h>
|
||||
@@ -107,7 +107,8 @@ namespace AZ
|
||||
result = ContinueLoading(&id, azrtti_typeid<AssetId>(), it->value, context);
|
||||
if (!id.m_guid.IsNull())
|
||||
{
|
||||
*instance = Asset<AssetData>(id, instance->GetType());
|
||||
*instance = AssetManager::Instance().FindOrCreateAsset(id, instance->GetType(), AssetLoadBehavior::NoLoad);
|
||||
|
||||
|
||||
result.Combine(context.Report(result, "Successfully created Asset<T> with id."));
|
||||
}
|
||||
|
||||
@@ -1117,7 +1117,7 @@ namespace AZ
|
||||
return asset;
|
||||
}
|
||||
|
||||
void AssetManager::UpdateDebugStatus(AZ::Data::Asset<AZ::Data::AssetData> asset)
|
||||
void AssetManager::UpdateDebugStatus(const AZ::Data::Asset<AZ::Data::AssetData>& asset)
|
||||
{
|
||||
if(!m_debugAssetEvents)
|
||||
{
|
||||
@@ -1750,7 +1750,6 @@ namespace AZ
|
||||
{
|
||||
AssetData* data = asset.Get();
|
||||
{
|
||||
const AZ::Data::AssetId& assetId = asset.GetId();
|
||||
|
||||
AZStd::scoped_lock<AZStd::recursive_mutex> assetLock(m_assetMutex);
|
||||
if (data)
|
||||
|
||||
@@ -358,7 +358,7 @@ namespace AZ
|
||||
|
||||
Asset<AssetData> GetAssetInternal(const AssetId& assetId, const AssetType& assetType, AssetLoadBehavior assetReferenceLoadBehavior, const AssetLoadParameters& loadParams = AssetLoadParameters{}, AssetInfo assetInfo = AssetInfo(), bool signalLoaded = false);
|
||||
|
||||
void UpdateDebugStatus(AZ::Data::Asset<AZ::Data::AssetData> asset);
|
||||
void UpdateDebugStatus(const AZ::Data::Asset<AZ::Data::AssetData>& asset);
|
||||
|
||||
/**
|
||||
* Gets a root asset and dependencies as individual async loads if necessary.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
/** @file
|
||||
* Header file for the Component base class.
|
||||
* In Lumberyard's component entity system, each component defines a discrete
|
||||
* In Open 3D Engine's component entity system, each component defines a discrete
|
||||
* feature that can be attached to an entity.
|
||||
*/
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace AZ
|
||||
* practice to access other components through EBuses instead of accessing them directly.
|
||||
* For more information, see the
|
||||
* <a href="http://docs.aws.amazon.com/lumberyard/latest/developerguide/component-entity-system-pg-intro.html">Programmer's Guide to Entities and Components</a>
|
||||
* in the Lumberyard Developer Guide.
|
||||
* in the Open 3D Engine Developer Guide.
|
||||
* @return A pointer to the entity. If the component is not attached to any entity,
|
||||
* the return value is a null pointer.
|
||||
*/
|
||||
@@ -426,7 +426,7 @@ namespace AZ
|
||||
|
||||
/**
|
||||
* Describes the properties of the component descriptor event bus.
|
||||
* This bus uses AzTypeInfo::Uuid as the ID for the specific descriptor. Lumberyard allows only one
|
||||
* This bus uses AzTypeInfo::Uuid as the ID for the specific descriptor. Open 3D Engine allows only one
|
||||
* descriptor for each component type. When you call functions on the bus for a specific component
|
||||
* type, you can safely pass only one result variable because aggregating or overwriting results
|
||||
* is impossible.
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <AzCore/Memory/OverrunDetectionAllocator.h>
|
||||
#include <AzCore/Memory/AllocatorManager.h>
|
||||
#include <AzCore/Memory/MallocSchema.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/ObjectStream.h>
|
||||
@@ -174,78 +173,85 @@ namespace AZ
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
//! SettingsRegistry notifier handler which updates relevant registry settings based
|
||||
//! on an update to '/Amazon/AzCore/Bootstrap/project_path' key.
|
||||
struct UpdateProjectSettingsEventHandler
|
||||
{
|
||||
UpdateProjectSettingsEventHandler(AZ::SettingsRegistryInterface& registry)
|
||||
UpdateProjectSettingsEventHandler(AZ::SettingsRegistryInterface& registry, AZ::CommandLine& commandLine)
|
||||
: m_registry{ registry }
|
||||
, m_commandLine{ commandLine }
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(AZStd::string_view path, AZ::SettingsRegistryInterface::Type)
|
||||
{
|
||||
UpdateProjectSpecializationInRegistry(path);
|
||||
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
|
||||
// #1 Update the project settings when the project path is set
|
||||
const auto projectPathKey = FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path";
|
||||
AZ::IO::FixedMaxPath newProjectPath;
|
||||
if (SettingsRegistryMergeUtils::IsPathAncestorDescendantOrEqual(projectPathKey, path)
|
||||
&& m_registry.Get(newProjectPath.Native(), projectPathKey) && newProjectPath != m_oldProjectPath)
|
||||
{
|
||||
UpdateProjectSettingsFromProjectPath(AZ::IO::PathView(newProjectPath));
|
||||
}
|
||||
|
||||
// #2 Update the project specialization when the project name is set
|
||||
const auto projectNameKey = FixedValueString(AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey) + "/project_name";
|
||||
FixedValueString newProjectName;
|
||||
if (SettingsRegistryMergeUtils::IsPathAncestorDescendantOrEqual(projectNameKey, path)
|
||||
&& m_registry.Get(newProjectName, projectNameKey) && newProjectName != m_oldProjectName)
|
||||
{
|
||||
UpdateProjectSpecializationFromProjectName(newProjectName);
|
||||
}
|
||||
|
||||
// #3 Update the ComponentApplication CommandLine instance when the command line settings are merged into the Settings Registry
|
||||
if (path == AZ::SettingsRegistryMergeUtils::CommandLineValueChangedKey)
|
||||
{
|
||||
UpdateCommandLine();
|
||||
}
|
||||
}
|
||||
|
||||
//! Add the project name as a specialization underneath the /Amazon/AzCore/Settings/Specializations path
|
||||
//! and remove the current project name specialization if one exists.
|
||||
void UpdateProjectSpecializationInRegistry(AZStd::string_view path)
|
||||
void UpdateProjectSpecializationFromProjectName(AZStd::string_view newProjectName)
|
||||
{
|
||||
auto projectPathKey =
|
||||
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey)
|
||||
+ "/project_path";
|
||||
if (path == projectPathKey)
|
||||
{
|
||||
AZ::SettingsRegistryInterface::FixedValueString newProjectPath;
|
||||
if (m_registry.Get(newProjectPath, path) && !newProjectPath.empty())
|
||||
{
|
||||
// Make the path absolute by appending to app root, in case project path is relative.
|
||||
// If the project path is already absolute it will remain the same.
|
||||
// If we turn it from a relative path to an absolute path, write-back the absolute path to the registry.
|
||||
AZ::IO::FixedMaxPath projectPath = AZ::SettingsRegistryMergeUtils::FindEngineRoot(m_registry) / newProjectPath;
|
||||
if (projectPath.Compare(newProjectPath.c_str()))
|
||||
{
|
||||
m_registry.Set(path, projectPath.Native());
|
||||
}
|
||||
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
|
||||
// Add the project_name as a specialization for loading the build system dependency .setreg files
|
||||
auto newProjectNameSpecialization = FixedValueString::format("%s/%.*s", AZ::SettingsRegistryMergeUtils::SpecializationsRootKey,
|
||||
aznumeric_cast<int>(newProjectName.size()), newProjectName.data());
|
||||
auto oldProjectNameSpecialization = FixedValueString::format("%s/%s", AZ::SettingsRegistryMergeUtils::SpecializationsRootKey,
|
||||
m_oldProjectName.c_str());
|
||||
m_registry.Remove(oldProjectNameSpecialization);
|
||||
m_oldProjectName = newProjectName;
|
||||
m_registry.Set(newProjectNameSpecialization, true);
|
||||
}
|
||||
|
||||
// Merge the project.json file into settings registry under ProjectSettingsRootKey path.
|
||||
AZ::IO::FixedMaxPath projectMetadataFile{ projectPath };
|
||||
projectMetadataFile /= "project.json";
|
||||
m_registry.MergeSettingsFile(projectMetadataFile.Native(),
|
||||
AZ::SettingsRegistryInterface::Format::JsonMergePatch, AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey);
|
||||
void UpdateProjectSettingsFromProjectPath(AZ::IO::PathView newProjectPath)
|
||||
{
|
||||
// Update old Project path before attempting to merge in new Settings Registry values in order to prevent recursive calls
|
||||
m_oldProjectPath = newProjectPath;
|
||||
|
||||
// Get the 'project_name' value from what was in the 'project.json' file...
|
||||
auto projectNameKey =
|
||||
AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey)
|
||||
+ "/project_name";
|
||||
// Merge the project.json file into settings registry under ProjectSettingsRootKey path.
|
||||
AZ::IO::FixedMaxPath projectMetadataFile{ AZ::SettingsRegistryMergeUtils::FindEngineRoot(m_registry) / newProjectPath };
|
||||
projectMetadataFile /= "project.json";
|
||||
m_registry.MergeSettingsFile(projectMetadataFile.Native(),
|
||||
AZ::SettingsRegistryInterface::Format::JsonMergePatch, AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey);
|
||||
|
||||
AZ::SettingsRegistryInterface::FixedValueString projectSpecialization;
|
||||
if (m_registry.Get(projectSpecialization, projectNameKey))
|
||||
{
|
||||
auto specializationKey = AZ::SettingsRegistryInterface::FixedValueString::format(
|
||||
"%s/%s", AZ::SettingsRegistryMergeUtils::SpecializationsRootKey, projectSpecialization.c_str());
|
||||
if (m_currentSpecialization != specializationKey)
|
||||
{
|
||||
m_registry.Set(specializationKey, true);
|
||||
if (!m_currentSpecialization.empty())
|
||||
{
|
||||
// Remove the previous Project Name from the specialization path if it was set.
|
||||
m_registry.Remove(m_currentSpecialization);
|
||||
}
|
||||
m_currentSpecialization = specializationKey;
|
||||
// Update all the runtime file paths based on the new "project_path" value.
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry);
|
||||
}
|
||||
|
||||
// Update all the runtime file paths based on the new "project_path" value.
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void UpdateCommandLine()
|
||||
{
|
||||
AZ::SettingsRegistryMergeUtils::GetCommandLineFromRegistry(m_registry, m_commandLine);
|
||||
}
|
||||
|
||||
private:
|
||||
AZ::SettingsRegistryInterface::FixedValueString m_currentSpecialization;
|
||||
AZ::IO::FixedMaxPath m_oldProjectPath;
|
||||
AZ::SettingsRegistryInterface::FixedValueString m_oldProjectName;
|
||||
AZ::SettingsRegistryInterface& m_registry;
|
||||
AZ::CommandLine& m_commandLine;
|
||||
};
|
||||
|
||||
void ComponentApplication::Descriptor::AllocatorRemapping::Reflect(ReflectContext* context, ComponentApplication* app)
|
||||
@@ -335,6 +341,16 @@ namespace AZ
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<ComponentApplicationBus>("ComponentApplicationBus")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Components")
|
||||
|
||||
->Event("GetEntityName", &ComponentApplicationBus::Events::GetEntityName)
|
||||
->Event("SetEntityName", &ComponentApplicationBus::Events::SetEntityName);
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -362,11 +378,20 @@ namespace AZ
|
||||
ComponentApplication::ComponentApplication()
|
||||
: ComponentApplication(0, nullptr)
|
||||
{
|
||||
if (Interface<ComponentApplicationRequests>::Get() == nullptr)
|
||||
{
|
||||
Interface<ComponentApplicationRequests>::Register(this);
|
||||
}
|
||||
}
|
||||
|
||||
ComponentApplication::ComponentApplication(int argC, char** argV)
|
||||
: m_eventLogger{}
|
||||
{
|
||||
if (Interface<ComponentApplicationRequests>::Get() == nullptr)
|
||||
{
|
||||
Interface<ComponentApplicationRequests>::Register(this);
|
||||
}
|
||||
|
||||
if (argV)
|
||||
{
|
||||
m_argC = argC;
|
||||
@@ -415,7 +440,13 @@ namespace AZ
|
||||
// Add the Command Line arguments into the SettingsRegistry
|
||||
SettingsRegistryMergeUtils::StoreCommandLineToRegistry(*m_settingsRegistry, m_commandLine);
|
||||
|
||||
// Merge Command Line arguments
|
||||
// Add a notifier to update the project_settings when
|
||||
// 1. The 'project_path' key changes
|
||||
// 2. The project specialization when the 'project-name' key changes
|
||||
// 3. The ComponentApplication command line when the command line is stored to the registry
|
||||
m_projectChangedHandler = m_settingsRegistry->RegisterNotifier(UpdateProjectSettingsEventHandler{ *m_settingsRegistry, m_commandLine });
|
||||
|
||||
// Merge Command Line arguments
|
||||
constexpr bool executeRegDumpCommands = false;
|
||||
SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(*m_settingsRegistry, m_commandLine, executeRegDumpCommands);
|
||||
|
||||
@@ -429,10 +460,6 @@ namespace AZ
|
||||
// for the application root.
|
||||
CalculateAppRoot();
|
||||
|
||||
// Add a notifier to update the /Amazon/AzCore/Settings/Specializations
|
||||
// when the 'project_path' property changes within the SettingsRegistry
|
||||
m_projectChangedHandler = m_settingsRegistry->RegisterNotifier(UpdateProjectSettingsEventHandler{ *m_settingsRegistry });
|
||||
|
||||
// Merge the bootstrap.cfg file into the Settings Registry as soon as the OSAllocator has been created.
|
||||
SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(*m_settingsRegistry);
|
||||
SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(*m_settingsRegistry, AZ_TRAIT_OS_PLATFORM_CODENAME, {});
|
||||
@@ -462,6 +489,11 @@ namespace AZ
|
||||
//=========================================================================
|
||||
ComponentApplication::~ComponentApplication()
|
||||
{
|
||||
if (Interface<ComponentApplicationRequests>::Get() == this)
|
||||
{
|
||||
Interface<ComponentApplicationRequests>::Unregister(this);
|
||||
}
|
||||
|
||||
if (m_isStarted)
|
||||
{
|
||||
Destroy();
|
||||
@@ -495,8 +527,7 @@ namespace AZ
|
||||
DestroyAllocator();
|
||||
}
|
||||
|
||||
Entity* ComponentApplication::Create(const Descriptor& descriptor,
|
||||
const StartupParameters& startupParameters)
|
||||
Entity* ComponentApplication::Create(const Descriptor& descriptor, const StartupParameters& startupParameters)
|
||||
{
|
||||
AZ_Assert(!m_isStarted, "Component application already started!");
|
||||
|
||||
@@ -905,6 +936,8 @@ namespace AZ
|
||||
SettingsRegistryMergeUtils::MergeSettingsToRegistry_ProjectUserRegistry(registry, AZ_TRAIT_OS_PLATFORM_CODENAME, specializations, &scratchBuffer);
|
||||
SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(registry, m_commandLine, true);
|
||||
#endif
|
||||
// Update the Runtime file paths in case the "{BootstrapSettingsRootKey}/assets" key was overriden by a setting registry
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(registry);
|
||||
}
|
||||
|
||||
void ComponentApplication::SetSettingsRegistrySpecializations(SettingsRegistryInterface::Specializations& specializations)
|
||||
@@ -943,6 +976,16 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentApplication::RegisterEntityAddedEventHandler(EntityAddedEvent::Handler& handler)
|
||||
{
|
||||
handler.Connect(m_entityAddedEvent);
|
||||
}
|
||||
|
||||
void ComponentApplication::RegisterEntityRemovedEventHandler(EntityRemovedEvent::Handler& handler)
|
||||
{
|
||||
handler.Connect(m_entityRemovedEvent);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// AddEntity
|
||||
// [5/30/2012]
|
||||
@@ -954,7 +997,7 @@ namespace AZ
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_entityAddedEvent.Signal(entity);
|
||||
return m_entities.insert(AZStd::make_pair(entity->GetId(), entity)).second;
|
||||
}
|
||||
|
||||
@@ -969,7 +1012,7 @@ namespace AZ
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_entityRemovedEvent.Signal(entity);
|
||||
return (m_entities.erase(entity->GetId()) == 1);
|
||||
}
|
||||
|
||||
@@ -982,6 +1025,7 @@ namespace AZ
|
||||
Entity* entity = FindEntity(id);
|
||||
if (entity)
|
||||
{
|
||||
m_entityRemovedEvent.Signal(entity);
|
||||
delete entity;
|
||||
return true;
|
||||
}
|
||||
@@ -1016,6 +1060,20 @@ namespace AZ
|
||||
return AZStd::string();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// SetEntityName
|
||||
//=========================================================================
|
||||
bool ComponentApplication::SetEntityName(const EntityId& id, const AZStd::string_view name)
|
||||
{
|
||||
Entity* entity = FindEntity(id);
|
||||
if (entity)
|
||||
{
|
||||
entity->SetName(name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// EnumerateEntities
|
||||
//=========================================================================
|
||||
@@ -1371,10 +1429,7 @@ namespace AZ
|
||||
//=========================================================================
|
||||
void ComponentApplication::CalculateExecutablePath()
|
||||
{
|
||||
Utils::GetExecutableDirectory(m_exeDirectory.data(), m_exeDirectory.capacity());
|
||||
// Update the size value of the executable directory fixed string to correctly be the length of the null-terminated string stored within it
|
||||
m_exeDirectory.resize_no_construct(AZStd::char_traits<char>::length(m_exeDirectory.data()));
|
||||
m_exeDirectory.push_back(AZ_CORRECT_FILESYSTEM_SEPARATOR);
|
||||
m_exeDirectory = Utils::GetExecutableDirectory();
|
||||
}
|
||||
|
||||
void ComponentApplication::CalculateAppRoot()
|
||||
@@ -1382,19 +1437,12 @@ namespace AZ
|
||||
if (AZStd::optional<AZ::StringFunc::Path::FixedString> appRootPath = Utils::GetDefaultAppRootPath(); appRootPath)
|
||||
{
|
||||
m_appRoot = AZStd::move(*appRootPath);
|
||||
if (!m_appRoot.empty() && !m_appRoot.ends_with(AZ_CORRECT_FILESYSTEM_SEPARATOR))
|
||||
{
|
||||
m_appRoot.push_back(AZ_CORRECT_FILESYSTEM_SEPARATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentApplication::CalculateEngineRoot()
|
||||
{
|
||||
if (m_engineRoot = AZ::SettingsRegistryMergeUtils::FindEngineRoot(*m_settingsRegistry).Native(); !m_engineRoot.empty())
|
||||
{
|
||||
m_engineRoot.push_back(AZ_CORRECT_FILESYSTEM_SEPARATOR);
|
||||
}
|
||||
m_engineRoot = AZ::SettingsRegistryMergeUtils::FindEngineRoot(*m_settingsRegistry).Native();
|
||||
}
|
||||
|
||||
void ComponentApplication::ResolveModulePath([[maybe_unused]] AZ::OSString& modulePath)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <AzCore/Module/DynamicModuleHandle.h>
|
||||
#include <AzCore/Module/ModuleManager.h>
|
||||
#include <AzCore/Outcome/Outcome.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/RTTI/ReflectionManager.h>
|
||||
@@ -193,8 +194,7 @@ namespace AZ
|
||||
* You will need to setup all system components manually.
|
||||
* \returns pointer to the system entity.
|
||||
*/
|
||||
virtual Entity* Create(const Descriptor& descriptor,
|
||||
const StartupParameters& startupParameters = StartupParameters());
|
||||
virtual Entity* Create(const Descriptor& descriptor, const StartupParameters& startupParameters = StartupParameters());
|
||||
virtual void Destroy();
|
||||
virtual void DestroyAllocator(); // Called at the end of Destroy(). Applications can override to do tear down work right before allocator is destroyed.
|
||||
|
||||
@@ -202,11 +202,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;
|
||||
bool AddEntity(Entity* entity) override;
|
||||
bool RemoveEntity(Entity* entity) override;
|
||||
bool DeleteEntity(const EntityId& id) override;
|
||||
Entity* FindEntity(const EntityId& id) override;
|
||||
AZStd::string GetEntityName(const EntityId& id) override;
|
||||
bool SetEntityName(const EntityId& id, const AZStd::string_view name) override;
|
||||
void EnumerateEntities(const ComponentApplicationRequests::EntityCallback& callback) override;
|
||||
ComponentApplication* GetApplication() override { return this; }
|
||||
/// Returns the serialize context that has been registered with the app, if there is one.
|
||||
@@ -380,6 +383,8 @@ namespace AZ
|
||||
float m_deltaTime{ 0.0f };
|
||||
AZStd::unique_ptr<ModuleManager> m_moduleManager;
|
||||
AZStd::unique_ptr<SettingsRegistryInterface> m_settingsRegistry;
|
||||
EntityAddedEvent m_entityAddedEvent;
|
||||
EntityRemovedEvent m_entityRemovedEvent;
|
||||
AZ::IConsole* m_console{};
|
||||
Descriptor m_descriptor;
|
||||
bool m_isStarted{ false };
|
||||
@@ -389,9 +394,9 @@ namespace AZ
|
||||
void* m_fixedMemoryBlock{ nullptr }; //!< Pointer to the memory block allocator, so we can free it OnDestroy.
|
||||
IAllocatorAllocate* m_osAllocator{ nullptr };
|
||||
EntitySetType m_entities;
|
||||
AZ::IO::FixedMaxPathString m_exeDirectory;
|
||||
AZ::IO::FixedMaxPathString m_engineRoot;
|
||||
AZ::IO::FixedMaxPathString m_appRoot;
|
||||
AZ::IO::FixedMaxPath m_exeDirectory;
|
||||
AZ::IO::FixedMaxPath m_engineRoot;
|
||||
AZ::IO::FixedMaxPath m_appRoot;
|
||||
|
||||
AZ::SettingsRegistryInterface::NotifyEventHandler m_projectChangedHandler;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/EBus/Event.h>
|
||||
#include <AzCore/Component/EntityId.h>
|
||||
#include <AzCore/std/parallel/mutex.h>
|
||||
#include <AzCore/std/string/osstring.h>
|
||||
@@ -69,160 +70,144 @@ namespace AZ
|
||||
inline bool ApplicationTypeQuery::IsGame() const { return (m_maskValue & Masks::Game) == Masks::Game; }
|
||||
inline bool ApplicationTypeQuery::IsValid() const { return m_maskValue != Masks::Invalid; }
|
||||
|
||||
/**
|
||||
* Event bus that components use to make requests of the main application.
|
||||
* Only one application can exist at a time, which is why this bus
|
||||
* supports only one listener.
|
||||
*/
|
||||
using EntityAddedEvent = AZ::Event<AZ::Entity*>;
|
||||
using EntityRemovedEvent = AZ::Event<AZ::Entity*>;
|
||||
|
||||
//! Interface that components can use to make requests of the main application.
|
||||
class ComponentApplicationRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ComponentApplicationRequests, "{E8BE41B7-615F-4FE8-B611-8A9E441290A8}");
|
||||
|
||||
/**
|
||||
* Destroys the event bus that components use to make requests of the main application.
|
||||
*/
|
||||
virtual ~ComponentApplicationRequests() {}
|
||||
//! Destroys the event bus that components use to make requests of the main application.
|
||||
virtual ~ComponentApplicationRequests() = default;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides - application is a singleton
|
||||
/**
|
||||
* Overrides the default AZ::EBusTraits handler policy to allow one
|
||||
* listener only, because only one application can exist at a time.
|
||||
*/
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single; // We sort components on m_initOrder.
|
||||
/**
|
||||
* Overrides the default AZ::EBusTraits mutex type to the AZStd implementation of
|
||||
* a recursive mutex with exclusive ownership semantics. A mutex prevents multiple
|
||||
* threads from accessing shared data simultaneously.
|
||||
*/
|
||||
typedef AZStd::recursive_mutex MutexType;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Registers a component descriptor with the application.
|
||||
* @param descriptor A component descriptor.
|
||||
*/
|
||||
//! Registers a component descriptor with the application.
|
||||
//! @param descriptor A component descriptor.
|
||||
virtual void RegisterComponentDescriptor(const ComponentDescriptor* descriptor) = 0;
|
||||
/**
|
||||
* Unregisters a component descriptor with the application.
|
||||
* @param descriptor A component descriptor.
|
||||
*/
|
||||
|
||||
//! Unregisters a component descriptor with the application.
|
||||
//! @param descriptor A component descriptor.
|
||||
virtual void UnregisterComponentDescriptor(const ComponentDescriptor* descriptor) = 0;
|
||||
/**
|
||||
* Gets a pointer to the application.
|
||||
* @return A pointer to the application.
|
||||
*/
|
||||
virtual ComponentApplication* GetApplication() = 0;
|
||||
|
||||
/**
|
||||
* Adds an entity to the application's registry.
|
||||
* Calling Init() on an entity automatically performs this operation.
|
||||
* @param entity A pointer to the entity to add to the application's registry.
|
||||
* @return True if the operation succeeded. False if the operation failed.
|
||||
*/
|
||||
virtual bool AddEntity(Entity* entity) = 0;
|
||||
/**
|
||||
* Removes the specified entity from the application's registry.
|
||||
* Deleting an entity automatically performs this operation.
|
||||
* @param entity A pointer to the entity that will be removed from the application's registry.
|
||||
* @return True if the operation succeeded. False if the operation failed.
|
||||
*/
|
||||
virtual bool RemoveEntity(Entity* entity) = 0;
|
||||
/**
|
||||
* Unregisters and deletes the specified entity.
|
||||
* @param entity A reference to the entity that will be unregistered and deleted.
|
||||
* @return True if the operation succeeded. False if the operation failed.
|
||||
*/
|
||||
virtual bool DeleteEntity(const EntityId& id) = 0;
|
||||
/**
|
||||
* Returns the entity with the matching ID, if the entity is registered with the application.
|
||||
* @param entity A reference to the entity that you are searching for.
|
||||
* @return A pointer to the entity with the specified entity ID.
|
||||
*/
|
||||
virtual Entity* FindEntity(const EntityId& id) = 0;
|
||||
/**
|
||||
* Returns the name of the entity that has the specified entity ID.
|
||||
* Entity names are not unique.
|
||||
* This method exists to facilitate better debugging messages.
|
||||
* @param entity A reference to the entity whose name you are seeking.
|
||||
* @return The name of the entity with the specified entity ID.
|
||||
* If no entity is found for the specified ID, it returns an empty string.
|
||||
*/
|
||||
virtual AZStd::string GetEntityName(const EntityId& id) { (void)id; return AZStd::string(); };
|
||||
//! Gets a pointer to the application.
|
||||
//! @return A pointer to the application.
|
||||
virtual ComponentApplication* GetApplication() = 0;
|
||||
|
||||
/**
|
||||
* The type that AZ::ComponentApplicationRequests::EnumerateEntities uses to
|
||||
* pass entity callbacks to the application for enumeration.
|
||||
*/
|
||||
//! Registers an event handler that will be signalled whenever an entity is added.
|
||||
//! @param handler the event handler to signal.
|
||||
virtual void RegisterEntityAddedEventHandler(EntityAddedEvent::Handler& handler) = 0;
|
||||
|
||||
//! Registers an event handler that will be signalled whenever an entity is removed.
|
||||
//! @param handler the event handler to signal.
|
||||
virtual void RegisterEntityRemovedEventHandler(EntityRemovedEvent::Handler& handler) = 0;
|
||||
|
||||
//! Adds an entity to the application's registry.
|
||||
//! Calling Init() on an entity automatically performs this operation.
|
||||
//! @param entity A pointer to the entity to add to the application's registry.
|
||||
//! @return True if the operation succeeded. False if the operation failed.
|
||||
virtual bool AddEntity(Entity* entity) = 0;
|
||||
|
||||
//! Removes the specified entity from the application's registry.
|
||||
//! Deleting an entity automatically performs this operation.
|
||||
//! @param entity A pointer to the entity that will be removed from the application's registry.
|
||||
//! @return True if the operation succeeded. False if the operation failed.
|
||||
virtual bool RemoveEntity(Entity* entity) = 0;
|
||||
|
||||
//! Unregisters and deletes the specified entity.
|
||||
//! @param entity A reference to the entity that will be unregistered and deleted.
|
||||
//! @return True if the operation succeeded. False if the operation failed.
|
||||
virtual bool DeleteEntity(const EntityId& id) = 0;
|
||||
|
||||
//! Returns the entity with the matching ID, if the entity is registered with the application.
|
||||
//! @param entity A reference to the entity that you are searching for.
|
||||
//! @return A pointer to the entity with the specified entity ID.
|
||||
virtual Entity* FindEntity(const EntityId& id) = 0;
|
||||
|
||||
//! Returns the name of the entity that has the specified entity ID.
|
||||
//! Entity names are not unique.
|
||||
//! This method exists to facilitate better debugging messages.
|
||||
//! @param entity A reference to the entity whose name you are seeking.
|
||||
//! @return The name of the entity with the specified entity ID.
|
||||
//! If no entity is found for the specified ID, it returns an empty string.
|
||||
virtual AZStd::string GetEntityName(const EntityId& id) { (void)id; return AZStd::string(); }
|
||||
|
||||
//! Sets the name of the entity that has the specified entity ID.
|
||||
//! Entity names are not enforced to be unique.
|
||||
//! @param entityId A reference to the entity whose name you want to change.
|
||||
//! @return True if the name was changed successfully, false if it wasn't.
|
||||
virtual bool SetEntityName([[maybe_unused]] const EntityId& id, [[maybe_unused]] const AZStd::string_view name) { return false; }
|
||||
|
||||
//! The type that AZ::ComponentApplicationRequests::EnumerateEntities uses to
|
||||
//! pass entity callbacks to the application for enumeration.
|
||||
using EntityCallback = AZStd::function<void(Entity*)>;
|
||||
/**
|
||||
* Enumerates all registered entities and invokes the specified callback for each entity.
|
||||
* @param callback A reference to the callback that is invoked for each entity.
|
||||
*/
|
||||
virtual void EnumerateEntities(const EntityCallback& callback) = 0;
|
||||
/**
|
||||
* Returns the serialize context that was registered with the app.
|
||||
* @return The serialize context, if there is one. SerializeContext is a class that contains reflection data
|
||||
* for serialization and construction of objects.
|
||||
*/
|
||||
|
||||
//! Enumerates all registered entities and invokes the specified callback for each entity.
|
||||
//! @param callback A reference to the callback that is invoked for each entity.
|
||||
virtual void EnumerateEntities(const EntityCallback& callback) = 0;
|
||||
|
||||
//! Returns the serialize context that was registered with the app.
|
||||
//! @return The serialize context, if there is one. SerializeContext is a class that contains reflection data
|
||||
//! for serialization and construction of objects.
|
||||
virtual class SerializeContext* GetSerializeContext() = 0;
|
||||
/**
|
||||
* Returns the behavior context that was registered with the app.
|
||||
* @return The behavior context, if there is one. BehaviorContext is a class that reflects classes, methods,
|
||||
* and EBuses for runtime interaction.
|
||||
*/
|
||||
|
||||
//! Returns the behavior context that was registered with the app.
|
||||
//! @return The behavior context, if there is one. BehaviorContext is a class that reflects classes, methods,
|
||||
//! and EBuses for runtime interaction.
|
||||
virtual class BehaviorContext* GetBehaviorContext() = 0;
|
||||
/**
|
||||
* Returns the Json Registration context that was registered with the app.
|
||||
* @return The Json Registration context, if there is one. JsonRegistrationContext is a class that contains
|
||||
* the serializers used by the best-effort json serialization.
|
||||
*/
|
||||
|
||||
//! Returns the Json Registration context that was registered with the app.
|
||||
//! @return The Json Registration context, if there is one. JsonRegistrationContext is a class that contains
|
||||
//! the serializers used by the best-effort json serialization.
|
||||
virtual class JsonRegistrationContext* GetJsonRegistrationContext() = 0;
|
||||
/**
|
||||
* Gets the name of the working root folder that was registered with the app.
|
||||
* @return A pointer to the name of the app's root folder, if a root folder was registered.
|
||||
*/
|
||||
virtual const char* GetAppRoot() const = 0;
|
||||
/**
|
||||
* Gets the path of the working engine folder that the app is a part of.
|
||||
* @return A pointer to the engine path.
|
||||
*/
|
||||
virtual const char* GetEngineRoot() const = 0;
|
||||
/**
|
||||
* Gets the path to the directory that contains the application's executable.
|
||||
* @return A pointer to the name of the path that contains the application's executable.
|
||||
*/
|
||||
virtual const char* GetExecutableFolder() const = 0;
|
||||
|
||||
/**
|
||||
* Returns a pointer to the driller manager, if driller is enabled.
|
||||
* The driller manager manages all active driller sessions and driller factories.
|
||||
* @return A pointer to the driller manager. If driller is not enabled,
|
||||
* this function returns null.
|
||||
*/
|
||||
virtual Debug::DrillerManager* GetDrillerManager() = 0;
|
||||
//! Gets the name of the working root folder that was registered with the app.
|
||||
//! @return a pointer to the name of the app's root folder, if a root folder was registered.
|
||||
virtual const char* GetAppRoot() const = 0;
|
||||
|
||||
/**
|
||||
* ResolveModulePath is called whenever LoadDynamicModule wants to resolve a module in order to actually load it.
|
||||
* You can override this if you need to load modules from a different path or hijack module loading in some other way.
|
||||
* If you do, ensure that you use platform-specific conventions to do so, as this is called by multiple platforms.
|
||||
* The default implantation prepends the path to the executable to the module path, but you can override this behavior
|
||||
* (Call the base class if you want this behavior to persist in overrides)
|
||||
*/
|
||||
virtual void ResolveModulePath(AZ::OSString& /*modulePath*/) { }
|
||||
//! Gets the path of the working engine folder that the app is a part of.
|
||||
//! @return a pointer to the engine path.
|
||||
virtual const char* GetEngineRoot() const = 0;
|
||||
|
||||
/**
|
||||
* Returns AZ parsed command line structure.
|
||||
* Command Line structure can be queried for switches (-<switch> /<switch>) or positional parameter (<value>)
|
||||
*/
|
||||
//! Gets the path to the directory that contains the application's executable.
|
||||
//! @return a pointer to the name of the path that contains the application's executable.
|
||||
virtual const char* GetExecutableFolder() const = 0;
|
||||
|
||||
//! Returns a pointer to the driller manager, if driller is enabled.
|
||||
//! The driller manager manages all active driller sessions and driller factories.
|
||||
//! @return A pointer to the driller manager. If driller is not enabled, this function returns null.
|
||||
virtual Debug::DrillerManager* GetDrillerManager() = 0;
|
||||
|
||||
//! ResolveModulePath is called whenever LoadDynamicModule wants to resolve a module in order to actually load it.
|
||||
//! You can override this if you need to load modules from a different path or hijack module loading in some other way.
|
||||
//! If you do, ensure that you use platform-specific conventions to do so, as this is called by multiple platforms.
|
||||
//! The default implantation prepends the path to the executable to the module path, but you can override this behavior
|
||||
//! (Call the base class if you want this behavior to persist in overrides)
|
||||
virtual void ResolveModulePath([[maybe_unused]] AZ::OSString& modulePath) { }
|
||||
|
||||
//! Returns AZ parsed command line structure.
|
||||
//! Command Line structure can be queried for switches (-<switch> /<switch>) or positional parameter (<value>)
|
||||
virtual AZ::CommandLine* GetAzCommandLine() { return{}; }
|
||||
|
||||
//! Returns all the flags that are true for the current application.
|
||||
virtual void QueryApplicationType(ApplicationTypeQuery& appType) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used by components to make requests of the component application.
|
||||
*/
|
||||
typedef AZ::EBus<ComponentApplicationRequests> ComponentApplicationBus;
|
||||
class ComponentApplicationRequestsEBusTraits
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//! EBusTraits overrides - application is a singleton
|
||||
//! Overrides the default AZ::EBusTraits handler policy to allow one
|
||||
//! listener only, because only one application can exist at a time.
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single; // We sort components on m_initOrder.
|
||||
|
||||
//! Overrides the default AZ::EBusTraits mutex type to the AZStd implementation of
|
||||
//! a recursive mutex with exclusive ownership semantics. A mutex prevents multiple
|
||||
//! threads from accessing shared data simultaneously.
|
||||
using MutexType = AZStd::recursive_mutex;
|
||||
};
|
||||
|
||||
//! Used by components to make requests of the component application.
|
||||
using ComponentApplicationBus = AZ::EBus<ComponentApplicationRequests, ComponentApplicationRequestsEBusTraits>;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/Component/NamedEntityId.h>
|
||||
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Casting/lossy_cast.h>
|
||||
|
||||
#include <AzCore/Serialization/Json/RegistrationContext.h>
|
||||
@@ -159,10 +159,11 @@ namespace AZ
|
||||
AZ_Assert(m_state == State::Constructed, "Component should be in Constructed state to be Initialized!");
|
||||
SetState(State::Initializing);
|
||||
|
||||
bool result = true;
|
||||
EBUS_EVENT_RESULT(result, ComponentApplicationBus, AddEntity, this);
|
||||
(void)result;
|
||||
AZ_Assert(result, "Failed to add entity '%s' [0x%llx]! Did you already register an entity with this ID?", m_name.c_str(), m_id);
|
||||
if (AZ::Interface<ComponentApplicationRequests>::Get() != nullptr)
|
||||
{
|
||||
[[maybe_unused]] const bool result = AZ::Interface<ComponentApplicationRequests>::Get()->AddEntity(this);
|
||||
AZ_Assert(result, "Failed to add entity '%s' [0x%llx]! Did you already register an entity with this ID?", m_name.c_str(), m_id);
|
||||
}
|
||||
|
||||
for (ComponentArrayType::iterator it = m_components.begin(); it != m_components.end();)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
/** @file
|
||||
* Header file for the Entity class.
|
||||
* In Lumberyard's component entity system, an entity is an addressable container for
|
||||
* In Open 3D Engine's component entity system, an entity is an addressable container for
|
||||
* a group of components. The entity represents the functionality and properties of an
|
||||
* object within your game.
|
||||
*/
|
||||
|
||||
@@ -40,10 +40,26 @@ namespace AZ
|
||||
(*idMapper)->SetIsEntityReference(false);
|
||||
}
|
||||
|
||||
JSR::ResultCode idLoadResult =
|
||||
ContinueLoadingFromJsonObjectField(&entityInstance->m_id,
|
||||
azrtti_typeid<decltype(entityInstance->m_id)>(),
|
||||
inputValue, "Id", context);
|
||||
JSR::ResultCode idLoadResult = ContinueLoadingFromJsonObjectField(
|
||||
&entityInstance->m_id, azrtti_typeid<decltype(entityInstance->m_id)>(), inputValue, "Id", context);
|
||||
|
||||
// If the entity has an invalid ID, there's no point in deserializing, the entity will be unusable.
|
||||
// It's also dangerous to generate new IDs here:
|
||||
// - They need to be globally unique
|
||||
// - We don't know *why* it's invalid (maybe just a typo on the name "Id" for example), so we don't know the ramifications
|
||||
// of changing it. There might be many other entities that have references to this one that would become invalid as well
|
||||
// if we try to silently fix it up.
|
||||
// - Unless we save the ID immediately, it will change every time we serialize the data in, which can happen multiple times
|
||||
// during the serialization pipeline. So it either needs to be saved back immediately, or we need a deterministic way
|
||||
// to generate a globally unique ID for the entity.
|
||||
if (!entityInstance->GetId().IsValid())
|
||||
{
|
||||
// Since we're going to halt processing anyways, we just return the error here immediately.
|
||||
return context.Report(
|
||||
JSR::ResultCode(JSR::Tasks::ReadField, JSR::Outcomes::Invalid),
|
||||
"Invalid or missing entity ID - please add an 'Id' field to this entity with a globally unique id. \n"
|
||||
"Failed to load entity information.");
|
||||
}
|
||||
|
||||
if (hasValidIdMapper)
|
||||
{
|
||||
@@ -93,9 +109,10 @@ namespace AZ
|
||||
inputValue, "IsRuntimeActive", context);
|
||||
}
|
||||
|
||||
return context.Report(result,
|
||||
result.GetProcessing() == JSR::Processing::Halted ? "Succesfully loaded entity information." :
|
||||
"Failed to load entity information.");
|
||||
return context.Report(
|
||||
result,
|
||||
result.GetProcessing() != JSR::Processing::Halted ? "Succesfully loaded entity information."
|
||||
: "Failed to load entity information.");
|
||||
}
|
||||
|
||||
JsonSerializationResult::Result JsonEntitySerializer::Store(rapidjson::Value& outputValue,
|
||||
@@ -199,7 +216,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
return context.Report(result,
|
||||
result.GetProcessing() == JSR::Processing::Halted ? "Successfully stored Entity information." :
|
||||
result.GetProcessing() != JSR::Processing::Halted ? "Successfully stored Entity information." :
|
||||
"Failed to store Entity information.");
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@ namespace AZ
|
||||
{
|
||||
class Vector3;
|
||||
|
||||
//! Do not allow the scale to be zero to avoid problems with inverting scale.
|
||||
static constexpr float MinNonUniformScale = 1e-3f;
|
||||
|
||||
using NonUniformScaleChangedEvent = AZ::Event<const AZ::Vector3&>;
|
||||
|
||||
//! Requests for working with non-uniform scale.
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace AZ
|
||||
{
|
||||
class Transform;
|
||||
|
||||
using TransformChangedEvent = Event<Transform, Transform>;
|
||||
using TransformChangedEvent = Event<const Transform&, const Transform&>;
|
||||
|
||||
using ParentChangedEvent = Event<EntityId, EntityId>;
|
||||
|
||||
|
||||
@@ -42,9 +42,8 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
#define AZ_TRACE_METHOD_NAME_CATEGORY(name, category) AZ::Debug::EventTrace::ScopedSlice AZ_JOIN(ScopedSlice__, __LINE__)(name, category);
|
||||
|
||||
#ifdef AZ_PROFILE_TELEMETRY
|
||||
# define AZ_TRACE_METHOD_NAME_CATEGORY(name, category) AZ::Debug::EventTrace::ScopedSlice AZ_JOIN(ScopedSlice__, __LINE__)(name, category);
|
||||
# define AZ_TRACE_METHOD_NAME(name) \
|
||||
AZ_TRACE_METHOD_NAME_CATEGORY(name, "") \
|
||||
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzTrace, name)
|
||||
@@ -53,6 +52,7 @@ namespace AZ
|
||||
AZ_TRACE_METHOD_NAME_CATEGORY(AZ_FUNCTION_SIGNATURE, "") \
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzTrace)
|
||||
#else
|
||||
# define AZ_TRACE_METHOD_NAME_CATEGORY(name, category)
|
||||
# define AZ_TRACE_METHOD_NAME(name) AZ_TRACE_METHOD_NAME_CATEGORY(name, "")
|
||||
# define AZ_TRACE_METHOD() AZ_TRACE_METHOD_NAME(AZ_FUNCTION_SIGNATURE)
|
||||
#endif
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace AZ
|
||||
static const char* logVerbosityUID = "sys_LogLevel";
|
||||
static const int assertLevel_log = 1;
|
||||
static const int assertLevel_nativeUI = 2;
|
||||
static const int assertLevel_crash = 3;
|
||||
static const int logLevel_errorWarning = 1;
|
||||
static const int logLevel_full = 2;
|
||||
static AZ::EnvironmentVariable<AZStd::unordered_set<size_t>> g_ignoredAsserts;
|
||||
@@ -289,8 +290,8 @@ namespace AZ
|
||||
}
|
||||
|
||||
#if AZ_ENABLE_TRACE_ASSERTS
|
||||
//display native UI dialogs at verbosity level 2 or higher
|
||||
if (currentLevel >= assertLevel_nativeUI)
|
||||
//display native UI dialogs at verbosity level 2
|
||||
if (currentLevel == assertLevel_nativeUI)
|
||||
{
|
||||
AZ::NativeUI::AssertAction buttonResult;
|
||||
EBUS_EVENT_RESULT(buttonResult, AZ::NativeUI::NativeUIRequestBus, DisplayAssertDialog, dialogBoxText);
|
||||
@@ -314,7 +315,13 @@ namespace AZ
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif //AZ_ENABLE_TRACE_ASSERTS
|
||||
// Crash the application directly at assert level 3
|
||||
if (currentLevel >= assertLevel_crash)
|
||||
{
|
||||
AZ_Crash();
|
||||
}
|
||||
}
|
||||
g_alreadyHandlingAssertOrFatal = false;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* Header file for internal EBus classes.
|
||||
* For more information about EBuses, see AZ::EBus and AZ::EBusTraits in this guide and
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* in the *Lumberyard Developer Guide*.
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
/**
|
||||
* @file
|
||||
* Header file for event bus (EBus), a general-purpose communication system
|
||||
* that Lumberyard uses to dispatch notifications and receive requests.
|
||||
* that Open 3D Engine uses to dispatch notifications and receive requests.
|
||||
* EBuses are configurable and support many different use cases.
|
||||
* For more information about %EBuses, see AZ::EBus in this guide and
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* in the *Lumberyard Developer Guide*.
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -70,7 +70,7 @@ namespace AZ
|
||||
*
|
||||
* For more information about %EBuses, see EBus in this guide and
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* in the *Lumberyard Developer Guide*.
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*/
|
||||
struct EBusTraits
|
||||
{
|
||||
@@ -256,7 +256,7 @@ namespace AZ
|
||||
|
||||
/**
|
||||
* Event buses (EBuses) are a general-purpose communication system
|
||||
* that Lumberyard uses to dispatch notifications and receive requests.
|
||||
* that Open 3D Engine uses to dispatch notifications and receive requests.
|
||||
*
|
||||
* @tparam Interface A class whose virtual functions define the events
|
||||
* dispatched or received by the %EBus.
|
||||
@@ -268,7 +268,7 @@ namespace AZ
|
||||
* For more information about EBuses, see
|
||||
* [Event Bus](http://docs.aws.amazon.com/lumberyard/latest/developerguide/asset-pipeline-ebus.html)
|
||||
* and [Components and EBuses: Best Practices ](http://docs.aws.amazon.com/lumberyard/latest/developerguide/component-entity-system-pg-components-ebuses-best-practices.html)
|
||||
* in the *Lumberyard Developer Guide*.
|
||||
* in the *Open 3D Engine Developer Guide*.
|
||||
*
|
||||
* ## How Components Use EBuses
|
||||
* Components commonly use EBuses in two ways: to dispatch events or to handle requests.
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/EBus/EventSchedulerSystemComponent.h>
|
||||
#include <AzCore/EBus/ScheduledEvent.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Console/ILogger.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
@@ -111,8 +110,10 @@ namespace AZ
|
||||
TimeMs currentMilliseconds = GetElapsedTimeMs();
|
||||
if (timedEvent->m_handle == nullptr)
|
||||
{
|
||||
timedEvent->m_handle = AllocateHandle(TimeMs(currentMilliseconds + durationMs), durationMs, timedEvent);
|
||||
timedEvent->m_handle = AllocateHandle();
|
||||
}
|
||||
const bool ownsScheduledEvent = false;
|
||||
*(timedEvent->m_handle) = ScheduledEventHandle(TimeMs(currentMilliseconds + durationMs), durationMs, timedEvent, ownsScheduledEvent);
|
||||
timedEvent->m_timeInserted = currentMilliseconds;
|
||||
m_queue.push(timedEvent->m_handle);
|
||||
return timedEvent->m_handle;
|
||||
@@ -126,7 +127,9 @@ namespace AZ
|
||||
}
|
||||
|
||||
TimeMs currentMilliseconds = GetElapsedTimeMs();
|
||||
ScheduledEvent* timedEvent = AllocateManagedEvent(TimeMs(currentMilliseconds + durationMs), durationMs, callback, eventName);
|
||||
ScheduledEvent* timedEvent = AllocateManagedEvent(callback, eventName);
|
||||
const bool ownsScheduledEvent = true;
|
||||
*(timedEvent->m_handle) = ScheduledEventHandle(TimeMs(currentMilliseconds + durationMs), durationMs, timedEvent, ownsScheduledEvent);
|
||||
timedEvent->m_timeInserted = currentMilliseconds;
|
||||
m_queue.push(timedEvent->m_handle);
|
||||
}
|
||||
@@ -150,10 +153,12 @@ namespace AZ
|
||||
{
|
||||
AZLOG_INFO("EventSchedulerSystemComponent::HandleCount = %u", aznumeric_cast<uint32_t>(GetHandleCount()));
|
||||
AZLOG_INFO("EventSchedulerSystemComponent::FreeHandleCount = %u", aznumeric_cast<uint32_t>(GetFreeHandleCount()));
|
||||
AZLOG_INFO("EventSchedulerSystemComponent::OwnedEventCount = %u", aznumeric_cast<uint32_t>(m_ownedEvents.size()));
|
||||
AZLOG_INFO("EventSchedulerSystemComponent::FreeEventCount = %u", aznumeric_cast<uint32_t>(m_freeEvents.size()));
|
||||
AZLOG_INFO("EventSchedulerSystemComponent::QueueSize = %u", aznumeric_cast<uint32_t>(GetQueueSize()));
|
||||
}
|
||||
|
||||
ScheduledEventHandle* EventSchedulerSystemComponent::AllocateHandle(TimeMs executeTimeMs, TimeMs durationTimeMs, ScheduledEvent* scheduledEvent)
|
||||
ScheduledEventHandle* EventSchedulerSystemComponent::AllocateHandle()
|
||||
{
|
||||
ScheduledEventHandle* result = nullptr;
|
||||
if (!m_freeHandles.empty())
|
||||
@@ -166,31 +171,34 @@ namespace AZ
|
||||
m_handles.resize(m_handles.size() + 1);
|
||||
result = &(m_handles.back());
|
||||
}
|
||||
*result = ScheduledEventHandle(executeTimeMs, durationTimeMs, scheduledEvent, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
ScheduledEvent* EventSchedulerSystemComponent::AllocateManagedEvent(TimeMs executeTimeMs, TimeMs durationTimeMs, const AZStd::function<void()>& callback, const Name& eventName)
|
||||
ScheduledEvent* EventSchedulerSystemComponent::AllocateManagedEvent(const AZStd::function<void()>& callback, const Name& eventName)
|
||||
{
|
||||
ScheduledEvent* result = new ScheduledEvent(callback, eventName);
|
||||
ScheduledEventHandle* handle = nullptr;
|
||||
if (!m_freeHandles.empty())
|
||||
ScheduledEvent* scheduledEvent = nullptr;
|
||||
if (!m_freeEvents.empty())
|
||||
{
|
||||
handle = m_freeHandles.back();
|
||||
m_freeHandles.pop_back();
|
||||
scheduledEvent = m_freeEvents.back();
|
||||
m_freeEvents.pop_back();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_handles.resize(m_handles.size() + 1);
|
||||
handle = &(m_handles.back());
|
||||
m_ownedEvents.resize(m_ownedEvents.size() + 1);
|
||||
scheduledEvent = &(m_ownedEvents.back());
|
||||
}
|
||||
*handle = ScheduledEventHandle(executeTimeMs, durationTimeMs, result, true);
|
||||
result->m_handle = handle;
|
||||
return result;
|
||||
scheduledEvent->m_eventName = eventName;
|
||||
scheduledEvent->m_callback = callback;
|
||||
scheduledEvent->m_handle = AllocateHandle();
|
||||
return scheduledEvent;
|
||||
}
|
||||
|
||||
void EventSchedulerSystemComponent::FreeHandle(ScheduledEventHandle* handle)
|
||||
{
|
||||
if (handle->GetOwnsScheduledEvent())
|
||||
{
|
||||
m_freeEvents.push_back(handle->GetScheduledEvent());
|
||||
}
|
||||
m_freeHandles.push_back(handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/EBus/ScheduledEventHandle.h>
|
||||
#include <AzCore/EBus/ScheduledEvent.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/containers/queue.h>
|
||||
@@ -89,9 +90,11 @@ namespace AZ
|
||||
//! @}
|
||||
|
||||
private:
|
||||
ScheduledEventHandle* AllocateHandle(TimeMs executeTimeMs, TimeMs durationTimeMs, ScheduledEvent* scheduledEvent);
|
||||
// Allocates a single use event to capture the passed in callback. Event is cleaned up on completion.
|
||||
ScheduledEvent* AllocateManagedEvent(TimeMs executeTimeMs, TimeMs durationTimeMs, const AZStd::function<void()>& callback, const Name& eventName);
|
||||
ScheduledEventHandle* AllocateHandle();
|
||||
|
||||
//! Allocates a single use event to capture the passed in callback. Event is cleaned up on completion.
|
||||
ScheduledEvent* AllocateManagedEvent(const AZStd::function<void()>& callback, const Name& eventName);
|
||||
|
||||
void FreeHandle(ScheduledEventHandle* handle);
|
||||
|
||||
// Bind the DumpStats member function to the console as 'EventSchedulerSystemComponent.DumpStats'
|
||||
@@ -100,6 +103,8 @@ namespace AZ
|
||||
// Priority queues of scheduled events sorted by execution time
|
||||
AZStd::priority_queue<ScheduledEventHandle*, AZStd::vector<ScheduledEventHandle*>, CompareScheduledEventPtrs> m_queue;
|
||||
AZStd::priority_queue<ScheduledEventHandle*, AZStd::vector<ScheduledEventHandle*>, PrioritizeScheduledEventPtrs> m_pendingQueue;
|
||||
AZStd::deque<ScheduledEvent> m_ownedEvents;
|
||||
AZStd::vector<ScheduledEvent*> m_freeEvents;
|
||||
AZStd::deque<ScheduledEventHandle> m_handles;
|
||||
AZStd::vector<ScheduledEventHandle*> m_freeHandles;
|
||||
};
|
||||
|
||||
@@ -359,7 +359,7 @@ namespace AZ
|
||||
|
||||
//insert the new handler
|
||||
handler.m_index = aznumeric_cast<int32_t>(AZStd::distance(m_handlers.begin(), insertLocation));
|
||||
auto insertedItr = m_handlers.insert(insertLocation, &handler);
|
||||
m_handlers.insert(insertLocation, &handler);
|
||||
return handler.m_index;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ namespace AZ
|
||||
void ScheduledEvent::Requeue(TimeMs durationMs)
|
||||
{
|
||||
m_durationMs = durationMs;
|
||||
ClearHandle();
|
||||
IEventScheduler* eventScheduler = Interface<IEventScheduler>::Get();
|
||||
if (eventScheduler)
|
||||
{
|
||||
@@ -120,10 +119,6 @@ namespace AZ
|
||||
|
||||
void ScheduledEvent::ClearHandle()
|
||||
{
|
||||
if (m_handle)
|
||||
{
|
||||
m_handle->Clear();
|
||||
m_handle = nullptr;
|
||||
}
|
||||
m_handle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ namespace AZ
|
||||
class ScheduledEvent
|
||||
{
|
||||
public:
|
||||
//! Default constructor only for AZStd::deque compatibility.
|
||||
ScheduledEvent() = default;
|
||||
|
||||
//! Constructor of ScheduledEvent class.
|
||||
//! @param callback a call back function to be executed when the event triggers
|
||||
//! @param eventName name of the scheduled event for easier debugging
|
||||
@@ -82,8 +85,6 @@ namespace AZ
|
||||
//! Clears any currently set handle pointer.
|
||||
void ClearHandle();
|
||||
|
||||
AZ_DISABLE_COPY_MOVE(ScheduledEvent);
|
||||
|
||||
Name m_eventName; //< Scheduled event name
|
||||
AZStd::function<void()> m_callback; //< A callback function to run when the scheduled event triggers
|
||||
ScheduledEventHandle* m_handle = nullptr; //< Handle pointer to protect running a deleted event callback function
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
ScheduledEventHandle::ScheduledEventHandle(TimeMs executeTimeMs, TimeMs durationTimeMs, ScheduledEvent* scheduledEvent, bool isAutoDelete)
|
||||
ScheduledEventHandle::ScheduledEventHandle(TimeMs executeTimeMs, TimeMs durationTimeMs, ScheduledEvent* scheduledEvent, bool ownsScheduledEvent)
|
||||
: m_executeTimeMs(executeTimeMs)
|
||||
, m_durationMs(durationTimeMs)
|
||||
, m_event(scheduledEvent)
|
||||
, m_autoDelete(isAutoDelete)
|
||||
, m_ownsScheduledEvent(ownsScheduledEvent)
|
||||
{
|
||||
;
|
||||
}
|
||||
@@ -49,11 +49,6 @@ namespace AZ
|
||||
else // Not configured to auto-requeue, so remove the handle
|
||||
{
|
||||
m_event->ClearHandle();
|
||||
if (m_autoDelete)
|
||||
{
|
||||
delete m_event;
|
||||
}
|
||||
m_event = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,11 +60,6 @@ namespace AZ
|
||||
return false; // Event has been deleted, so the handle class must be deleted after this function.
|
||||
}
|
||||
|
||||
void ScheduledEventHandle::Clear()
|
||||
{
|
||||
m_event = nullptr;
|
||||
}
|
||||
|
||||
TimeMs ScheduledEventHandle::GetExecuteTimeMs() const
|
||||
{
|
||||
return m_executeTimeMs;
|
||||
@@ -79,4 +69,14 @@ namespace AZ
|
||||
{
|
||||
return m_durationMs;
|
||||
}
|
||||
|
||||
bool ScheduledEventHandle::GetOwnsScheduledEvent() const
|
||||
{
|
||||
return m_ownsScheduledEvent;
|
||||
}
|
||||
|
||||
ScheduledEvent* ScheduledEventHandle::GetScheduledEvent() const
|
||||
{
|
||||
return m_event;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace AZ
|
||||
//! @param executeTimeMs an absolute time in ms at which point the scheduled event should trigger
|
||||
//! @param durationTimeMs the interval time in ms used for prioritization as well as re-queueing
|
||||
//! @param scheduledEvent a scheduled event to run
|
||||
//! @param autoDelete if the event handle will be automatically deleted after execution completes
|
||||
ScheduledEventHandle(TimeMs executeTimeMs, TimeMs durationTimeMs, ScheduledEvent* scheduledEvent, bool isAutoDelete);
|
||||
//! @param ownsScheduledEvent true if the event handle owns its own scheduled event instance
|
||||
ScheduledEventHandle(TimeMs executeTimeMs, TimeMs durationTimeMs, ScheduledEvent* scheduledEvent, bool ownsScheduledEvent = false);
|
||||
|
||||
//! operator of comparing a scheduled event by execute time.
|
||||
//! @param a_Rhs a scheduled event handle to compare
|
||||
@@ -42,9 +42,6 @@ namespace AZ
|
||||
//! @return true for re-queuing a scheduled event or false for deleting this class.
|
||||
bool Notify();
|
||||
|
||||
//! Set nullptr for a scheduled event pointer.
|
||||
void Clear();
|
||||
|
||||
//! Get the execution time in ms for this scheduled event.
|
||||
//! @return the execution time in ms for this scheduled event
|
||||
TimeMs GetExecuteTimeMs() const;
|
||||
@@ -54,12 +51,20 @@ namespace AZ
|
||||
//! @return the duration time in ms for this scheduled event
|
||||
TimeMs GetDurationTimeMs() const;
|
||||
|
||||
//! Gets whether or not the event handle owns its own scheduled event.
|
||||
//! @return true if the event handle owns
|
||||
bool GetOwnsScheduledEvent() const;
|
||||
|
||||
//! Gets the scheduled event instance bound to this event handle.
|
||||
//! @return the scheduled event instance bound to this event handle
|
||||
ScheduledEvent* GetScheduledEvent() const;
|
||||
|
||||
private:
|
||||
|
||||
TimeMs m_executeTimeMs = TimeMs{ 0 }; //< execution time of the scheduled event
|
||||
TimeMs m_durationMs = TimeMs{ 0 }; //< interval time of the scheduled event
|
||||
ScheduledEvent* m_event = nullptr; //< pointer to the scheduled event
|
||||
bool m_autoDelete = false; //< if the handle manages the memory of its own event
|
||||
bool m_ownsScheduledEvent = false; //< if the handle manages the memory of its own event
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -96,8 +96,8 @@ namespace AZ::IO
|
||||
constexpr int Compare(const value_type* pathString) const noexcept;
|
||||
|
||||
// decomposition
|
||||
//! Given a windows path of "C:\lumberyard\foo\bar\name.txt" and a posix path of
|
||||
//! "/lumberyard/foo/bar/name.txt"
|
||||
//! Given a windows path of "C:\O3DE\foo\bar\name.txt" and a posix path of
|
||||
//! "/O3DE/foo/bar/name.txt"
|
||||
//! The following functions return the following
|
||||
|
||||
//! Returns the root name part of the path. if it has one.
|
||||
@@ -114,10 +114,10 @@ namespace AZ::IO
|
||||
constexpr PathView RootPath() const;
|
||||
//! Returns the relative path portion of the path.
|
||||
//! This contains the path parts after the root path
|
||||
//! windows = "lumberyard\foo\bar\name.txt", posix = "lumberyard/foo/bar/name.txt"
|
||||
//! windows = "O3DE\foo\bar\name.txt", posix = "O3DE/foo/bar/name.txt"
|
||||
constexpr PathView RelativePath() const;
|
||||
//! Returns the parent directory of filename contained within the path
|
||||
//! windows = "C:\lumberyard\foo\bar", posix = "/lumberyard/foo/bar"
|
||||
//! windows = "C:\O3DE\foo\bar", posix = "/O3DE/foo/bar"
|
||||
//! NOTE: If the path ends with a trailing separator "test/foo/" it is treated as being a path of
|
||||
//! "test/foo" as if the filename of the path is "foo" and the parent directory is "test"
|
||||
constexpr PathView ParentPath() const;
|
||||
@@ -150,7 +150,7 @@ namespace AZ::IO
|
||||
//! The root portion of the path is made up of root_name() / root_directory()
|
||||
[[nodiscard]] constexpr bool HasRootPath() const;
|
||||
//! checks whether the relative part of path is empty
|
||||
//! (C:\\ lumberyard\dev\)
|
||||
//! (C:\\ O3DE\dev\)
|
||||
//! ^ ^
|
||||
//! root part relative part
|
||||
[[nodiscard]] constexpr bool HasRelativePath() const;
|
||||
@@ -485,10 +485,10 @@ namespace AZ::IO
|
||||
constexpr PathView RootPath() const;
|
||||
//! Returns the relative path portion of the path.
|
||||
//! This contains the path parts after the root path
|
||||
//! windows = "lumberyard\foo\bar\name.txt", posix = "lumberyard/foo/bar/name.txt"
|
||||
//! windows = "O3DE\foo\bar\name.txt", posix = "O3DE/foo/bar/name.txt"
|
||||
constexpr PathView RelativePath() const;
|
||||
//! Returns the parent directory of filename contained within the path
|
||||
//! windows = "C:\lumberyard\foo\bar", posix = "/lumberyard/foo/bar"
|
||||
//! windows = "C:\O3DE\foo\bar", posix = "/O3DE/foo/bar"
|
||||
//! NOTE: If the path ends with a trailing separator "test/foo/" it is treated as being a path of
|
||||
//! "test/foo" as if the filename of the path is "foo" and the parent directory is "test"
|
||||
constexpr PathView ParentPath() const;
|
||||
@@ -521,8 +521,8 @@ namespace AZ::IO
|
||||
//! The root portion of the path is made up of root_name() / root_directory()
|
||||
[[nodiscard]] constexpr bool HasRootPath() const;
|
||||
//! checks whether the relative part of path is empty
|
||||
//! (C:\\ lumberyard\dev\)
|
||||
//! ^ ^
|
||||
//! (C:\\ O3DE\dev\)
|
||||
//! ^ ^
|
||||
//! root part relative part
|
||||
[[nodiscard]] constexpr bool HasRelativePath() const;
|
||||
//! checks whether the path has a parent path that empty
|
||||
@@ -544,8 +544,8 @@ namespace AZ::IO
|
||||
[[nodiscard]] constexpr bool IsRelativeTo(const PathView& base) const;
|
||||
|
||||
// decomposition
|
||||
//! Given a windows path of "C:\lumberyard\foo\bar\name.txt" and a posix path of
|
||||
//! "/lumberyard/foo/bar/name.txt"
|
||||
//! Given a windows path of "C:\O3DE\foo\bar\name.txt" and a posix path of
|
||||
//! "/O3DE/foo/bar/name.txt"
|
||||
//! The following functions return the following
|
||||
|
||||
// query
|
||||
|
||||
@@ -214,6 +214,20 @@ namespace AZ::IO::Internal
|
||||
// logic
|
||||
return IsAbsolute(pathView.begin(), pathView.end(), preferredSeparator);
|
||||
}
|
||||
|
||||
// Compares path segments using either Posix or Windows path rules based on the path separator in use
|
||||
// Posix paths perform a case-sensitive comparison, while Windows paths perform a case-insensitive comparison
|
||||
static int ComparePathSegment(AZStd::string_view left, AZStd::string_view right, char pathSeparator)
|
||||
{
|
||||
const size_t maxCharsToCompare = (AZStd::min)(left.size(), right.size());
|
||||
|
||||
int charCompareResult = pathSeparator == PosixPathSeparator
|
||||
? strncmp(left.data(), right.data(), maxCharsToCompare)
|
||||
: azstrnicmp(left.data(), right.data(), maxCharsToCompare);
|
||||
return charCompareResult == 0
|
||||
? aznumeric_cast<ptrdiff_t>(left.size()) - aznumeric_cast<ptrdiff_t>(right.size())
|
||||
: charCompareResult;
|
||||
}
|
||||
}
|
||||
|
||||
//! PathParser implementation
|
||||
@@ -351,7 +365,6 @@ namespace AZ::IO::parser
|
||||
constexpr void Decrement() noexcept
|
||||
{
|
||||
auto pathStart = m_path_view.begin();
|
||||
auto pathEnd = m_path_view.end();
|
||||
auto currentPathEntry = getCurrentTokenStartPos();
|
||||
|
||||
if (currentPathEntry == pathStart)
|
||||
@@ -613,7 +626,7 @@ namespace AZ::IO::parser
|
||||
{
|
||||
return pathParser->InRootName() ? **pathParser : "";
|
||||
};
|
||||
int res = GetRootName(lhsPathParser).compare(GetRootName(rhsPathParser));
|
||||
int res = Internal::ComparePathSegment(GetRootName(lhsPathParser), GetRootName(rhsPathParser), lhsPathParser->m_preferred_separator);
|
||||
ConsumeRootName(lhsPathParser);
|
||||
ConsumeRootName(rhsPathParser);
|
||||
return res;
|
||||
@@ -642,7 +655,8 @@ namespace AZ::IO::parser
|
||||
|
||||
while (lhsPathParser && rhsPathParser)
|
||||
{
|
||||
if (int res = (*lhsPathParser).compare(*rhsPathParser); res != 0)
|
||||
if (int res = Internal::ComparePathSegment(*lhsPathParser, *rhsPathParser, lhsPathParser.m_preferred_separator);
|
||||
res != 0)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
@@ -1033,11 +1047,25 @@ namespace AZ::IO
|
||||
parser::PathParser patternParserEnd(pathPatternView.relative_path_view(), parser::ParserState::PS_AtEnd, pathPatternView.m_preferred_separator);
|
||||
|
||||
// move the parser from the end to a valid filename by decrementing
|
||||
for(--pathParserEnd, --patternParserEnd; pathParserEnd && patternParserEnd; --pathParserEnd, --patternParserEnd)
|
||||
// Windows Paths are case-insensitive, while Posix paths are case-sensitive
|
||||
if (m_preferred_separator == PosixPathSeparator)
|
||||
{
|
||||
if (!AZStd::wildcard_match_case(*patternParserEnd, *pathParserEnd))
|
||||
for (--pathParserEnd, --patternParserEnd; pathParserEnd && patternParserEnd; --pathParserEnd, --patternParserEnd)
|
||||
{
|
||||
return false;
|
||||
if (!AZStd::wildcard_match_case(*patternParserEnd, *pathParserEnd))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (--pathParserEnd, --patternParserEnd; pathParserEnd && patternParserEnd; --pathParserEnd, --patternParserEnd)
|
||||
{
|
||||
if (!AZStd::wildcard_match(*patternParserEnd, *pathParserEnd))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,15 +147,18 @@ namespace AZ
|
||||
ReadFile(request, args);
|
||||
return;
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
else
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}, request->GetCommand());
|
||||
}
|
||||
|
||||
|
||||
@@ -146,15 +146,18 @@ namespace AZ
|
||||
DestroyDedicatedCache(request, args);
|
||||
return;
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
else
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}, request->GetCommand());
|
||||
}
|
||||
|
||||
|
||||
@@ -97,19 +97,22 @@ namespace AZ
|
||||
CancelRequest(request, args.m_target);
|
||||
return;
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
else
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
if constexpr (AZStd::is_same_v<Command, FileRequest::FlushData>)
|
||||
{
|
||||
FlushCache(args.m_path);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::ReportData>)
|
||||
{
|
||||
Report(args);
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::FlushAllData>)
|
||||
{
|
||||
FlushEntireCache();
|
||||
}
|
||||
else if constexpr (AZStd::is_same_v<Command, FileRequest::ReportData>)
|
||||
{
|
||||
Report(args);
|
||||
}
|
||||
StreamStackEntry::QueueRequest(request);
|
||||
}, request->GetCommand());
|
||||
}
|
||||
|
||||
|
||||
@@ -300,7 +300,6 @@ namespace AZ
|
||||
context.Class<Uuid>("Uuid")->
|
||||
Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)->
|
||||
Attribute(AZ::Script::Attributes::Module, "math")->
|
||||
Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)->
|
||||
Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)->
|
||||
Attribute(AZ::Script::Attributes::ConstructorOverride, &Internal::ScriptUuidConstructor)->
|
||||
Attribute(AZ::Script::Attributes::GenericConstructorOverride, &Internal::UuidDefaultConstructor)->
|
||||
|
||||
@@ -18,11 +18,8 @@ namespace AZ
|
||||
{
|
||||
Quaternion CreateRandomQuaternion(SimpleLcgRandom& rng)
|
||||
{
|
||||
float u1 = rng.GetRandomFloat();
|
||||
float u2 = rng.GetRandomFloat();
|
||||
float u3 = rng.GetRandomFloat();
|
||||
float c1 = Sqrt(1.0f - u1);
|
||||
float c2 = Sqrt(u1);
|
||||
float x, y, z, w;
|
||||
SinCos(Constants::TwoPi * u2, x, y);
|
||||
SinCos(Constants::TwoPi * u3, z, w);
|
||||
|
||||
@@ -374,7 +374,7 @@ namespace AZ
|
||||
|
||||
targetForward.Normalize();
|
||||
|
||||
// Lumberyard is Z-up and is right-handed.
|
||||
// Open 3D Engine is Z-up and is right-handed.
|
||||
Vector3 up = Vector3::CreateAxisZ();
|
||||
|
||||
// We have a degenerate case if target forward is parallel to the up axis,
|
||||
@@ -391,7 +391,7 @@ namespace AZ
|
||||
up.Normalize();
|
||||
|
||||
// Passing in forwardAxis allows you to force a particular local-space axis to look
|
||||
// at the target point. In Lumberyard, the default is forward is along Y+.
|
||||
// at the target point. In Open 3D Engine, the default is forward is along Y+.
|
||||
switch (forwardAxis)
|
||||
{
|
||||
case Axis::XPositive:
|
||||
|
||||
@@ -426,7 +426,7 @@ namespace AZ
|
||||
Matrix4x4 Matrix4x4::CreateProjection(float fovY, float aspectRatio, float nearDist, float farDist)
|
||||
{
|
||||
// This section contains some notes about camera matrices and field of view, because there are some subtle differences
|
||||
// between the convention Lumberyard uses and what you might be used to from other software packages.
|
||||
// between the convention Open 3D Engine uses and what you might be used to from other software packages.
|
||||
// Our camera space has the camera looking down the *positive* z-axis, the x-axis points towards the left of the screen,
|
||||
// and the y-axis points towards the top of the screen.
|
||||
//
|
||||
|
||||
@@ -74,7 +74,6 @@ namespace AZ
|
||||
{
|
||||
behaviorContext->Class<Obb>()->
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::Preview)->
|
||||
Attribute(Script::Attributes::Storage, Script::Attributes::StorageType::Value)->
|
||||
Attribute(Script::Attributes::GenericConstructorOverride, &Internal::ObbDefaultConstructor)->
|
||||
Property("position", &Obb::GetPosition, &Obb::SetPosition)->
|
||||
@@ -155,7 +154,7 @@ namespace AZ
|
||||
return Obb::CreateFromPositionRotationAndHalfLengths(
|
||||
transform.TransformPoint(obb.GetPosition()),
|
||||
transform.GetRotation() * obb.GetRotation(),
|
||||
obb.GetHalfLengths()
|
||||
transform.GetScale() * obb.GetHalfLengths()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,9 +104,9 @@ namespace AZ
|
||||
// As one return value (hit point) is based on the other (hit time), for simplicity, the Lua implementation
|
||||
// just returns all three values: does the ray hit? When does it hit? Where does it hit?
|
||||
|
||||
if (!dc.IsClass<Vector3>(0) || !dc.IsClass<Vector3>(0))
|
||||
if (!dc.IsClass<Vector3>(0) || !dc.IsClass<Vector3>(1))
|
||||
{
|
||||
AZ_Error("Script", false, "ScriptPlane CastRay requires two ScriptVector3s as arguments.");
|
||||
AZ_Error("Script", false, "ScriptPlane IntersectSegment requires two ScriptVector3s as arguments.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,6 @@ namespace AZ
|
||||
{
|
||||
behaviorContext->Class<Plane>()->
|
||||
Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)->
|
||||
Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)->
|
||||
Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)->
|
||||
Attribute(AZ::Script::Attributes::GenericConstructorOverride, &Internal::PlaneDefaultConstructor)->
|
||||
Method("ToString", &Internal::PlaneToString)->
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace AZ
|
||||
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<PolygonPrism>()
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(Script::Attributes::Storage, Script::Attributes::StorageType::RuntimeOwn)
|
||||
->Property("height", BehaviorValueGetter(&PolygonPrism::m_height), nullptr)
|
||||
->Property("vertexContainer", BehaviorValueGetter(&PolygonPrism::m_vertexContainer), nullptr)
|
||||
|
||||
@@ -258,7 +258,8 @@ namespace AZ
|
||||
Method("CreateFromMatrix3x3", &Quaternion::CreateFromMatrix3x3)->
|
||||
Method("CreateFromMatrix4x4", &Quaternion::CreateFromMatrix4x4)->
|
||||
Method("CreateFromAxisAngle", &Quaternion::CreateFromAxisAngle)->
|
||||
Method("CreateShortestArc", &Quaternion::CreateShortestArc)
|
||||
Method("CreateShortestArc", &Quaternion::CreateShortestArc)->
|
||||
Method("CreateFromEulerAnglesDegrees", &Quaternion::CreateFromEulerAnglesDegrees)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,13 +111,11 @@ namespace AZ
|
||||
Property("segmentFraction", BehaviorValueProperty(&SplineAddress::m_segmentFraction));
|
||||
|
||||
behaviorContext->Class<PositionSplineQueryResult>()->
|
||||
Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)->
|
||||
Attribute(Script::Attributes::Storage, Script::Attributes::StorageType::Value)->
|
||||
Property("splineAddress", [](PositionSplineQueryResult* thisPtr) { return thisPtr->m_splineAddress; }, nullptr)->
|
||||
Property("distanceSq", [](PositionSplineQueryResult* thisPtr) { return thisPtr->m_distanceSq; }, nullptr);
|
||||
|
||||
behaviorContext->Class<RaySplineQueryResult>()->
|
||||
Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)->
|
||||
Attribute(Script::Attributes::Storage, Script::Attributes::StorageType::Value)->
|
||||
Property("splineAddress", [](RaySplineQueryResult* thisPtr) { return thisPtr->m_splineAddress; }, nullptr)->
|
||||
Property("distanceSq", [](RaySplineQueryResult* thisPtr) { return thisPtr->m_distanceSq; }, nullptr)->
|
||||
|
||||
@@ -250,6 +250,7 @@ namespace AZ
|
||||
Attribute(Script::Attributes::ExcludeFrom, Script::Attributes::ExcludeFlags::All)->
|
||||
Attribute(Script::Attributes::Storage, Script::Attributes::StorageType::Value)->
|
||||
Attribute(Script::Attributes::GenericConstructorOverride, &Internal::TransformDefaultConstructor)->
|
||||
Constructor<const Vector3&, const Quaternion&, const Vector3&>()->
|
||||
Method("GetBasis", &Transform::GetBasis)->
|
||||
Method("GetBasisX", &Transform::GetBasisX)->
|
||||
Method("GetBasisY", &Transform::GetBasisY)->
|
||||
@@ -354,7 +355,7 @@ namespace AZ
|
||||
|
||||
targetForward.Normalize();
|
||||
|
||||
// Lumberyard is Z-up and is right-handed.
|
||||
// Open 3D Engine is Z-up and is right-handed.
|
||||
Vector3 up = Vector3::CreateAxisZ();
|
||||
|
||||
// We have a degenerate case if target forward is parallel to the up axis,
|
||||
@@ -371,7 +372,7 @@ namespace AZ
|
||||
up.Normalize();
|
||||
|
||||
// Passing in forwardAxis allows you to force a particular local-space axis to look
|
||||
// at the target point. In Lumberyard, the default is forward is along Y+.
|
||||
// at the target point. In Open 3D Engine, the default is forward is along Y+.
|
||||
switch (forwardAxis)
|
||||
{
|
||||
case Axis::XPositive:
|
||||
|
||||
@@ -38,6 +38,13 @@ namespace AZ
|
||||
bool CompareValueData(const void* lhs, const void* rhs) override;
|
||||
};
|
||||
|
||||
//! Limits for transform scale values.
|
||||
//! The scale should not be zero to avoid problems with inverting.
|
||||
//! @{
|
||||
static constexpr float MinTransformScale = 1e-2f;
|
||||
static constexpr float MaxTransformScale = 1e9f;
|
||||
//! @}
|
||||
|
||||
//! The basic transformation class, represented using a quaternion rotation, vector scale and vector translation.
|
||||
//! By design, cannot represent skew transformations.
|
||||
class Transform
|
||||
|
||||
@@ -167,14 +167,14 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
AZ_MATH_INLINE Vector2::Vector2(const Vector3& source)
|
||||
Vector2::Vector2(const Vector3& source)
|
||||
: m_x(source.GetX())
|
||||
, m_y(source.GetY())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Vector2::Vector2(const Vector4& source)
|
||||
Vector2::Vector2(const Vector4& source)
|
||||
: m_x(source.GetX())
|
||||
, m_y(source.GetY())
|
||||
{
|
||||
|
||||
@@ -720,9 +720,9 @@ namespace AZ
|
||||
StoragePolicyBase<Allocator>::Destroy(Base::GetModuleAllocatorInstance());
|
||||
}
|
||||
|
||||
AZ_FORCE_INLINE static bool IsReady()
|
||||
static bool IsReady()
|
||||
{
|
||||
return true;
|
||||
return Base::GetModuleAllocatorInstance().IsReady();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -707,7 +707,7 @@ PoolSchema::GarbageCollect()
|
||||
// occur exclusively in the destruction of the allocator.
|
||||
//
|
||||
// TODO: A better solution needs to be found for integrating back into mainline
|
||||
// Lumberyard.
|
||||
// Open 3D Engine.
|
||||
//m_impl->GarbageCollect();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/PlatformId/PlatformDefaults.h>
|
||||
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
inline namespace PlatformDefaults
|
||||
{
|
||||
static const char* PlatformNames[PlatformId::NumPlatformIds] = { PlatformPC, PlatformES3, PlatformIOS, PlatformOSX, PlatformProvo, PlatformSalem, PlatformJasper, PlatformServer, PlatformAll, PlatformAllClient };
|
||||
|
||||
const char* PlatformIdToPalFolder(AZ::PlatformId platform)
|
||||
{
|
||||
#ifdef IOS
|
||||
#define AZ_REDEFINE_IOS_AT_END IOS
|
||||
#undef IOS
|
||||
#endif
|
||||
switch (platform)
|
||||
{
|
||||
case AZ::PC:
|
||||
return "PC";
|
||||
case AZ::ES3:
|
||||
return "Android";
|
||||
case AZ::IOS:
|
||||
return "iOS";
|
||||
case AZ::OSX:
|
||||
return "Mac";
|
||||
case AZ::PROVO:
|
||||
return "Provo";
|
||||
case AZ::SALEM:
|
||||
return "Salem";
|
||||
case AZ::JASPER:
|
||||
return "Jasper";
|
||||
case AZ::SERVER:
|
||||
return "Server";
|
||||
case AZ::ALL:
|
||||
case AZ::ALL_CLIENT:
|
||||
case AZ::NumPlatformIds:
|
||||
case AZ::Invalid:
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
||||
#ifdef AZ_REDEFINE_IOS_AT_END
|
||||
#define IOS AZ_REDEFINE_IOS_AT_END
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* OSPlatformToDefaultAssetPlatform(AZStd::string_view osPlatform)
|
||||
{
|
||||
if (osPlatform == PlatformCodeNameWindows || osPlatform == PlatformCodeNameLinux)
|
||||
{
|
||||
return PlatformPC;
|
||||
}
|
||||
else if (osPlatform == PlatformCodeNameMac)
|
||||
{
|
||||
return PlatformOSX;
|
||||
}
|
||||
else if (osPlatform == PlatformCodeNameAndroid)
|
||||
{
|
||||
return PlatformES3;
|
||||
}
|
||||
else if (osPlatform == PlatformCodeNameiOS)
|
||||
{
|
||||
return PlatformIOS;
|
||||
}
|
||||
else if (osPlatform == PlatformCodeNameProvo)
|
||||
{
|
||||
return PlatformProvo;
|
||||
}
|
||||
else if (osPlatform == PlatformCodeNameSalem)
|
||||
{
|
||||
return PlatformSalem;
|
||||
}
|
||||
else if (osPlatform == PlatformCodeNameJasper)
|
||||
{
|
||||
return PlatformJasper;
|
||||
}
|
||||
|
||||
AZ_Error("PlatformDefault", false, R"(Supplied OS platform "%.*s" does not have a corresponding default asset platform)",
|
||||
aznumeric_cast<int>(osPlatform.size()), osPlatform.data());
|
||||
return "";
|
||||
}
|
||||
|
||||
PlatformFlags PlatformHelper::GetPlatformFlagFromPlatformIndex(PlatformId platformIndex)
|
||||
{
|
||||
if (platformIndex < 0 || platformIndex > PlatformId::NumPlatformIds)
|
||||
{
|
||||
return PlatformFlags::Platform_NONE;
|
||||
}
|
||||
if (platformIndex == PlatformId::ALL)
|
||||
{
|
||||
return PlatformFlags::Platform_ALL;
|
||||
}
|
||||
if (platformIndex == PlatformId::ALL_CLIENT)
|
||||
{
|
||||
return PlatformFlags::Platform_ALL_CLIENT;
|
||||
}
|
||||
return static_cast<PlatformFlags>(1 << platformIndex);
|
||||
}
|
||||
|
||||
AZStd::fixed_vector<AZStd::string_view, PlatformId::NumPlatformIds> PlatformHelper::GetPlatforms(PlatformFlags platformFlags)
|
||||
{
|
||||
AZStd::fixed_vector<AZStd::string_view, PlatformId::NumPlatformIds> platforms;
|
||||
for (int platformNum = 0; platformNum < PlatformId::NumPlatformIds; ++platformNum)
|
||||
{
|
||||
const bool isAllPlatforms = PlatformId::ALL == static_cast<PlatformId>(platformNum)
|
||||
&& ((platformFlags & PlatformFlags::Platform_ALL) != PlatformFlags::Platform_NONE);
|
||||
|
||||
const bool isAllClientPlatforms = PlatformId::ALL_CLIENT == static_cast<PlatformId>(platformNum)
|
||||
&& ((platformFlags & PlatformFlags::Platform_ALL_CLIENT) != PlatformFlags::Platform_NONE);
|
||||
|
||||
if (isAllPlatforms || isAllClientPlatforms
|
||||
|| (platformFlags & static_cast<PlatformFlags>(1 << platformNum)) != PlatformFlags::Platform_NONE)
|
||||
{
|
||||
platforms.push_back(PlatformNames[platformNum]);
|
||||
}
|
||||
}
|
||||
|
||||
return platforms;
|
||||
}
|
||||
|
||||
AZStd::fixed_vector<AZStd::string_view, PlatformId::NumPlatformIds> PlatformHelper::GetPlatformsInterpreted(PlatformFlags platformFlags)
|
||||
{
|
||||
return GetPlatforms(GetPlatformFlagsInterpreted(platformFlags));
|
||||
}
|
||||
|
||||
AZStd::fixed_vector<PlatformId, PlatformId::NumPlatformIds> PlatformHelper::GetPlatformIndices(PlatformFlags platformFlags)
|
||||
{
|
||||
AZStd::fixed_vector<PlatformId, PlatformId::NumPlatformIds> platformIndices;
|
||||
for (int i = 0; i < PlatformId::NumPlatformIds; i++)
|
||||
{
|
||||
PlatformId index = static_cast<PlatformId>(i);
|
||||
if ((GetPlatformFlagFromPlatformIndex(index) & platformFlags) != PlatformFlags::Platform_NONE)
|
||||
{
|
||||
platformIndices.emplace_back(index);
|
||||
}
|
||||
}
|
||||
return platformIndices;
|
||||
}
|
||||
|
||||
AZStd::fixed_vector<PlatformId, PlatformId::NumPlatformIds> PlatformHelper::GetPlatformIndicesInterpreted(PlatformFlags platformFlags)
|
||||
{
|
||||
return GetPlatformIndices(GetPlatformFlagsInterpreted(platformFlags));
|
||||
}
|
||||
|
||||
PlatformFlags PlatformHelper::GetPlatformFlag(AZStd::string_view platform)
|
||||
{
|
||||
int platformIndex = GetPlatformIndexFromName(platform);
|
||||
if (platformIndex == PlatformId::Invalid)
|
||||
{
|
||||
AZ_Error("PlatformDefault", false, "Invalid Platform ( %.*s ).\n", static_cast<int>(platform.length()), platform.data());
|
||||
return PlatformFlags::Platform_NONE;
|
||||
}
|
||||
|
||||
if (platformIndex == PlatformId::ALL)
|
||||
{
|
||||
return PlatformFlags::Platform_ALL;
|
||||
}
|
||||
|
||||
if (platformIndex == PlatformId::ALL_CLIENT)
|
||||
{
|
||||
return PlatformFlags::Platform_ALL_CLIENT;
|
||||
}
|
||||
|
||||
return static_cast<PlatformFlags>(1 << platformIndex);
|
||||
}
|
||||
|
||||
const char* PlatformHelper::GetPlatformName(PlatformId platform)
|
||||
{
|
||||
if (platform < 0 || platform > PlatformId::NumPlatformIds)
|
||||
{
|
||||
return "invalid";
|
||||
}
|
||||
return PlatformNames[platform];
|
||||
}
|
||||
|
||||
void PlatformHelper::AppendPlatformCodeNames(AZStd::fixed_vector<AZStd::string_view, MaxPlatformCodeNames>& platformCodes, AZStd::string_view platformId)
|
||||
{
|
||||
PlatformId platform = GetPlatformIdFromName(platformId);
|
||||
AZ_Assert(platform != PlatformId::Invalid, "Unsupported Platform ID: %.*s", static_cast<int>(platformId.length()), platformId.data());
|
||||
AppendPlatformCodeNames(platformCodes, platform);
|
||||
}
|
||||
|
||||
void PlatformHelper::AppendPlatformCodeNames(AZStd::fixed_vector<AZStd::string_view, MaxPlatformCodeNames>& platformCodes, PlatformId platformId)
|
||||
{
|
||||
// The IOS SDK has a macro that defines IOS as 1 which causes the enum below to be incorrectly converted to "PlatformId::1".
|
||||
#pragma push_macro("IOS")
|
||||
#undef IOS
|
||||
// To reduce work the Asset Processor groups assets that can be shared between hardware platforms together. For this
|
||||
// reason "PC" can for instance cover both the Windows and Linux platforms and "IOS" can cover AppleTV and iOS.
|
||||
switch (platformId)
|
||||
{
|
||||
case PlatformId::PC:
|
||||
platformCodes.emplace_back(PlatformCodeNameWindows);
|
||||
platformCodes.emplace_back(PlatformCodeNameLinux);
|
||||
break;
|
||||
case PlatformId::ES3:
|
||||
platformCodes.emplace_back(PlatformCodeNameAndroid);
|
||||
break;
|
||||
case PlatformId::IOS:
|
||||
platformCodes.emplace_back(PlatformCodeNameiOS);
|
||||
break;
|
||||
case PlatformId::OSX:
|
||||
platformCodes.emplace_back(PlatformCodeNameMac);
|
||||
break;
|
||||
case PlatformId::PROVO:
|
||||
platformCodes.emplace_back(PlatformCodeNameProvo);
|
||||
break;
|
||||
case PlatformId::SALEM:
|
||||
platformCodes.emplace_back(PlatformCodeNameSalem);
|
||||
break;
|
||||
case PlatformId::JASPER:
|
||||
platformCodes.emplace_back(PlatformCodeNameJasper);
|
||||
break;
|
||||
case PlatformId::SERVER:
|
||||
// Server is not a hardware platform
|
||||
break;
|
||||
default:
|
||||
AZ_Assert(false, "Unsupported Platform ID: %i", platformId);
|
||||
break;
|
||||
}
|
||||
#pragma pop_macro("IOS")
|
||||
}
|
||||
|
||||
int PlatformHelper::GetPlatformIndexFromName(AZStd::string_view platformName)
|
||||
{
|
||||
for (int idx = 0; idx < PlatformId::NumPlatformIds; idx++)
|
||||
{
|
||||
if (platformName == PlatformNames[idx])
|
||||
{
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
|
||||
return PlatformId::Invalid;
|
||||
}
|
||||
|
||||
PlatformId PlatformHelper::GetPlatformIdFromName(AZStd::string_view platformName)
|
||||
{
|
||||
return aznumeric_caster(GetPlatformIndexFromName(platformName));
|
||||
}
|
||||
|
||||
AssetPlatformCombinedString PlatformHelper::GetCommaSeparatedPlatformList(PlatformFlags platformFlags)
|
||||
{
|
||||
AZStd::fixed_vector<AZStd::string_view, PlatformId::NumPlatformIds> platformNames = GetPlatforms(platformFlags);
|
||||
AssetPlatformCombinedString platformsString;
|
||||
AZ::StringFunc::Join(platformsString, platformNames.begin(), platformNames.end(), ", ");
|
||||
return platformsString;
|
||||
}
|
||||
|
||||
PlatformFlags PlatformHelper::GetPlatformFlagsInterpreted(PlatformFlags platformFlags)
|
||||
{
|
||||
PlatformFlags returnFlags = PlatformFlags::Platform_NONE;
|
||||
|
||||
if ((platformFlags & PlatformFlags::Platform_ALL) != PlatformFlags::Platform_NONE)
|
||||
{
|
||||
for (int i = 0; i < NumPlatforms; ++i)
|
||||
{
|
||||
auto platformId = static_cast<PlatformId>(i);
|
||||
|
||||
if (platformId != PlatformId::ALL && platformId != PlatformId::ALL_CLIENT)
|
||||
{
|
||||
returnFlags |= GetPlatformFlagFromPlatformIndex(platformId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((platformFlags & PlatformFlags::Platform_ALL_CLIENT) != PlatformFlags::Platform_NONE)
|
||||
{
|
||||
for (int i = 0; i < NumPlatforms; ++i)
|
||||
{
|
||||
auto platformId = static_cast<PlatformId>(i);
|
||||
|
||||
if (platformId != PlatformId::ALL && platformId != PlatformId::ALL_CLIENT && platformId != PlatformId::SERVER)
|
||||
{
|
||||
returnFlags |= GetPlatformFlagFromPlatformIndex(platformId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnFlags = platformFlags;
|
||||
}
|
||||
|
||||
return returnFlags;
|
||||
}
|
||||
|
||||
bool PlatformHelper::IsSpecialPlatform(PlatformFlags platformFlags)
|
||||
{
|
||||
return (platformFlags & PlatformFlags::Platform_ALL) != PlatformFlags::Platform_NONE
|
||||
|| (platformFlags & PlatformFlags::Platform_ALL_CLIENT) != PlatformFlags::Platform_NONE;
|
||||
}
|
||||
|
||||
bool HasFlagHelper(PlatformFlags flags, PlatformFlags checkPlatform)
|
||||
{
|
||||
return (flags & checkPlatform) == checkPlatform;
|
||||
}
|
||||
|
||||
|
||||
bool PlatformHelper::HasPlatformFlag(PlatformFlags flags, PlatformId checkPlatform)
|
||||
{
|
||||
// If checkPlatform contains any kind of invalid id, just exit out here
|
||||
if (checkPlatform == PlatformId::Invalid || checkPlatform == NumPlatforms)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ALL_CLIENT + SERVER = ALL
|
||||
if (HasFlagHelper(flags, PlatformFlags::Platform_ALL_CLIENT | PlatformFlags::Platform_SERVER))
|
||||
{
|
||||
flags = PlatformFlags::Platform_ALL;
|
||||
}
|
||||
|
||||
if (HasFlagHelper(flags, PlatformFlags::Platform_ALL))
|
||||
{
|
||||
// It doesn't matter what checkPlatform is set to in this case, just return true
|
||||
return true;
|
||||
}
|
||||
|
||||
if (HasFlagHelper(flags, PlatformFlags::Platform_ALL_CLIENT))
|
||||
{
|
||||
return checkPlatform != PlatformId::SERVER;
|
||||
}
|
||||
|
||||
return HasFlagHelper(flags, GetPlatformFlagFromPlatformIndex(checkPlatform));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Preprocessor/Enum.h>
|
||||
#include <AzCore/std/containers/fixed_vector.h>
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
#include <AzCore/std/string/string_view.h>
|
||||
|
||||
// On IOS builds IOS will be defined and interfere with the below enums
|
||||
#pragma push_macro("IOS")
|
||||
#undef IOS
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
inline namespace PlatformDefaults
|
||||
{
|
||||
constexpr char PlatformPC[] = "pc";
|
||||
constexpr char PlatformES3[] = "es3";
|
||||
constexpr char PlatformIOS[] = "ios";
|
||||
constexpr char PlatformOSX[] = "osx_gl";
|
||||
constexpr char PlatformProvo[] = "provo";
|
||||
constexpr char PlatformSalem[] = "salem";
|
||||
constexpr char PlatformJasper[] = "jasper";
|
||||
constexpr char PlatformServer[] = "server";
|
||||
|
||||
constexpr char PlatformCodeNameWindows[] = "Windows";
|
||||
constexpr char PlatformCodeNameLinux[] = "Linux";
|
||||
constexpr char PlatformCodeNameAndroid[] = "Android";
|
||||
constexpr char PlatformCodeNameiOS[] = "iOS";
|
||||
constexpr char PlatformCodeNameMac[] = "Mac";
|
||||
constexpr char PlatformCodeNameProvo[] = "Provo";
|
||||
constexpr char PlatformCodeNameSalem[] = "Salem";
|
||||
constexpr char PlatformCodeNameJasper[] = "Jasper";
|
||||
constexpr char PlatformAll[] = "all";
|
||||
constexpr char PlatformAllClient[] = "all_client";
|
||||
|
||||
// Used for the capacity of a fixed vector to store the code names of platforms
|
||||
// The value needs to be higher than the number of unique OS platforms that are supported(at this time 8)
|
||||
constexpr size_t MaxPlatformCodeNames = 16;
|
||||
|
||||
//! This platform enum have platform values in sequence and can also be used to get the platform count.
|
||||
AZ_ENUM_WITH_UNDERLYING_TYPE(PlatformId, int,
|
||||
(Invalid, -1),
|
||||
PC,
|
||||
ES3,
|
||||
IOS,
|
||||
OSX,
|
||||
PROVO,
|
||||
SALEM,
|
||||
JASPER,
|
||||
SERVER, // Corresponds to the customer's flavor of "server" which could be windows, ubuntu, etc
|
||||
ALL,
|
||||
ALL_CLIENT,
|
||||
|
||||
// Add new platforms above this
|
||||
NumPlatformIds
|
||||
);
|
||||
constexpr int NumClientPlatforms = 7;
|
||||
constexpr int NumPlatforms = NumClientPlatforms + 1; // 1 "Server" platform currently
|
||||
enum class PlatformFlags : AZ::u32
|
||||
{
|
||||
Platform_NONE = 0x00,
|
||||
Platform_PC = 1 << PlatformId::PC,
|
||||
Platform_ES3 = 1 << PlatformId::ES3,
|
||||
Platform_IOS = 1 << PlatformId::IOS,
|
||||
Platform_OSX = 1 << PlatformId::OSX,
|
||||
Platform_PROVO = 1 << PlatformId::PROVO,
|
||||
Platform_SALEM = 1 << PlatformId::SALEM,
|
||||
Platform_JASPER = 1 << PlatformId::JASPER,
|
||||
Platform_SERVER = 1 << PlatformId::SERVER,
|
||||
|
||||
// A special platform that will always correspond to all platforms, even if new ones are added
|
||||
Platform_ALL = 1ULL << 30,
|
||||
|
||||
// A special platform that will always correspond to all non-server platforms, even if new ones are added
|
||||
Platform_ALL_CLIENT = 1ULL << 31,
|
||||
|
||||
AllNamedPlatforms = Platform_PC | Platform_ES3 | Platform_IOS | Platform_OSX | Platform_PROVO | Platform_SALEM | Platform_JASPER | Platform_SERVER,
|
||||
};
|
||||
|
||||
AZ_DEFINE_ENUM_BITWISE_OPERATORS(PlatformFlags);
|
||||
|
||||
// 32 characters should be more than enough to store a platform name
|
||||
using AssetPlatformFixedString = AZStd::fixed_string<32>;
|
||||
// Fixed string which can store a comma separated list of platforms names
|
||||
// Additional byte is added to take into account the comma
|
||||
using AssetPlatformCombinedString = AZStd::fixed_string < (AssetPlatformFixedString{}.max_size() + 1)* PlatformId::NumPlatformIds > ;
|
||||
|
||||
const char* PlatformIdToPalFolder(PlatformId platform);
|
||||
|
||||
const char* OSPlatformToDefaultAssetPlatform(AZStd::string_view osPlatform);
|
||||
|
||||
//! Platform Helper is an utility class that can be used to retrieve platform related information
|
||||
class PlatformHelper
|
||||
{
|
||||
public:
|
||||
|
||||
//! Given a platformIndex returns the platform name
|
||||
static const char* GetPlatformName(PlatformId platform);
|
||||
|
||||
//! Converts the platform name to the platform code names as defined in AZ_TRAIT_OS_PLATFORM_CODENAME.
|
||||
static void AppendPlatformCodeNames(AZStd::fixed_vector<AZStd::string_view, MaxPlatformCodeNames>& platformCodes, AZStd::string_view platformName);
|
||||
|
||||
//! Converts the platform name to the platform code names as defined in AZ_TRAIT_OS_PLATFORM_CODENAME.
|
||||
static void AppendPlatformCodeNames(AZStd::fixed_vector<AZStd::string_view, MaxPlatformCodeNames>& platformCodes, PlatformId platformId);
|
||||
|
||||
//! Given a platform name returns a platform index.
|
||||
//! If the platform is not found, the method returns -1.
|
||||
static int GetPlatformIndexFromName(AZStd::string_view platformName);
|
||||
|
||||
//! Given a platform name returns a platform id.
|
||||
//! If the platform is not found, the method returns -1.
|
||||
static PlatformId GetPlatformIdFromName(AZStd::string_view platformName);
|
||||
|
||||
//! Given a platformIndex returns the platformFlags
|
||||
static PlatformFlags GetPlatformFlagFromPlatformIndex(PlatformId platform);
|
||||
|
||||
//! Given a platformFlags returns all the platform identifiers that are set.
|
||||
static AZStd::fixed_vector<AZStd::string_view, PlatformId::NumPlatformIds> GetPlatforms(PlatformFlags platformFlags);
|
||||
//! Given a platformFlags returns all the platform identifiers that are set, with special flags interpreted. Do not use the result for saving
|
||||
static AZStd::fixed_vector<AZStd::string_view, PlatformId::NumPlatformIds> GetPlatformsInterpreted(PlatformFlags platformFlags);
|
||||
|
||||
//! Given a platformFlags return a list of PlatformId indices
|
||||
static AZStd::fixed_vector<PlatformId, PlatformId::NumPlatformIds> GetPlatformIndices(PlatformFlags platformFlags);
|
||||
//! Given a platformFlags return a list of PlatformId indices, with special flags interpreted. Do not use the result for saving
|
||||
static AZStd::fixed_vector<PlatformId, PlatformId::NumPlatformIds> GetPlatformIndicesInterpreted(PlatformFlags platformFlags);
|
||||
|
||||
//! Given a platform identifier returns its corresponding platform flag.
|
||||
static PlatformFlags GetPlatformFlag(AZStd::string_view platform);
|
||||
|
||||
//! Given any platformFlags returns a string listing the input platforms
|
||||
static AssetPlatformCombinedString GetCommaSeparatedPlatformList(PlatformFlags platformFlags);
|
||||
|
||||
//! If platformFlags contains any special flags, they are removed and replaced with the normal flags they represent
|
||||
static PlatformFlags GetPlatformFlagsInterpreted(PlatformFlags platformFlags);
|
||||
|
||||
//! Returns true if platformFlags contains any special flags
|
||||
static bool IsSpecialPlatform(PlatformFlags platformFlags);
|
||||
|
||||
//! Returns true if platformFlags has checkPlatform flag set.
|
||||
static bool HasPlatformFlag(PlatformFlags platformFlags, PlatformId checkPlatform);
|
||||
};
|
||||
}
|
||||
}
|
||||
#pragma pop_macro("IOS")
|
||||
@@ -515,7 +515,6 @@ namespace AZ
|
||||
->Attribute(AZ::Script::Attributes::EnableAsScriptEventParamType, &IsScriptEventType)
|
||||
->Method("AssignAt", &AssignAt, { { {}, { "Index", "The index at which to assign the element to, resizes the container if necessary", nullptr, BehaviorParameter::Traits::TR_INDEX } } })
|
||||
->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::IndexWrite)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Method("Erase_VM", &ErasePost_VM, { { { "Container", "The container from which to delete", nullptr, {} }, { "Key", "The key to delete", nullptr, {} } } })
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Erase", "Containers"))
|
||||
@@ -526,35 +525,29 @@ namespace AZ
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
->template Method<void(ContainerType::*)(typename ContainerType::const_reference)>("push_back", &ContainerType::push_back)
|
||||
->Attribute(AZ::Script::Attributes::Deprecated, true)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Method("PushBack_VM", &PushBack_VM, { { { "Container", "The container into which to add an element to", nullptr, {} }, { "Value", "The value to be added", nullptr, {} } } })
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Add Element at End", "Containers"))
|
||||
->Attribute(AZ::ScriptCanvasAttributes::OverloadArgumentGroup, AZ::OverloadArgumentGroupInfo({ "ContainerGroup", "" }, { "ContainerGroup" }))
|
||||
->Method("pop_back", &ContainerType::pop_back)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::Script::Attributes::Deprecated, true)
|
||||
->template Method<typename ContainerType::reference(ContainerType::*)(typename ContainerType::size_type)>
|
||||
("at", &ContainerType::at, {{ { "Index", "The index to read from", nullptr, BehaviorParameter::Traits::TR_INDEX } }})->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::IndexRead)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::Script::Attributes::Deprecated, true)
|
||||
->template Method<typename ContainerType::reference(ContainerType::*)(typename ContainerType::size_type)>(k_accessElementNameUnchecked, &ContainerType::at, { { { "Index", "The index to read from", nullptr } } })
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Get Element", "Containers"))
|
||||
->Attribute(AZ::ScriptCanvasAttributes::CheckedOperation, CheckedOperationInfo("Has Key", {}, "Out", "Key Not Found"))
|
||||
->Method("size", [](ContainerType& thisPtr) { return aznumeric_cast<int>(thisPtr.size()); })
|
||||
->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Length)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Method("GetSize", [](ContainerType& thisPtr) { return aznumeric_cast<int>(thisPtr.size()); }, { { { "Container", "The container to get the size of", nullptr, {} } } })
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Get Size", "Containers"))
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Method("clear", &ContainerType::clear)
|
||||
->template Method<typename ContainerType::reference(ContainerType::*)(typename ContainerType::size_type)>(k_accessElementName, &ContainerType::at, { { { "Index", "The index to read from", nullptr, BehaviorParameter::Traits::TR_INDEX } } })
|
||||
->Method("Capacity", &ContainerType::capacity)
|
||||
->Method("Clear", [](ContainerType& thisContainer)->ContainerType& { thisContainer.clear(); return thisContainer; }, { { { "Container", "The container to clear", nullptr, {} } } })
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Clear All Elements", "Containers"))
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::OverloadArgumentGroup, AZ::OverloadArgumentGroupInfo({ "ContainerGroup" }, { "ContainerGroup" }))
|
||||
->Method("Empty", &ContainerType::empty, { { { "Container", "The container to check if it is empty", nullptr, {} } } })
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Is Empty", "Containers"))
|
||||
@@ -798,10 +791,8 @@ namespace AZ
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
->template Constructor<const T1&, const T2&>()
|
||||
->Property("first", [](ContainerType& thisPtr) { return thisPtr.first; }, [](ContainerType& thisPtr, const T1& value) { thisPtr.first = value; })
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::TupleGetFunctionIndex, 0)
|
||||
->Property("second", [](ContainerType& thisPtr) { return thisPtr.second; }, [](ContainerType& thisPtr, const T2& value) { thisPtr.second = value; })
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::TupleGetFunctionIndex, 1)
|
||||
->Method("ConstructTuple", [](const T1& first, const T2& second) { return AZStd::make_pair(first, second); })
|
||||
;
|
||||
@@ -1013,7 +1004,6 @@ namespace AZ
|
||||
->Method("Clear", [](ContainerType& thisContainer)->ContainerType& { thisContainer.clear(); return thisContainer; })
|
||||
->Attribute(AZ::Script::Attributes::TreatAsMemberFunction, AZ::AttributeIsValid::IfPresent)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::ExplicitOverloadCrc, ExplicitOverloadInfo("Clear All Elements", "Containers"))
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::OverloadArgumentGroup, AZ::OverloadArgumentGroupInfo({ "ContainerGroup" }, { "ContainerGroup" }))
|
||||
->Method(k_iteratorConstructorName, &Iterate_VM)
|
||||
;
|
||||
|
||||
@@ -43,6 +43,9 @@ namespace AZ
|
||||
{
|
||||
const static AZ::Crc32 RuntimeEBusAttribute = AZ_CRC("RuntimeEBus", 0x466b899b); ///< Signals that this reflected ebus should only be available at runtime, helps tools filter out data driven ebuses
|
||||
|
||||
constexpr const char* k_PropertyNameGetterSuffix = "::Getter";
|
||||
constexpr const char* k_PropertyNameSetterSuffix = "::Setter";
|
||||
|
||||
/// Typedef for class unwrapping callback (i.e. used for things like smart_ptr<T> to unwrap for T)
|
||||
using BehaviorClassUnwrapperFunction = void(*)(void* /*classPtr*/, void*& /*unwrappedClass*/, AZ::Uuid& /*unwrappedClassTypeId*/, void* /*userData*/);
|
||||
|
||||
@@ -2525,7 +2528,7 @@ namespace AZ
|
||||
getterPropertyName += "::";
|
||||
}
|
||||
getterPropertyName += m_name;
|
||||
getterPropertyName += "::Getter";
|
||||
getterPropertyName += k_PropertyNameGetterSuffix;
|
||||
m_getter = aznew GetterType(getter, context, getterPropertyName);
|
||||
|
||||
if (AZStd::is_class<typename GetterType::ClassType>::value)
|
||||
@@ -2603,7 +2606,7 @@ namespace AZ
|
||||
setterPropertyName += "::";
|
||||
}
|
||||
setterPropertyName += m_name;
|
||||
setterPropertyName += "::Setter";
|
||||
setterPropertyName += k_PropertyNameSetterSuffix;
|
||||
m_setter = aznew SetterType(setter, context, setterPropertyName);
|
||||
if (AZStd::is_class<typename SetterType::ClassType>::value)
|
||||
{
|
||||
|
||||
@@ -243,6 +243,28 @@ namespace AZ
|
||||
return variance;
|
||||
}
|
||||
|
||||
void RemovePropertyGetterNameArtifacts(AZStd::string& name)
|
||||
{
|
||||
if (name.ends_with(k_PropertyNameGetterSuffix))
|
||||
{
|
||||
AZ::StringFunc::Replace(name, k_PropertyNameGetterSuffix, "");
|
||||
}
|
||||
}
|
||||
|
||||
void RemovePropertySetterNameArtifacts(AZStd::string& name)
|
||||
{
|
||||
if (name.ends_with(k_PropertyNameSetterSuffix))
|
||||
{
|
||||
AZ::StringFunc::Replace(name, k_PropertyNameSetterSuffix, "");
|
||||
}
|
||||
}
|
||||
|
||||
void RemovePropertyNameArtifacts(AZStd::string& name)
|
||||
{
|
||||
RemovePropertyGetterNameArtifacts(name);
|
||||
RemovePropertySetterNameArtifacts(name);
|
||||
}
|
||||
|
||||
AZStd::string ReplaceCppArtifacts(AZStd::string_view sourceName)
|
||||
{
|
||||
using namespace AZ::StringFunc;
|
||||
|
||||
@@ -68,6 +68,12 @@ namespace AZ
|
||||
|
||||
AZStd::vector<AZStd::pair<const BehaviorMethod*, const BehaviorClass*>> OverloadsToVector(const BehaviorMethod&, const BehaviorClass*);
|
||||
|
||||
void RemovePropertyGetterNameArtifacts(AZStd::string& name);
|
||||
|
||||
void RemovePropertySetterNameArtifacts(AZStd::string& name);
|
||||
|
||||
void RemovePropertyNameArtifacts(AZStd::string& name);
|
||||
|
||||
AZStd::string ReplaceCppArtifacts(AZStd::string_view sourceName);
|
||||
|
||||
void StripQualifiers(AZStd::string& name);
|
||||
|
||||
@@ -1600,7 +1600,7 @@ static int Global_Typeid(lua_State* l)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef LUA_LUMBERYARD_EXTENSIONS
|
||||
#ifdef LUA_O3DE_EXTENSIONS
|
||||
|
||||
//=========================================================================
|
||||
// LUA Dummy Node Extension
|
||||
@@ -1631,7 +1631,7 @@ LUA_API const Node* lua_getDummyNode()
|
||||
return &(*s_luaDummyNodeVariable);
|
||||
}
|
||||
|
||||
#endif // LUA_LUMBERYARD_EXTENSIONS
|
||||
#endif // LUA_O3DE_EXTENSIONS
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -51,11 +51,11 @@ namespace AZ
|
||||
const static AZ::Crc32 ExcludeFrom = AZ_CRC("ExcludeFrom", 0xa98972fe);
|
||||
enum ExcludeFlags : AZ::u64
|
||||
{
|
||||
List = 1 << 0,
|
||||
Documentation = 1 << 1,
|
||||
Preview = 1 << 2,
|
||||
ListOnly = 1 << 3,
|
||||
All = (List | Documentation | Preview)
|
||||
List = 1 << 0, //< The reflected item will be excluded from any list (e.g. node palette)
|
||||
Documentation = 1 << 1, //< The reflected item will be excluded from the Lua class reference
|
||||
Unused = 1 << 2, //< This flag is unused (deprecated)
|
||||
ListOnly = 1 << 3, //< Some elements should be excluded from lists, but available for documentation
|
||||
All = (List | Documentation) //< Used to exclude reflections from lists and documentation
|
||||
};
|
||||
|
||||
//! Used to specify the usage of a Behavior Context element (e.g. Class or EBus) designed for automation scripts
|
||||
|
||||
@@ -929,7 +929,6 @@ void ScriptSystemComponent::Reflect(ReflectContext* reflection)
|
||||
Debug::TraceReflect(behaviorContext);
|
||||
|
||||
behaviorContext->Class<PlatformID>("Platform")
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
|
||||
->Enum<static_cast<int>(PlatformID::PLATFORM_WINDOWS_64)>("Windows64")
|
||||
->Enum<static_cast<int>(PlatformID::PLATFORM_LINUX_64)>("Linux")
|
||||
->Enum<static_cast<int>(PlatformID::PLATFORM_ANDROID_64)>("Android64")
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace AZ
|
||||
const static AZ::Crc32 ChangeNotify = AZ_CRC("ChangeNotify", 0xf793bc19);
|
||||
const static AZ::Crc32 ClearNotify = AZ_CRC("ClearNotify", 0x88914c8c);
|
||||
|
||||
//! Specifies a function to accept or reject a value changed in the Lumberyard Editor.
|
||||
//! Specifies a function to accept or reject a value changed in the Open 3D Engine Editor.
|
||||
//! For example, a component could reject AZ::EntityId values that reference its own entity.
|
||||
//!
|
||||
//! Element type to use this with: Any type that you reflect using AZ::EditContext::ClassInfo::DataElement().
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace AZ
|
||||
// JsonBaseContext
|
||||
//
|
||||
|
||||
JsonBaseContext::JsonBaseContext(JsonSerializationMetadata metadata, JsonSerializationResult::JsonIssueCallback reporting,
|
||||
JsonBaseContext::JsonBaseContext(JsonSerializationMetadata& metadata, JsonSerializationResult::JsonIssueCallback reporting,
|
||||
StackedString::Format pathFormat, SerializeContext* serializeContext, JsonRegistrationContext* registrationContext)
|
||||
: m_metadata(AZStd::move(metadata))
|
||||
: m_metadata(metadata)
|
||||
, m_serializeContext(serializeContext)
|
||||
, m_registrationContext(registrationContext)
|
||||
, m_path(pathFormat)
|
||||
@@ -126,20 +126,13 @@ namespace AZ
|
||||
// JsonDeserializerContext
|
||||
//
|
||||
|
||||
JsonDeserializerContext::JsonDeserializerContext(const JsonDeserializerSettings& settings)
|
||||
JsonDeserializerContext::JsonDeserializerContext(JsonDeserializerSettings& settings)
|
||||
: JsonBaseContext(settings.m_metadata, settings.m_reporting,
|
||||
StackedString::Format::JsonPointer, settings.m_serializeContext, settings.m_registrationContext)
|
||||
, m_clearContainers(settings.m_clearContainers)
|
||||
{
|
||||
}
|
||||
|
||||
JsonDeserializerContext::JsonDeserializerContext(JsonDeserializerSettings&& settings)
|
||||
: JsonBaseContext(AZStd::move(settings.m_metadata), AZStd::move(settings.m_reporting),
|
||||
StackedString::Format::JsonPointer, settings.m_serializeContext, settings.m_registrationContext)
|
||||
, m_clearContainers(settings.m_clearContainers)
|
||||
{
|
||||
}
|
||||
|
||||
bool JsonDeserializerContext::ShouldClearContainers() const
|
||||
{
|
||||
return m_clearContainers;
|
||||
@@ -151,7 +144,7 @@ namespace AZ
|
||||
// JsonSerializerContext
|
||||
//
|
||||
|
||||
JsonSerializerContext::JsonSerializerContext(const JsonSerializerSettings& settings, rapidjson::Document::AllocatorType& jsonAllocator)
|
||||
JsonSerializerContext::JsonSerializerContext(JsonSerializerSettings& settings, rapidjson::Document::AllocatorType& jsonAllocator)
|
||||
: JsonBaseContext(settings.m_metadata, settings.m_reporting, StackedString::Format::ContextPath,
|
||||
settings.m_serializeContext, settings.m_registrationContext)
|
||||
, m_jsonAllocator(jsonAllocator)
|
||||
@@ -159,14 +152,6 @@ namespace AZ
|
||||
{
|
||||
}
|
||||
|
||||
JsonSerializerContext::JsonSerializerContext(JsonSerializerSettings&& settings, rapidjson::Document::AllocatorType& jsonAllocator)
|
||||
: JsonBaseContext(AZStd::move(settings.m_metadata), AZStd::move(settings.m_reporting), StackedString::Format::ContextPath,
|
||||
settings.m_serializeContext, settings.m_registrationContext)
|
||||
, m_jsonAllocator(jsonAllocator)
|
||||
, m_keepDefaults(settings.m_keepDefaults)
|
||||
{
|
||||
}
|
||||
|
||||
rapidjson::Document::AllocatorType& JsonSerializerContext::GetJsonAllocator()
|
||||
{
|
||||
return m_jsonAllocator;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace AZ
|
||||
class JsonBaseContext
|
||||
{
|
||||
public:
|
||||
JsonBaseContext(JsonSerializationMetadata metadata, JsonSerializationResult::JsonIssueCallback reporting,
|
||||
JsonBaseContext(JsonSerializationMetadata& metadata, JsonSerializationResult::JsonIssueCallback reporting,
|
||||
StackedString::Format pathFormat, SerializeContext* serializeContext, JsonRegistrationContext* registrationContext);
|
||||
virtual ~JsonBaseContext() = default;
|
||||
|
||||
@@ -71,10 +71,6 @@ namespace AZ
|
||||
const JsonRegistrationContext* GetRegistrationContext() const;
|
||||
|
||||
protected:
|
||||
//! Metadata that's passed in by the settings as additional configuration options or metadata that's collected
|
||||
//! during processing for later use.
|
||||
JsonSerializationMetadata m_metadata;
|
||||
|
||||
//! Callback used to report progress and issues. Users of the serialization can update the return code to change
|
||||
//! the behavior of the serializer.
|
||||
AZStd::stack<JsonSerializationResult::JsonIssueCallback> m_reporters;
|
||||
@@ -82,6 +78,10 @@ namespace AZ
|
||||
//! Path to the element that's currently being operated on.
|
||||
StackedString m_path;
|
||||
|
||||
//! Metadata that's passed in by the settings as additional configuration options or metadata that's collected
|
||||
//! during processing for later use.
|
||||
JsonSerializationMetadata& m_metadata;
|
||||
|
||||
//! The Serialize Context that can be used to retrieve meta data during processing.
|
||||
SerializeContext* m_serializeContext = nullptr;
|
||||
//! The registration context for the json serialization. This can be used to retrieve the handlers for specific types.
|
||||
@@ -92,8 +92,7 @@ namespace AZ
|
||||
: public JsonBaseContext
|
||||
{
|
||||
public:
|
||||
explicit JsonDeserializerContext(const JsonDeserializerSettings& settings);
|
||||
explicit JsonDeserializerContext(JsonDeserializerSettings&& settings);
|
||||
explicit JsonDeserializerContext(JsonDeserializerSettings& settings);
|
||||
~JsonDeserializerContext() override = default;
|
||||
|
||||
JsonDeserializerContext(const JsonDeserializerContext&) = delete;
|
||||
@@ -114,8 +113,7 @@ namespace AZ
|
||||
: public JsonBaseContext
|
||||
{
|
||||
public:
|
||||
explicit JsonSerializerContext(const JsonSerializerSettings& settings, rapidjson::Document::AllocatorType& jsonAllocator);
|
||||
explicit JsonSerializerContext(JsonSerializerSettings&& settings, rapidjson::Document::AllocatorType& jsonAllocator);
|
||||
JsonSerializerContext(JsonSerializerSettings& settings, rapidjson::Document::AllocatorType& jsonAllocator);
|
||||
~JsonSerializerContext() override = default;
|
||||
|
||||
JsonSerializerContext(const JsonSerializerContext&) = delete;
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ByteStreamSerializer.h"
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Serialization/Json/JsonSerialization.h>
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace ByteSerializerInternal
|
||||
{
|
||||
static JsonSerializationResult::Result Load(void* outputValue, const rapidjson::Value& inputValue, JsonDeserializerContext& context)
|
||||
{
|
||||
using JsonSerializationResult::Outcomes;
|
||||
using JsonSerializationResult::Tasks;
|
||||
|
||||
AZ_Assert(outputValue, "Expected a valid pointer to load from json value.");
|
||||
|
||||
switch (inputValue.GetType())
|
||||
{
|
||||
case rapidjson::kStringType: {
|
||||
JsonByteStream buffer;
|
||||
if (AZ::StringFunc::Base64::Decode(buffer, inputValue.GetString(), inputValue.GetStringLength()))
|
||||
{
|
||||
JsonByteStream* valAsByteStream = static_cast<JsonByteStream*>(outputValue);
|
||||
*valAsByteStream = AZStd::move(buffer);
|
||||
return context.Report(Tasks::ReadField, Outcomes::Success, "Successfully read ByteStream.");
|
||||
}
|
||||
return context.Report(Tasks::ReadField, Outcomes::Invalid, "Decode of Base64 encoded ByteStream failed.");
|
||||
}
|
||||
case rapidjson::kArrayType:
|
||||
case rapidjson::kObjectType:
|
||||
case rapidjson::kNullType:
|
||||
case rapidjson::kFalseType:
|
||||
case rapidjson::kTrueType:
|
||||
case rapidjson::kNumberType:
|
||||
return context.Report(
|
||||
Tasks::ReadField, Outcomes::Unsupported,
|
||||
"Unsupported type. ByteStream values cannot be read from arrays, objects, nulls, booleans or numbers.");
|
||||
default:
|
||||
return context.Report(Tasks::ReadField, Outcomes::Unknown, "Unknown json type encountered for ByteStream value.");
|
||||
}
|
||||
}
|
||||
|
||||
static JsonSerializationResult::Result StoreWithDefault(
|
||||
rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue, JsonSerializerContext& context)
|
||||
{
|
||||
using JsonSerializationResult::Outcomes;
|
||||
using JsonSerializationResult::Tasks;
|
||||
|
||||
const JsonByteStream& valAsByteStream = *static_cast<const JsonByteStream*>(inputValue);
|
||||
if (context.ShouldKeepDefaults() || !defaultValue || (valAsByteStream != *static_cast<const JsonByteStream*>(defaultValue)))
|
||||
{
|
||||
const auto base64ByteStream = AZ::StringFunc::Base64::Encode(valAsByteStream.data(), valAsByteStream.size());
|
||||
outputValue.SetString(base64ByteStream.c_str(), base64ByteStream.size(), context.GetJsonAllocator());
|
||||
return context.Report(Tasks::WriteValue, Outcomes::Success, "ByteStream successfully stored.");
|
||||
}
|
||||
|
||||
return context.Report(Tasks::WriteValue, Outcomes::DefaultsUsed, "Default ByteStream used.");
|
||||
}
|
||||
} // namespace ByteSerializerInternal
|
||||
|
||||
AZ_CLASS_ALLOCATOR_IMPL(JsonByteStreamSerializer, SystemAllocator, 0);
|
||||
|
||||
JsonSerializationResult::Result JsonByteStreamSerializer::Load(
|
||||
void* outputValue, [[maybe_unused]] const Uuid& outputValueTypeId, const rapidjson::Value& inputValue,
|
||||
JsonDeserializerContext& context)
|
||||
{
|
||||
AZ_Assert(
|
||||
azrtti_typeid<JsonByteStream>() == outputValueTypeId,
|
||||
"Unable to deserialize AZStd::vector<AZ::u8>> to json because the provided type is %s",
|
||||
outputValueTypeId.ToString<AZStd::string>().c_str());
|
||||
|
||||
return ByteSerializerInternal::Load(outputValue, inputValue, context);
|
||||
}
|
||||
|
||||
JsonSerializationResult::Result JsonByteStreamSerializer::Store(
|
||||
rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue, [[maybe_unused]] const Uuid& valueTypeId,
|
||||
JsonSerializerContext& context)
|
||||
{
|
||||
AZ_Assert(
|
||||
azrtti_typeid<JsonByteStream>() == valueTypeId,
|
||||
"Unable to serialize AZStd::vector<AZ::u8> to json because the provided type is %s",
|
||||
valueTypeId.ToString<AZStd::string>().c_str());
|
||||
|
||||
return ByteSerializerInternal::StoreWithDefault(outputValue, inputValue, defaultValue, context);
|
||||
}
|
||||
} // namespace AZ
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Serialization/Json/BaseJsonSerializer.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
using JsonByteStream = AZStd::vector<AZ::u8>; //!< Alias for AZStd::vector<AZ::u8>.
|
||||
|
||||
//! Serialize a stream of bytes (usually binary data) as a json string value.
|
||||
//! @note Related to GenericClassByteStream (part of SerializeGenericTypeInfo<AZStd::vector<AZ::u8>> - see AZStdContainers.inl for more
|
||||
//! details).
|
||||
class JsonByteStreamSerializer : public BaseJsonSerializer
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(JsonByteStreamSerializer, "{30F0EA5A-CD13-4BA7-BAE1-D50D851CAC45}", BaseJsonSerializer);
|
||||
AZ_CLASS_ALLOCATOR_DECL;
|
||||
|
||||
JsonSerializationResult::Result Load(
|
||||
void* outputValue, const Uuid& outputValueTypeId, const rapidjson::Value& inputValue,
|
||||
JsonDeserializerContext& context) override;
|
||||
JsonSerializationResult::Result Store(
|
||||
rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue, const Uuid& valueTypeId,
|
||||
JsonSerializerContext& context) override;
|
||||
};
|
||||
} // namespace AZ
|
||||
@@ -20,7 +20,7 @@ namespace AZ
|
||||
{
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch,
|
||||
const JsonApplyPatchSettings& settings)
|
||||
JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::CreatePatch(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, const JsonCreatePatchSettings& settings)
|
||||
const rapidjson::Value& target, JsonCreatePatchSettings& settings)
|
||||
{
|
||||
StackedString element(StackedString::Format::JsonPointer);
|
||||
return CreatePatchInternal(patch.SetArray(), allocator, source, target, element, settings);
|
||||
@@ -130,7 +130,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyMergePatch(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch,
|
||||
const JsonApplyPatchSettings& settings)
|
||||
JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -196,14 +196,14 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::CreateMergePatch(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, const JsonCreatePatchSettings& settings)
|
||||
const rapidjson::Value& target, JsonCreatePatchSettings& settings)
|
||||
{
|
||||
StackedString element(StackedString::Format::JsonPointer);
|
||||
return CreateMergePatchInternal(patch, allocator, source, target, element, settings);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_GetFromValue(rapidjson::Value** fromValue, rapidjson::Pointer& fromPointer,
|
||||
rapidjson::Value& target, const rapidjson::Value& entry, StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
rapidjson::Value& target, const rapidjson::Value& entry, StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Add(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& entry, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_AddValue(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Pointer& path, rapidjson::Value&& newValue,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Remove(rapidjson::Value& target, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -399,7 +399,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Replace(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& entry, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -426,7 +426,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Move(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& entry, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Copy(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& entry, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -463,7 +463,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::ApplyPatch_Test(rapidjson::Value& target, const rapidjson::Value& entry,
|
||||
const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings)
|
||||
const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -495,7 +495,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::CreatePatchInternal(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, StackedString& element, const JsonCreatePatchSettings& settings)
|
||||
const rapidjson::Value& target, StackedString& element, JsonCreatePatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -633,7 +633,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::ResultCode JsonMerger::CreateMergePatchInternal(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, StackedString& element, const JsonCreatePatchSettings& settings)
|
||||
const rapidjson::Value& target, StackedString& element, JsonCreatePatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
|
||||
@@ -30,43 +30,43 @@ namespace AZ
|
||||
//! Implementation of the JSON Patch algorithm: https://tools.ietf.org/html/rfc6902
|
||||
static JsonSerializationResult::ResultCode ApplyPatch(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch,
|
||||
const JsonApplyPatchSettings& settings);
|
||||
JsonApplyPatchSettings& settings);
|
||||
|
||||
//! Function to create JSON Patches: https://tools.ietf.org/html/rfc6902
|
||||
static JsonSerializationResult::ResultCode CreatePatch(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, const JsonCreatePatchSettings& settings);
|
||||
const rapidjson::Value& target, JsonCreatePatchSettings& settings);
|
||||
|
||||
//! Implementation of the JSON Merge Patch algorithm: https://tools.ietf.org/html/rfc7386
|
||||
static JsonSerializationResult::ResultCode ApplyMergePatch(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch,
|
||||
const JsonApplyPatchSettings& settings);
|
||||
JsonApplyPatchSettings& settings);
|
||||
|
||||
//! Function to create JSON Merge Patches: https://tools.ietf.org/html/rfc7386
|
||||
static JsonSerializationResult::ResultCode CreateMergePatch(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, const JsonCreatePatchSettings& settings);
|
||||
const rapidjson::Value& target, JsonCreatePatchSettings& settings);
|
||||
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_GetFromValue(rapidjson::Value** fromValue, rapidjson::Pointer& fromPointer,
|
||||
rapidjson::Value& target, const rapidjson::Value& entry, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
rapidjson::Value& target, const rapidjson::Value& entry, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Add(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_AddValue(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Pointer& path, rapidjson::Value&& newValue, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Pointer& path, rapidjson::Value&& newValue, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Remove(rapidjson::Value& target, const rapidjson::Pointer& path,
|
||||
StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Replace(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Move(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Copy(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
static JsonSerializationResult::ResultCode ApplyPatch_Test(rapidjson::Value& target,
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, const JsonApplyPatchSettings& settings);
|
||||
const rapidjson::Value& entry, const rapidjson::Pointer& path, StackedString& element, JsonApplyPatchSettings& settings);
|
||||
|
||||
static JsonSerializationResult::ResultCode CreatePatchInternal(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, StackedString& element, const JsonCreatePatchSettings& settings);
|
||||
const rapidjson::Value& target, StackedString& element, JsonCreatePatchSettings& settings);
|
||||
static rapidjson::Value CreatePatchInternal_Add(rapidjson::Document::AllocatorType& allocator,
|
||||
StackedString& path, const rapidjson::Value& value);
|
||||
static rapidjson::Value CreatePatchInternal_Remove(rapidjson::Document::AllocatorType& allocator, StackedString& path);
|
||||
@@ -75,6 +75,6 @@ namespace AZ
|
||||
|
||||
static JsonSerializationResult::ResultCode CreateMergePatchInternal(rapidjson::Value& patch,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, StackedString& element, const JsonCreatePatchSettings& settings);
|
||||
const rapidjson::Value& target, StackedString& element, JsonCreatePatchSettings& settings);
|
||||
};
|
||||
} // namespace AZ
|
||||
|
||||
@@ -97,9 +97,18 @@ namespace AZ
|
||||
}
|
||||
} // namespace JsonSerializationInternal
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::ApplyPatch(
|
||||
rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch, JsonMergeApproach approach,
|
||||
const JsonApplyPatchSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonApplyPatchSettings settingsCopy{ settings };
|
||||
return ApplyPatch(target, allocator, patch, approach, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::ApplyPatch(rapidjson::Value& target,
|
||||
rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch, JsonMergeApproach approach,
|
||||
JsonApplyPatchSettings settings)
|
||||
JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -126,8 +135,17 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::ApplyPatch(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& patch, JsonMergeApproach approach, const JsonApplyPatchSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonApplyPatchSettings settingsCopy{settings};
|
||||
return ApplyPatch(output, allocator, source, patch, approach, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::ApplyPatch(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& source, const rapidjson::Value& patch, JsonMergeApproach approach, JsonApplyPatchSettings settings)
|
||||
const rapidjson::Value& source, const rapidjson::Value& patch, JsonMergeApproach approach, JsonApplyPatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -166,9 +184,18 @@ namespace AZ
|
||||
return result;
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::CreatePatch(
|
||||
rapidjson::Value& patch, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, JsonMergeApproach approach, const JsonCreatePatchSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonCreatePatchSettings settingsCopy{settings};
|
||||
return CreatePatch(patch, allocator, source, target, approach, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::CreatePatch(rapidjson::Value& patch, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& source, const rapidjson::Value& target, JsonMergeApproach approach, JsonCreatePatchSettings settings)
|
||||
JsonSerializationResult::ResultCode JsonSerialization::CreatePatch(
|
||||
rapidjson::Value& patch, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, JsonMergeApproach approach, JsonCreatePatchSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -194,7 +221,16 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(void* object, const Uuid& objectType, const rapidjson::Value& root, JsonDeserializerSettings settings)
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(
|
||||
void* object, const Uuid& objectType, const rapidjson::Value& root, const JsonDeserializerSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonDeserializerSettings settingsCopy{settings};
|
||||
return Load(object, objectType, root, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(
|
||||
void* object, const Uuid& objectType, const rapidjson::Value& root, JsonDeserializerSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -212,14 +248,23 @@ namespace AZ
|
||||
if (result.GetOutcome() == Outcomes::Success)
|
||||
{
|
||||
StackedString path(StackedString::Format::JsonPointer);
|
||||
JsonDeserializerContext context(AZStd::move(settings));
|
||||
JsonDeserializerContext context(settings);
|
||||
result = JsonDeserializer::Load(object, objectType, root, context);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::LoadTypeId(
|
||||
Uuid& typeId, const rapidjson::Value& input, const Uuid* baseClassTypeId, AZStd::string_view jsonPath,
|
||||
const JsonDeserializerSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonDeserializerSettings settingsCopy{settings};
|
||||
return LoadTypeId(typeId, input, baseClassTypeId, jsonPath, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::LoadTypeId(Uuid& typeId, const rapidjson::Value& input,
|
||||
const Uuid* baseClassTypeId, AZStd::string_view jsonPath, JsonDeserializerSettings settings)
|
||||
const Uuid* baseClassTypeId, AZStd::string_view jsonPath, JsonDeserializerSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -236,7 +281,7 @@ namespace AZ
|
||||
ResultCode result = JsonSerializationInternal::GetContexts(settings, settings.m_serializeContext, settings.m_registrationContext);
|
||||
if (result.GetOutcome() == Outcomes::Success)
|
||||
{
|
||||
JsonDeserializerContext context(AZStd::move(settings));
|
||||
JsonDeserializerContext context(settings);
|
||||
context.PushPath(jsonPath);
|
||||
|
||||
result = JsonDeserializer::LoadTypeId(typeId, input, context, baseClassTypeId);
|
||||
@@ -244,8 +289,18 @@ namespace AZ
|
||||
return result;
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const void* object, const void* defaultObject, const Uuid& objectType, JsonSerializerSettings settings)
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const void* object, const void* defaultObject,
|
||||
const Uuid& objectType, const JsonSerializerSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonSerializerSettings settingsCopy{settings};
|
||||
return Store(output, allocator, object, defaultObject, objectType, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const void* object, const void* defaultObject,
|
||||
const Uuid& objectType, JsonSerializerSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -269,15 +324,24 @@ namespace AZ
|
||||
settings.m_keepDefaults = false;
|
||||
}
|
||||
|
||||
JsonSerializerContext context(AZStd::move(settings), allocator);
|
||||
JsonSerializerContext context(settings, allocator);
|
||||
StackedString path(StackedString::Format::ContextPath);
|
||||
result = JsonSerializer::Store(output, object, defaultObject, objectType, context);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::StoreTypeId(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const Uuid& typeId, AZStd::string_view elementPath,
|
||||
const JsonSerializerSettings& settings)
|
||||
{
|
||||
// Explicitly make a copy to call the correct overloaded version and avoid infinite recursion on this function.
|
||||
JsonSerializerSettings settingsCopy{settings};
|
||||
return StoreTypeId(output, allocator, typeId, elementPath, settingsCopy);
|
||||
}
|
||||
|
||||
JsonSerializationResult::ResultCode JsonSerialization::StoreTypeId(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const Uuid& typeId, AZStd::string_view elementPath, JsonSerializerSettings settings)
|
||||
const Uuid& typeId, AZStd::string_view elementPath, JsonSerializerSettings& settings)
|
||||
{
|
||||
using namespace JsonSerializationResult;
|
||||
|
||||
@@ -294,7 +358,7 @@ namespace AZ
|
||||
ResultCode result = JsonSerializationInternal::GetContexts(settings, settings.m_serializeContext, settings.m_registrationContext);
|
||||
if (result.GetOutcome() == Outcomes::Success)
|
||||
{
|
||||
JsonSerializerContext context(AZStd::move(settings), allocator);
|
||||
JsonSerializerContext context(settings, allocator);
|
||||
context.PushPath(elementPath);
|
||||
result = JsonSerializer::StoreTypeName(output, typeId, context);
|
||||
}
|
||||
|
||||
@@ -48,14 +48,25 @@ namespace AZ
|
||||
|
||||
//! Merges two json values together by applying "patch" to "target" using the selected merge algorithm.
|
||||
//! This version of ApplyPatch is destructive to "target". If the patch can't be correctly applied it will
|
||||
//! leave target in a partially patched state. Use the over version of ApplyPatch if target should be copied.
|
||||
//! leave target in a partially patched state. Use the other version of ApplyPatch if target should be copied.
|
||||
//! @param target The value where the patch will be applied to.
|
||||
//! @param allocator The allocator associated with the document that holds the target.
|
||||
//! @param patch The value holding the patch information.
|
||||
//! @param approach The merge algorithm that will be used to apply the patch on top of the target.
|
||||
//! @param settings Optional additional settings to control the way the patch is applied.
|
||||
static JsonSerializationResult::ResultCode ApplyPatch(rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& patch, JsonMergeApproach approach, JsonApplyPatchSettings settings = JsonApplyPatchSettings{});
|
||||
const rapidjson::Value& patch, JsonMergeApproach approach, const JsonApplyPatchSettings& settings = JsonApplyPatchSettings{});
|
||||
//! Merges two json values together by applying "patch" to "target" using the selected merge algorithm.
|
||||
//! This version of ApplyPatch is destructive to "target". If the patch can't be correctly applied it will
|
||||
//! leave target in a partially patched state. Use the other version of ApplyPatch if target should be copied.
|
||||
//! @param target The value where the patch will be applied to.
|
||||
//! @param allocator The allocator associated with the document that holds the target.
|
||||
//! @param patch The value holding the patch information.
|
||||
//! @param approach The merge algorithm that will be used to apply the patch on top of the target.
|
||||
//! @param settings Additional settings to control the way the patch is applied.
|
||||
static JsonSerializationResult::ResultCode ApplyPatch(
|
||||
rapidjson::Value& target, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& patch,
|
||||
JsonMergeApproach approach, JsonApplyPatchSettings& settings);
|
||||
|
||||
//! Merges two json values together by applying "patch" to a copy of "output" and written to output using the
|
||||
//! selected merge algorithm. This version of ApplyPatch is non-destructive to "source". If the patch couldn't be
|
||||
@@ -68,7 +79,19 @@ namespace AZ
|
||||
//! @param settings Optional additional settings to control the way the patch is applied.
|
||||
static JsonSerializationResult::ResultCode ApplyPatch(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& source, const rapidjson::Value& patch, JsonMergeApproach approach,
|
||||
JsonApplyPatchSettings settings = JsonApplyPatchSettings{});
|
||||
const JsonApplyPatchSettings& settings = JsonApplyPatchSettings{});
|
||||
//! Merges two json values together by applying "patch" to a copy of "output" and written to output using the
|
||||
//! selected merge algorithm. This version of ApplyPatch is non-destructive to "source". If the patch couldn't be
|
||||
//! fully applied "output" will be left set to an empty (default) object.
|
||||
//! @param source A copy of source with the patch applied to it or an empty object if the patch couldn't be applied.
|
||||
//! @param allocator The allocator associated with the document that holds the source.
|
||||
//! @param target The value where the patch will be applied to.
|
||||
//! @param patch The value holding the patch information.
|
||||
//! @param approach The merge algorithm that will be used to apply the patch on top of the target.
|
||||
//! @param settings Additional settings to control the way the patch is applied.
|
||||
static JsonSerializationResult::ResultCode ApplyPatch(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& patch, JsonMergeApproach approach, JsonApplyPatchSettings& settings);
|
||||
|
||||
//! Creates a patch using the selected merge algorithm such that when applied to source it results in target.
|
||||
//! @param patch The value containing the differences between source and target.
|
||||
@@ -79,22 +102,46 @@ namespace AZ
|
||||
//! @param settings Optional additional settings to control the way the patch is created.
|
||||
static JsonSerializationResult::ResultCode CreatePatch(rapidjson::Value& patch, rapidjson::Document::AllocatorType& allocator,
|
||||
const rapidjson::Value& source, const rapidjson::Value& target, JsonMergeApproach approach,
|
||||
JsonCreatePatchSettings settings = JsonCreatePatchSettings{});
|
||||
const JsonCreatePatchSettings& settings = JsonCreatePatchSettings{});
|
||||
//! Creates a patch using the selected merge algorithm such that when applied to source it results in target.
|
||||
//! @param patch The value containing the differences between source and target.
|
||||
//! @param allocator The allocator associated with the document that will hold the patch.
|
||||
//! @param source The value used as a starting point.
|
||||
//! @param target The value that will result if the patch is applied to the source.
|
||||
//! @param approach The algorithm that will be used when the patch is applied to the source.
|
||||
//! @param settings Additional settings to control the way the patch is created.
|
||||
static JsonSerializationResult::ResultCode CreatePatch(
|
||||
rapidjson::Value& patch, rapidjson::Document::AllocatorType& allocator, const rapidjson::Value& source,
|
||||
const rapidjson::Value& target, JsonMergeApproach approach, JsonCreatePatchSettings& settings);
|
||||
|
||||
//! Loads the data from the provided json value into the supplied object. The object is expected to be created before calling load.
|
||||
//! @param object Object where the data will be loaded into.
|
||||
//! @param root The Value or Document where the deserializer will start reading data from.
|
||||
//! @param settings The settings used during deserialization. Use the value passed in from Load.
|
||||
//! @param settings Optional additional settings to control the way document is deserialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Load(T& object, const rapidjson::Value& root,
|
||||
JsonDeserializerSettings settings = JsonDeserializerSettings{});
|
||||
static JsonSerializationResult::ResultCode Load(
|
||||
T& object, const rapidjson::Value& root, const JsonDeserializerSettings& settings = JsonDeserializerSettings{});
|
||||
//! Loads the data from the provided json value into the supplied object. The object is expected to be created before calling load.
|
||||
//! @param object Object where the data will be loaded into.
|
||||
//! @param root The Value or Document where the deserializer will start reading data from.
|
||||
//! @param settings Additional settings to control the way document is deserialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Load(T& object, const rapidjson::Value& root, JsonDeserializerSettings& settings);
|
||||
//! Loads the data from the provided json value into the supplied object. The object is expected to be created before calling load.
|
||||
//! @param object Pointer to the object where the data will be loaded into.
|
||||
//! @param objectType Type id of the object passed in.
|
||||
//! @param root The Value or Document from where the deserializer will start reading data.
|
||||
//! @param settings The settings used during deserialization. Use the value passed in from Load.
|
||||
static JsonSerializationResult::ResultCode Load(void* object, const Uuid& objectType, const rapidjson::Value& root,
|
||||
JsonDeserializerSettings settings = JsonDeserializerSettings{});
|
||||
//! @param settings Optional additional settings to control the way document is deserialized.
|
||||
static JsonSerializationResult::ResultCode Load(
|
||||
void* object, const Uuid& objectType, const rapidjson::Value& root,
|
||||
const JsonDeserializerSettings& settings = JsonDeserializerSettings{});
|
||||
//! Loads the data from the provided json value into the supplied object. The object is expected to be created before calling load.
|
||||
//! @param object Pointer to the object where the data will be loaded into.
|
||||
//! @param objectType Type id of the object passed in.
|
||||
//! @param root The Value or Document from where the deserializer will start reading data.
|
||||
//! @param settings Additional settings to control the way document is deserialized.
|
||||
static JsonSerializationResult::ResultCode Load(
|
||||
void* object, const Uuid& objectType, const rapidjson::Value& root, JsonDeserializerSettings& settings);
|
||||
|
||||
//! Loads the type id from the provided input.
|
||||
//! Note: it's not recommended to use this function (frequently) as it requires users of the json file to have knowledge of the internal
|
||||
@@ -105,20 +152,44 @@ namespace AZ
|
||||
//! references multiple types then the baseClassTypeId will be used to disambiguate between the different types by looking
|
||||
//! if exactly one of the types inherits from the base class that baseClassTypeId points to.
|
||||
//! @param jsonPath An optional path to the json node. This will be used for reporting.
|
||||
//! @param settings An optional settings object to change where this function collects information from. This can be same settings
|
||||
//! @param settings Optional settings object to change where this function collects information from. This can be same settings
|
||||
//! as used for the other Load functions.
|
||||
static JsonSerializationResult::ResultCode LoadTypeId(Uuid& typeId, const rapidjson::Value& input,
|
||||
const Uuid* baseClassTypeId = nullptr, AZStd::string_view jsonPath = AZStd::string_view{},
|
||||
JsonDeserializerSettings settings = JsonDeserializerSettings{});
|
||||
const JsonDeserializerSettings& settings = JsonDeserializerSettings{});
|
||||
//! Loads the type id from the provided input.
|
||||
//! Note: it's not recommended to use this function (frequently) as it requires users of the json file to have knowledge of the
|
||||
//! internal type structure and is therefore harder to use.
|
||||
//! @param typeId The uuid where the loaded data will be written to. If loading fails this will be a null uuid.
|
||||
//! @param input The json node to load from. The node is expected to contain a string.
|
||||
//! @param baseClassTypeId. An optional type id for the base class, if known. If a type name is stored in the string which
|
||||
//! references multiple types then the baseClassTypeId will be used to disambiguate between the different types by looking
|
||||
//! if exactly one of the types inherits from the base class that baseClassTypeId points to.
|
||||
//! @param jsonPath An optional path to the json node. This will be used for reporting.
|
||||
//! @param settings Settings object to change where this function collects information from. This can be same settings
|
||||
//! as used for the other Load functions.
|
||||
static JsonSerializationResult::ResultCode LoadTypeId(
|
||||
Uuid& typeId, const rapidjson::Value& input, const Uuid* baseClassTypeId,
|
||||
AZStd::string_view jsonPath, JsonDeserializerSettings& settings);
|
||||
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
//! @param allocator The memory allocator used by RapidJSON to create the json document.
|
||||
//! @param object The object that will be read from for values to convert.
|
||||
//! @param settings The settings used during serialization. Use the value passed in from Store.
|
||||
//! @param settings Optional additional settings to control the way document is serialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const T& object, JsonSerializerSettings settings = JsonSerializerSettings{});
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object,
|
||||
const JsonSerializerSettings& settings = JsonSerializerSettings{});
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
//! @param allocator The memory allocator used by RapidJSON to create the json document.
|
||||
//! @param object The object that will be read from for values to convert.
|
||||
//! @param settings Additional settings to control the way document is serialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object,
|
||||
JsonSerializerSettings& settings);
|
||||
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
@@ -127,10 +198,23 @@ namespace AZ
|
||||
//! @param defaultObject Default object used to compare the object to in order to determine if values are
|
||||
//! defaulted or not. If this is argument is provided m_keepDefaults in the settings will automatically
|
||||
//! be set to true.
|
||||
//! @param settings The settings used during serialization. Use the value passed in from Store.
|
||||
//! @param settings Optional additional settings to control the way document is serialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const T& object, const T& defaultObject, JsonSerializerSettings settings = JsonSerializerSettings{});
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object, const T& defaultObject,
|
||||
const JsonSerializerSettings& settings = JsonSerializerSettings{});
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
//! @param allocator The memory allocator used by RapidJSON to create the json document.
|
||||
//! @param object The object that will be read from for values to convert.
|
||||
//! @param defaultObject Default object used to compare the object to in order to determine if values are
|
||||
//! defaulted or not. If this is argument is provided m_keepDefaults in the settings will automatically
|
||||
//! be set to true.
|
||||
//! @param settings Additional settings to control the way document is serialized.
|
||||
template<typename T>
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object, const T& defaultObject,
|
||||
JsonSerializerSettings& settings);
|
||||
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
@@ -140,10 +224,22 @@ namespace AZ
|
||||
//! defaulted or not. This argument can be null, in which case a temporary default may be created if required by
|
||||
//! the settings. If this is argument is provided m_keepDefaults in the settings will automatically be set to true.
|
||||
//! @param objectType The type id of the object and default object.
|
||||
//! @param settings The settings used during serialization. Use the value passed in from Store.
|
||||
static JsonSerializationResult::ResultCode Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const void* object, const void* defaultObject, const Uuid& objectType,
|
||||
JsonSerializerSettings settings = JsonSerializerSettings{});
|
||||
//! @param settings Optional additional settings to control the way document is serialized.
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const void* object, const void* defaultObject,
|
||||
const Uuid& objectType, const JsonSerializerSettings& settings = JsonSerializerSettings{});
|
||||
//! Stores the data in the provided object as json values starting at the provided value.
|
||||
//! @param output The Value or Document where the converted data will start writing to.
|
||||
//! @param allocator The memory allocator used by RapidJSON to create the json document.
|
||||
//! @param object Pointer to the object that will be read from for values to convert.
|
||||
//! @param defaultObject Pointer to a default object used to compare the object to in order to determine if values are
|
||||
//! defaulted or not. This argument can be null, in which case a temporary default may be created if required by
|
||||
//! the settings. If this is argument is provided m_keepDefaults in the settings will automatically be set to true.
|
||||
//! @param objectType The type id of the object and default object.
|
||||
//! @param settings Additional settings to control the way document is serialized.
|
||||
static JsonSerializationResult::ResultCode Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const void* object, const void* defaultObject,
|
||||
const Uuid& objectType, JsonSerializerSettings& settings);
|
||||
|
||||
//! Stores a name for the type id in the provided output. The name can be safely used to reference a type such as a class during loading.
|
||||
//! Note: it's not recommended to use this function (frequently) as it requires users of the json file to have knowledge of the internal
|
||||
@@ -152,10 +248,25 @@ namespace AZ
|
||||
//! @param allocator The allocator associated with the document that will or already holds the output.
|
||||
//! @param typeId The type id to store.
|
||||
//! @param elementPath An optional path to the element. This will be used for reporting.
|
||||
//! @param settings An optional settings object to change where this function collects information from. This can be same settings
|
||||
//! @param settings Optional settings to change where this function collects information from. This can be the same settings
|
||||
//! as used for the other Store functions.
|
||||
static JsonSerializationResult::ResultCode StoreTypeId(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const Uuid& typeId, AZStd::string_view elementPath = AZStd::string_view{}, JsonSerializerSettings settings = JsonSerializerSettings{});
|
||||
static JsonSerializationResult::ResultCode StoreTypeId(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const Uuid& typeId,
|
||||
AZStd::string_view elementPath = AZStd::string_view{}, const JsonSerializerSettings& settings = JsonSerializerSettings{});
|
||||
//! Stores a name for the type id in the provided output. The name can be safely used to reference a type such as a class during
|
||||
//! loading. Note: it's not recommended to use this function (frequently) as it requires users of the json file to have knowledge of
|
||||
//! the internal
|
||||
//! type structure and is therefore harder to use.
|
||||
//! @param output The json value the result will be written to. If successful this will contain a string object otherwise a default
|
||||
//! object.
|
||||
//! @param allocator The allocator associated with the document that will or already holds the output.
|
||||
//! @param typeId The type id to store.
|
||||
//! @param elementPath The path to the element. This will be used for reporting.
|
||||
//! @param settings Settings to change where this function collects information from. This can be the same settings
|
||||
//! as used for the other Store functions.
|
||||
static JsonSerializationResult::ResultCode StoreTypeId(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const Uuid& typeId,
|
||||
AZStd::string_view elementPath, JsonSerializerSettings& settings);
|
||||
|
||||
//! Compares two json values of any type and determines if the left is less, equal or greater than the right.
|
||||
//! @param lhs The left hand side value for the compare.
|
||||
@@ -180,22 +291,43 @@ namespace AZ
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(T& object, const rapidjson::Value& root, JsonDeserializerSettings settings)
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(T& object, const rapidjson::Value& root, const JsonDeserializerSettings& settings)
|
||||
{
|
||||
return Load(&object, azrtti_typeid(object), root, settings);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const T& object, JsonSerializerSettings settings)
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Load(T& object, const rapidjson::Value& root, JsonDeserializerSettings& settings)
|
||||
{
|
||||
return Load(&object, azrtti_typeid(object), root, settings);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object, const JsonSerializerSettings& settings)
|
||||
{
|
||||
return Store(output, allocator, &object, nullptr, azrtti_typeid(object), settings);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object, JsonSerializerSettings& settings)
|
||||
{
|
||||
return Store(output, allocator, &object, nullptr, azrtti_typeid(object), settings);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator,
|
||||
const T& object, const T& defaultObject, JsonSerializerSettings settings)
|
||||
const T& object, const T& defaultObject, const JsonSerializerSettings& settings)
|
||||
{
|
||||
return Store(output, allocator, &object,& defaultObject, azrtti_typeid(object), settings);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
JsonSerializationResult::ResultCode JsonSerialization::Store(
|
||||
rapidjson::Value& output, rapidjson::Document::AllocatorType& allocator, const T& object, const T& defaultObject,
|
||||
JsonSerializerSettings& settings)
|
||||
{
|
||||
return Store(output, allocator, &object, &defaultObject, azrtti_typeid(object), settings);
|
||||
}
|
||||
} // namespace AZ
|
||||
|
||||
@@ -22,14 +22,20 @@ namespace AZ
|
||||
class JsonSerializationMetadata final
|
||||
{
|
||||
public:
|
||||
//! Creates a new settings object in the metadata collection.
|
||||
//! Only one object of the same type can be added or created.
|
||||
//! Returns false if an object of this type was already added.
|
||||
template<typename MetadataT, typename... Args>
|
||||
bool Create(Args&&... args);
|
||||
|
||||
//! Adds a new settings object to the metadata collection.
|
||||
//! Only one object of the same type can be added.
|
||||
//! Only one object of the same type can be added or created.
|
||||
//! Returns false if an object of this type was already added.
|
||||
template<typename MetadataT>
|
||||
bool Add(MetadataT&& data);
|
||||
|
||||
//! Adds a new settings object to the metadata collection.
|
||||
//! Only one object of the same type can be added.
|
||||
//! Only one object of the same type can be added or created.
|
||||
//! Returns false if an object of this type was already added.
|
||||
template<typename MetadataT>
|
||||
bool Add(const MetadataT& data);
|
||||
|
||||
@@ -16,19 +16,31 @@
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
template<typename MetadataT>
|
||||
bool JsonSerializationMetadata::Add(MetadataT&& data)
|
||||
template<typename MetadataT, typename... Args>
|
||||
bool JsonSerializationMetadata::Create(Args&&... args)
|
||||
{
|
||||
auto typeId = azrtti_typeid<MetadataT>();
|
||||
auto iter = m_data.find(typeId);
|
||||
if (iter != m_data.end())
|
||||
const Uuid& typeId = azrtti_typeid<MetadataT>();
|
||||
if (m_data.find(typeId) != m_data.end())
|
||||
{
|
||||
AZ_Warning("JsonSerializationMetadata", false, "Metadata object of type %s already added",
|
||||
typeId.template ToString<AZStd::string>().c_str());
|
||||
AZ_Assert(false, "Metadata object of type %s already added", typeId.template ToString<AZStd::string>().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
m_data[typeId] = AZStd::any{ AZStd::forward<MetadataT>(data) };
|
||||
m_data.emplace(typeId, MetadataT{AZStd::forward<Args>(args)...});
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename MetadataT>
|
||||
bool JsonSerializationMetadata::Add(MetadataT&& data)
|
||||
{
|
||||
const Uuid& typeId = azrtti_typeid<MetadataT>();
|
||||
if (m_data.find(typeId) != m_data.end())
|
||||
{
|
||||
AZ_Assert(false, "Metadata object of type %s already added", typeId.template ToString<AZStd::string>().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
m_data.emplace(typeId, AZStd::forward<MetadataT>(data));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,7 +53,7 @@ namespace AZ
|
||||
template<typename MetadataT>
|
||||
MetadataT* JsonSerializationMetadata::Find()
|
||||
{
|
||||
const auto& typeId = azrtti_typeid<MetadataT>();
|
||||
const Uuid& typeId = azrtti_typeid<MetadataT>();
|
||||
auto iter = m_data.find(typeId);
|
||||
return iter != m_data.end() ? AZStd::any_cast<MetadataT>(&iter->second) : nullptr;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <AzCore/Serialization/Json/ArraySerializer.h>
|
||||
#include <AzCore/Serialization/Json/BasicContainerSerializer.h>
|
||||
#include <AzCore/Serialization/Json/BoolSerializer.h>
|
||||
#include <AzCore/Serialization/Json/ByteStreamSerializer.h>
|
||||
#include <AzCore/Serialization/Json/DoubleSerializer.h>
|
||||
#include <AzCore/Serialization/Json/IntSerializer.h>
|
||||
#include <AzCore/Serialization/Json/JsonSystemComponent.h>
|
||||
@@ -68,6 +69,8 @@ namespace AZ
|
||||
jsonContext->Serializer<JsonStringSerializer>()->HandlesType<AZStd::string>();
|
||||
jsonContext->Serializer<JsonOSStringSerializer>()->HandlesType<OSString>();
|
||||
|
||||
jsonContext->Serializer<JsonByteStreamSerializer>()->HandlesType<JsonByteStream>();
|
||||
|
||||
jsonContext->Serializer<JsonBasicContainerSerializer>()
|
||||
->HandlesType<AZStd::fixed_vector>()
|
||||
->HandlesType<AZStd::forward_list>()
|
||||
|
||||
@@ -1452,6 +1452,13 @@ namespace AZ
|
||||
|
||||
void* parentPtr = nodeStack.back().m_ptr;
|
||||
DataElementNode* parentDataElement = nodeStack.back().m_dataElement;
|
||||
AZ_Assert(parentDataElement, "parentDataElement is null, cannot enumerate data from data element (%s:%s)",
|
||||
m_element.m_name ? m_element.m_name : "", m_element.m_id.ToString<AZStd::string>().data());
|
||||
if (!parentDataElement)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = true;
|
||||
|
||||
if (!m_classData)
|
||||
@@ -1472,7 +1479,6 @@ namespace AZ
|
||||
if (classElementFound)
|
||||
{
|
||||
void* dataAddress = nullptr;
|
||||
void* reserveAddress = nullptr;
|
||||
IDataContainer* dataContainer = parentDataElement->m_classData->m_container;
|
||||
if (dataContainer) // container elements
|
||||
{
|
||||
@@ -1500,7 +1506,7 @@ namespace AZ
|
||||
dataAddress = reinterpret_cast<char*>(parentPtr) + classElement.m_offset;
|
||||
}
|
||||
|
||||
reserveAddress = dataAddress;
|
||||
void* reserveAddress = dataAddress;
|
||||
|
||||
// create a new instance if needed
|
||||
if (classElement.m_flags & SerializeContext::ClassElement::FLG_POINTER)
|
||||
|
||||
@@ -1471,8 +1471,7 @@ namespace AZ
|
||||
{
|
||||
return [serializeContext](AZStd::any::Action action, AZStd::any* dest, const AZStd::any* source)
|
||||
{
|
||||
auto classData = serializeContext->FindClassData(dest->type());
|
||||
AZ_Assert(classData, "Type %s stored in any must be registered with the serialize context", AZ::AzTypeInfo<ValueType>::Name());
|
||||
AZ_Assert(serializeContext->FindClassData(dest->type()), "Type %s stored in any must be registered with the serialize context", AZ::AzTypeInfo<ValueType>::Name());
|
||||
|
||||
switch (action)
|
||||
{
|
||||
|
||||
@@ -502,10 +502,9 @@ namespace AZ
|
||||
altClassElement.m_offset = 0;
|
||||
VariantSerializationInternal::SetupClassElementFromType<AltType>(altClassElement);
|
||||
const AZ::Uuid& altTypeId = altClassElement.m_typeId;
|
||||
const char* altName = AzTypeInfo<AltType>::Name();
|
||||
|
||||
const SerializeContext::ClassData* altClassData = context.FindClassData(altTypeId);
|
||||
AZ_Error("Serialize", altClassData, "Unable to find ClassData for variant alternative with name %s and typeid of %s", altName, altTypeId.ToString<AZStd::string>().data());
|
||||
AZ_Error("Serialize", altClassData, "Unable to find ClassData for variant alternative with name %s and typeid of %s", AzTypeInfo<AltType>::Name(), altTypeId.ToString<AZStd::string>().data());
|
||||
return altClassData ? callContext.m_context->EnumerateInstanceConst(&callContext, &elementAlt, altTypeId, altClassData, &altClassElement) : false;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <AzCore/JSON/pointer.h>
|
||||
#include <AzCore/JSON/prettywriter.h>
|
||||
#include <AzCore/JSON/writer.h>
|
||||
#include <AzCore/PlatformId/PlatformDefaults.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Settings/CommandLine.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
@@ -30,18 +31,6 @@
|
||||
|
||||
namespace AZ::Internal
|
||||
{
|
||||
AZ::IO::FixedMaxPath GetExecutableDirectory()
|
||||
{
|
||||
AZStd::fixed_string<AZ::IO::MaxPathLength> value;
|
||||
|
||||
// Binary folder
|
||||
AZ::Utils::ExecutablePathResult pathResult = Utils::GetExecutableDirectory(value.data(), value.capacity());
|
||||
// Update the size value of the executable directory fixed string to correctly be the length of the null-terminated string stored within it
|
||||
value.resize_no_construct(AZStd::char_traits<char>::length(value.data()));
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
AZ::SettingsRegistryInterface::FixedValueString GetEngineMonikerForProject(
|
||||
SettingsRegistryInterface& settingsRegistry, const AZ::IO::FixedMaxPath& projectPath)
|
||||
{
|
||||
@@ -144,23 +133,14 @@ namespace AZ::Internal
|
||||
|
||||
AZ::IO::FixedMaxPath ScanUpRootLocator(AZStd::string_view rootFileToLocate)
|
||||
{
|
||||
|
||||
AZStd::fixed_string<AZ::IO::MaxPathLength> executableDir;
|
||||
if (Utils::GetExecutableDirectory(executableDir.data(), executableDir.capacity()) == Utils::ExecutablePathResult::Success)
|
||||
{
|
||||
// Update the size value of the executable directory fixed string to correctly be the length of the null-terminated string
|
||||
// stored within it
|
||||
executableDir.resize_no_construct(AZStd::char_traits<char>::length(executableDir.data()));
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPath engineRootCandidate{ executableDir };
|
||||
AZ::IO::FixedMaxPath rootCandidate{ AZ::Utils::GetExecutableDirectory() };
|
||||
|
||||
bool rootPathVisited = false;
|
||||
do
|
||||
{
|
||||
if (AZ::IO::SystemFile::Exists((engineRootCandidate / rootFileToLocate).c_str()))
|
||||
if (AZ::IO::SystemFile::Exists((rootCandidate / rootFileToLocate).c_str()))
|
||||
{
|
||||
return engineRootCandidate;
|
||||
return rootCandidate;
|
||||
}
|
||||
|
||||
// Note for posix filesystems the parent directory of '/' is '/' and for windows
|
||||
@@ -168,38 +148,69 @@ namespace AZ::Internal
|
||||
|
||||
// Validate that the parent directory isn't itself, that would imply
|
||||
// that it is the filesystem root path
|
||||
AZ::IO::PathView parentPath = engineRootCandidate.ParentPath();
|
||||
rootPathVisited = (engineRootCandidate == parentPath);
|
||||
AZ::IO::PathView parentPath = rootCandidate.ParentPath();
|
||||
rootPathVisited = (rootCandidate == parentPath);
|
||||
// Recurse upwards one directory
|
||||
engineRootCandidate = AZStd::move(parentPath);
|
||||
rootCandidate = AZStd::move(parentPath);
|
||||
|
||||
} while (!rootPathVisited);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void InjectSettingToCommandLineFront(AZ::SettingsRegistryInterface& settingsRegistry,
|
||||
AZStd::string_view path, AZStd::string_view value)
|
||||
{
|
||||
AZ::CommandLine commandLine;
|
||||
AZ::SettingsRegistryMergeUtils::GetCommandLineFromRegistry(settingsRegistry, commandLine);
|
||||
AZ::CommandLine::ParamContainer paramContainer;
|
||||
commandLine.Dump(paramContainer);
|
||||
|
||||
auto projectPathOverride = AZStd::string::format(R"(--regset="%.*s=%.*s")",
|
||||
aznumeric_cast<int>(path.size()), path.data(), aznumeric_cast<int>(value.size()), value.data());
|
||||
paramContainer.emplace(paramContainer.begin(), AZStd::move(projectPathOverride));
|
||||
commandLine.Parse(paramContainer);
|
||||
AZ::SettingsRegistryMergeUtils::StoreCommandLineToRegistry(settingsRegistry, commandLine);
|
||||
}
|
||||
} // namespace AZ::Internal
|
||||
|
||||
namespace AZ::SettingsRegistryMergeUtils
|
||||
{
|
||||
constexpr AZStd::string_view InternalScanUpEngineRootKey{ "/O3DE/Settings/Internal/engine_root_scan_up_path" };
|
||||
constexpr AZStd::string_view InternalScanUpProjectRootKey{ "/O3DE/Settings/Internal/project_root_scan_up_path" };
|
||||
|
||||
AZ::IO::FixedMaxPath FindEngineRoot(SettingsRegistryInterface& settingsRegistry)
|
||||
{
|
||||
AZ::IO::FixedMaxPath engineRoot;
|
||||
|
||||
// This is the 'external' engine root key, as in passed from command-line or .setreg files.
|
||||
auto engineRootKey = SettingsRegistryInterface::FixedValueString::format("%s/engine_path", BootstrapSettingsRootKey);
|
||||
|
||||
// Step 1 Run the scan upwards logic once to find the location of the engine.json if it exist
|
||||
// Once this step is run the {InternalScanUpEngineRootKey} is set in the Settings Registry
|
||||
// to have this scan logic only run once InternalScanUpEngineRootKey the supplied registry
|
||||
if (settingsRegistry.GetType(InternalScanUpEngineRootKey) == SettingsRegistryInterface::Type::NoType)
|
||||
{
|
||||
// We can scan up from exe directory to find engine.json, use that for engine root if it exists.
|
||||
engineRoot = Internal::ScanUpRootLocator("engine.json");
|
||||
// Set the {InternalScanUpEngineRootKey} to make sure this code path isn't called again for this settings registry
|
||||
settingsRegistry.Set(InternalScanUpEngineRootKey, engineRoot.Native());
|
||||
if (!engineRoot.empty())
|
||||
{
|
||||
settingsRegistry.Set(engineRootKey, engineRoot.Native());
|
||||
// Inject the engine root into the front of the command line settings
|
||||
Internal::InjectSettingToCommandLineFront(settingsRegistry, engineRootKey, engineRoot.Native());
|
||||
return engineRoot;
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2 check if the engine_path key has been supplied
|
||||
if (settingsRegistry.Get(engineRoot.Native(), engineRootKey); !engineRoot.empty())
|
||||
{
|
||||
return engineRoot;
|
||||
}
|
||||
|
||||
// We can scan up from exe directory to find engine.json, use that for engine root if it exists.
|
||||
if (engineRoot = Internal::ScanUpRootLocator("engine.json"); !engineRoot.empty())
|
||||
{
|
||||
settingsRegistry.Set(engineRootKey, engineRoot.c_str());
|
||||
return engineRoot;
|
||||
}
|
||||
|
||||
// Step 3 locate the project root and attempt to find the engine root using the registered engine
|
||||
// for the project in the project.json file
|
||||
AZ::IO::FixedMaxPath projectRoot = FindProjectRoot(settingsRegistry);
|
||||
if (projectRoot.empty())
|
||||
{
|
||||
@@ -219,16 +230,30 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
AZ::IO::FixedMaxPath FindProjectRoot(SettingsRegistryInterface& settingsRegistry)
|
||||
{
|
||||
AZ::IO::FixedMaxPath projectRoot;
|
||||
// This is the 'external' project root key, as in passed from command-line or .setreg files.
|
||||
auto projectRootKey = SettingsRegistryInterface::FixedValueString::format("%s/project_path", BootstrapSettingsRootKey);
|
||||
if (settingsRegistry.Get(projectRoot.Native(), projectRootKey))
|
||||
const auto projectRootKey = SettingsRegistryInterface::FixedValueString::format("%s/project_path", BootstrapSettingsRootKey);
|
||||
|
||||
// Step 1 Run the scan upwards logic once to find the location of the project.json if it exist
|
||||
// Once this step is run the {InternalScanUpProjectRootKey} is set in the Settings Registry
|
||||
// to have this scan logic only run once for the supplied registry
|
||||
// SettingsRegistryInterface::GetType is used to check if a key is set
|
||||
if (settingsRegistry.GetType(InternalScanUpProjectRootKey) == SettingsRegistryInterface::Type::NoType)
|
||||
{
|
||||
return projectRoot;
|
||||
projectRoot = Internal::ScanUpRootLocator("project.json");
|
||||
// Set the {InternalScanUpProjectRootKey} to make sure this code path isn't called again for this settings registry
|
||||
settingsRegistry.Set(InternalScanUpProjectRootKey, projectRoot.Native());
|
||||
if (!projectRoot.empty())
|
||||
{
|
||||
settingsRegistry.Set(projectRootKey, projectRoot.c_str());
|
||||
// Inject the project root into the front of the command line settings
|
||||
Internal::InjectSettingToCommandLineFront(settingsRegistry, projectRootKey, projectRoot.Native());
|
||||
return projectRoot;
|
||||
}
|
||||
}
|
||||
|
||||
if (projectRoot = Internal::ScanUpRootLocator("project.json"); !projectRoot.empty())
|
||||
// Step 2 Check the project-path key
|
||||
// This is the project path root key, as in passed from command-line or .setreg files.
|
||||
if (settingsRegistry.Get(projectRoot.Native(), projectRootKey))
|
||||
{
|
||||
settingsRegistry.Set(projectRootKey, projectRoot.c_str());
|
||||
return projectRoot;
|
||||
}
|
||||
|
||||
@@ -475,53 +500,40 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
void MergeSettingsToRegistry_Bootstrap(SettingsRegistryInterface& registry)
|
||||
{
|
||||
ConfigParserSettings parserSettings;
|
||||
parserSettings.m_commentPrefixFunc = [](AZStd::string_view line) -> AZStd::string_view
|
||||
{
|
||||
constexpr AZStd::string_view commentPrefixes[]{ "--", ";","#" };
|
||||
for (AZStd::string_view commentPrefix : commentPrefixes)
|
||||
{
|
||||
if (size_t commentOffset = line.find(commentPrefix); commentOffset != AZStd::string_view::npos)
|
||||
{
|
||||
return line.substr(0, commentOffset);
|
||||
}
|
||||
}
|
||||
return line;
|
||||
};
|
||||
parserSettings.m_registryRootPointerPath = BootstrapSettingsRootKey;
|
||||
MergeSettingsToRegistry_ConfigFile(registry, "bootstrap.cfg", parserSettings);
|
||||
}
|
||||
|
||||
void MergeSettingsToRegistry_AddRuntimeFilePaths(SettingsRegistryInterface& registry)
|
||||
{
|
||||
using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString;
|
||||
// Binary folder
|
||||
AZ::IO::FixedMaxPath path = Internal::GetExecutableDirectory();
|
||||
AZ::IO::FixedMaxPath path = AZ::Utils::GetExecutableDirectory();
|
||||
registry.Set(FilePathKey_BinaryFolder, path.LexicallyNormal().Native());
|
||||
|
||||
// Engine root folder - corresponds to the @engroot@ and @devroot@ aliases
|
||||
AZ::IO::FixedMaxPath engineRoot = FindEngineRoot(registry);
|
||||
registry.Set(FilePathKey_EngineRootFolder, engineRoot.LexicallyNormal().Native());
|
||||
|
||||
constexpr size_t bufferSize = 64;
|
||||
auto buffer = AZStd::fixed_string<bufferSize>::format("%s/project_path", BootstrapSettingsRootKey);
|
||||
|
||||
AZ::SettingsRegistryInterface::FixedValueString projectPathKey(buffer);
|
||||
auto projectPathKey = FixedValueString::format("%s/project_path", BootstrapSettingsRootKey);
|
||||
SettingsRegistryInterface::FixedValueString projectPathValue;
|
||||
if (registry.Get(projectPathValue, projectPathKey))
|
||||
{
|
||||
// Cache folder
|
||||
// Get the name of the asset platform assigned by the bootstrap. First check for platform version such as "windows_assets"
|
||||
// and if that's missing just get "assets".
|
||||
constexpr char platformName[] = AZ_TRAIT_OS_PLATFORM_CODENAME_LOWER;
|
||||
|
||||
SettingsRegistryInterface::FixedValueString assetPlatform;
|
||||
buffer = AZStd::fixed_string<bufferSize>::format("%s/%s_assets", BootstrapSettingsRootKey, platformName);
|
||||
AZStd::string_view assetPlatformKey(buffer);
|
||||
if (!registry.Get(assetPlatform, assetPlatformKey))
|
||||
FixedValueString assetPlatform;
|
||||
if (auto assetPlatformKey = FixedValueString::format("%s/%s_assets", BootstrapSettingsRootKey, AZ_TRAIT_OS_PLATFORM_CODENAME_LOWER);
|
||||
!registry.Get(assetPlatform, assetPlatformKey))
|
||||
{
|
||||
buffer = AZStd::fixed_string<bufferSize>::format("%s/assets", BootstrapSettingsRootKey);
|
||||
assetPlatformKey = AZStd::string_view(buffer);
|
||||
assetPlatformKey = FixedValueString::format("%s/assets", BootstrapSettingsRootKey);
|
||||
registry.Get(assetPlatform, assetPlatformKey);
|
||||
}
|
||||
if (assetPlatform.empty())
|
||||
{
|
||||
// Use the platform codename to retrieve the default asset platform value
|
||||
assetPlatform = AZ::OSPlatformToDefaultAssetPlatform(AZ_TRAIT_OS_PLATFORM_CODENAME);
|
||||
}
|
||||
|
||||
// Project path - corresponds to the @devassets@ alias
|
||||
// NOTE: Here we append to engineRoot, but if projectPathValue is absolute then engineRoot is discarded.
|
||||
@@ -561,8 +573,7 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
{
|
||||
// Cache: project root - no corresponding fileIO alias, but this is where the asset database lives.
|
||||
// A registry override is accepted using the "project_cache_path" key.
|
||||
buffer = AZStd::fixed_string<bufferSize>::format("%s/project_cache_path", BootstrapSettingsRootKey);
|
||||
AZStd::string_view projectCacheRootOverrideKey(buffer);
|
||||
auto projectCacheRootOverrideKey = FixedValueString::format("%s/project_cache_path", BootstrapSettingsRootKey);
|
||||
// Clear path to make sure that the `project_cache_path` value isn't concatenated to the project path
|
||||
path.clear();
|
||||
if (registry.Get(path.Native(), projectCacheRootOverrideKey))
|
||||
@@ -588,20 +599,38 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
aznumeric_cast<int>(projectPathKey.size()), projectPathKey.data());
|
||||
}
|
||||
|
||||
#if !AZ_TRAIT_USE_ASSET_CACHE_FOLDER
|
||||
// Setup the cache and user paths for Platforms where the Asset Cache Folder isn't used
|
||||
#if !AZ_TRAIT_OS_IS_HOST_OS_PLATFORM
|
||||
// Setup the cache and user paths when to platform specific locations when running on non-host platforms
|
||||
path = engineRoot;
|
||||
registry.Set(FilePathKey_CacheProjectRootFolder, path.LexicallyNormal().Native());
|
||||
registry.Set(FilePathKey_CacheRootFolder, path.LexicallyNormal().Native());
|
||||
registry.Set(FilePathKey_DevWriteStorage, path.LexicallyNormal().Native());
|
||||
registry.Set(FilePathKey_ProjectUserPath, (path / "user").LexicallyNormal().Native());
|
||||
#endif // AZ_TRAIT_USE_ASSET_CACHE_FOLDER
|
||||
if (AZStd::optional<AZ::IO::FixedMaxPathString> nonHostCacheRoot = Utils::GetDefaultAppRootPath();
|
||||
nonHostCacheRoot)
|
||||
{
|
||||
registry.Set(FilePathKey_CacheProjectRootFolder, *nonHostCacheRoot);
|
||||
registry.Set(FilePathKey_CacheRootFolder, *nonHostCacheRoot);
|
||||
}
|
||||
else
|
||||
{
|
||||
registry.Set(FilePathKey_CacheProjectRootFolder, path.LexicallyNormal().Native());
|
||||
registry.Set(FilePathKey_CacheRootFolder, path.LexicallyNormal().Native());
|
||||
}
|
||||
if (AZStd::optional<AZ::IO::FixedMaxPathString> devWriteStorage = Utils::GetDevWriteStoragePath();
|
||||
devWriteStorage)
|
||||
{
|
||||
registry.Set(FilePathKey_DevWriteStorage, *devWriteStorage);
|
||||
registry.Set(FilePathKey_ProjectUserPath, *devWriteStorage);
|
||||
}
|
||||
else
|
||||
{
|
||||
registry.Set(FilePathKey_DevWriteStorage, path.LexicallyNormal().Native());
|
||||
registry.Set(FilePathKey_ProjectUserPath, (path / "user").LexicallyNormal().Native());
|
||||
}
|
||||
#endif // AZ_TRAIT_OS_IS_HOST_OS_PLATFORM
|
||||
}
|
||||
|
||||
void MergeSettingsToRegistry_TargetBuildDependencyRegistry(SettingsRegistryInterface& registry, const AZStd::string_view platform,
|
||||
const SettingsRegistryInterface::Specializations& specializations, AZStd::vector<char>* scratchBuffer)
|
||||
{
|
||||
AZ::IO::FixedMaxPath mergePath = Internal::GetExecutableDirectory();
|
||||
AZ::IO::FixedMaxPath mergePath = AZ::Utils::GetExecutableDirectory();
|
||||
if (!mergePath.empty())
|
||||
{
|
||||
registry.MergeSettingsFolder((mergePath / SettingsRegistryInterface::RegistryFolder).Native(),
|
||||
@@ -801,6 +830,11 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
++argumentIndex;
|
||||
commandLinePath.resize(commandLineRootSize);
|
||||
}
|
||||
|
||||
// This key is used allow Notification Handlers to know when the command line has been updated within the
|
||||
// registry. The value itself is meaningless. The JSON path of {CommandLineValueChangedKey}
|
||||
// being passed to the Notification Event Handler indicates that the command line has be updated
|
||||
registry.Set(CommandLineValueChangedKey, true);
|
||||
}
|
||||
|
||||
bool GetCommandLineFromRegistry(SettingsRegistryInterface& registry, AZ::CommandLine& commandLine)
|
||||
@@ -817,10 +851,16 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
}
|
||||
else if (valueName == "Value" && !value.empty())
|
||||
{
|
||||
m_arguments.push_back(value);
|
||||
// Make sure value types are in quotes in case they start with a command option prefix
|
||||
m_arguments.push_back(QuoteArgument(value));
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::string QuoteArgument(AZStd::string_view arg)
|
||||
{
|
||||
return !arg.empty() ? AZStd::string::format(R"("%.*s")", aznumeric_cast<int>(arg.size()), arg.data()) : AZStd::string{ arg };
|
||||
}
|
||||
|
||||
// The first parameter is skipped by the ComamndLine::Parse function so initialize
|
||||
// the container with one empty element
|
||||
AZ::CommandLine::ParamContainer m_arguments{ 1 };
|
||||
@@ -998,4 +1038,12 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
|
||||
return visitor.Finalize();
|
||||
}
|
||||
|
||||
bool IsPathAncestorDescendantOrEqual(AZStd::string_view candidatePath, AZStd::string_view inputPath)
|
||||
{
|
||||
AZ::IO::PathView candidateView{ candidatePath, AZ::IO::PosixPathSeparator };
|
||||
AZ::IO::PathView inputView{ inputPath, AZ::IO::PosixPathSeparator };
|
||||
return inputView.empty() || candidateView.IsRelativeTo(inputView) || inputView.IsRelativeTo(candidateView);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,6 +57,9 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
|
||||
//! Root key for where command line are stored at within the settings registry
|
||||
inline static constexpr char CommandLineRootKey[] = "/Amazon/AzCore/Runtime/CommandLine";
|
||||
//! Key set to trigger a notification that the CommandLine has been stored within the settings registry
|
||||
//! The value of the key has no meaning. Notification Handlers only need to check if the key was supplied
|
||||
inline static constexpr char CommandLineValueChangedKey[] = "/Amazon/AzCore/Runtime/CommandLineChanged";
|
||||
|
||||
//! Root key where raw project settings (project.json) file is merged to settings registry
|
||||
inline static constexpr char ProjectSettingsRootKey[] = "/Amazon/Project/Settings";
|
||||
@@ -74,6 +77,20 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
//! If it's still not found, attempt to find the project (by similar means) then reconcile the
|
||||
//! engine root by inspecting project.json and the engine manifest file.
|
||||
AZ::IO::FixedMaxPath FindEngineRoot(SettingsRegistryInterface& settingsRegistry);
|
||||
|
||||
//! The algorithm that is used to find the project root is as follows
|
||||
//! 1. The first time this function is it performs a upward scan for a project.json file from
|
||||
//! the executable directory and if found stores that path to an internal key.
|
||||
//! In the same step it injects the path into the front of list of command line parameters
|
||||
//! using the --regset="{BootstrapSettingsRootKey}/project_path=<path>" value
|
||||
//! 2. Next the "{BootstrapSettingsRootKey}/project_path" is checked to see if it has a project path set
|
||||
//!
|
||||
//! The order in which the project path settings are overridden proceeds in the following order
|
||||
//! 1. project_path set in the <engine-root>/bootstrap.cfg file
|
||||
//! 2. project_path set in a *.setreg/*.setregpatch file
|
||||
//! 3. project_path found by scanning upwards from the executable directory to the project.json path
|
||||
//! 4. project_path set on the Command line via either --regset="{BootstrapSettingsRootKey}/project_path=<path>"
|
||||
//! or --project_path=<path>
|
||||
AZ::IO::FixedMaxPath FindProjectRoot(SettingsRegistryInterface& settingsRegistry);
|
||||
|
||||
//! Query the specializations that will be used when loading the Settings Registry.
|
||||
@@ -256,4 +273,22 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
aznumeric_cast<int>(keyName.size()), keyName.data());
|
||||
return registry.Get(result, key);
|
||||
}
|
||||
|
||||
//! Check if the supplied input path is an ancestor, a descendant or exactly equal to the candidate path
|
||||
//! The can be used to check if a JSON pointer to a settings registry entry has potentially
|
||||
//! "modified" the object at candidate path or its children in notifications
|
||||
//! @param candidatePath Path which is being checked for the ancestor/descendant relationship
|
||||
//! @param inputPath Path which is checked to determine if it is an ancestor or descendant of the candidate path
|
||||
//! @return true if the input path is an ancestor, descendant or equal to the candidate path
|
||||
//! Example: input path is ancestor path of candidate path
|
||||
//! IsPathAncestorDescendantOrEqual("/Amazon/AzCore/Bootstrap", "/Amazon/AzCore") = true
|
||||
//! Example: input path is equal to candidate path
|
||||
//! IsPathAncestorDescendantOrEqual("/Amazon/AzCore/Bootstrap", "/Amazon/AzCore/Bootstrap") = true
|
||||
//! Example: input path is descendant of candidate path
|
||||
//! IsPathAncestorDescendantOrEqual("/Amazon/AzCore/Bootstrap", "/Amazon/AzCore/Bootstrap/project_path") = true
|
||||
//! //! Example: input path is unrelated to candidate path
|
||||
//! IsPathAncestorDescendantOrEqual("/Amazon/AzCore/Bootstrap", "/Amazon/Project/Settings/project_name") = false
|
||||
//! //! Example: The path "" is the root JSON pointer therefore that is the ancestor of all paths
|
||||
//! IsPathAncestorDescendantOrEqual("/Amazon/AzCore/Bootstrap", "") = true
|
||||
bool IsPathAncestorDescendantOrEqual(AZStd::string_view candidatePath, AZStd::string_view inputPath);
|
||||
}
|
||||
|
||||
@@ -2900,7 +2900,7 @@ namespace AZ
|
||||
{
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(referencedSliceAssetPath, &AZ::Data::AssetCatalogRequests::GetAssetPathById, slice.GetSliceAsset()->GetId());
|
||||
}
|
||||
AZ_Error("Slices", false, "Slice with asset ID %s and path %s has an invalid slice reference to slice with path %s. The Lumberyard editor may be unstable, it is recommended you re-launch the editor.",
|
||||
AZ_Error("Slices", false, "Slice with asset ID %s and path %s has an invalid slice reference to slice with path %s. The Open 3D Engine editor may be unstable, it is recommended you re-launch the editor.",
|
||||
!m_myAsset ? "invalid asset" : m_myAsset->GetId().ToString<AZStd::string>().c_str(),
|
||||
mySliceAssetPath.empty() ? "invalid path" : mySliceAssetPath.c_str(),
|
||||
referencedSliceAssetPath.empty() ? "invalid path" : referencedSliceAssetPath.c_str());
|
||||
|
||||
@@ -769,8 +769,8 @@ namespace AZ
|
||||
*! This has similar behavior to Python pathlib '/' operator and os.path.join
|
||||
*! Specifically, that it uses the last absolute path as the anchor for the resulting path
|
||||
*! https://docs.python.org/3/library/pathlib.html#pathlib.PurePath
|
||||
*! This means that joining StringFunc::Path::Join("C:\\lumberyard" "F:\\lumberyard") results in "F:\\lumberyard"
|
||||
*! not "C:\\lumberyard\\F:\\lumberyard"
|
||||
*! This means that joining StringFunc::Path::Join("C:\\O3DE" "F:\\O3DE") results in "F:\\O3DE"
|
||||
*! not "C:\\O3DE\\F:\\O3DE"
|
||||
*! EX: StringFunc::Path::Join("C:\\p4\\game","info\\some.file", a) == true; a== "C:\\p4\\game\\info\\some.file"
|
||||
*! EX: StringFunc::Path::Join("C:\\p4\\game\\info", "game\\info\\some.file", a) == true; a== "C:\\p4\\game\\info\\game\\info\\some.file"
|
||||
*! EX: StringFunc::Path::Join("C:\\p4\\game\\info", "\\game\\info\\some.file", a) == true; a== "C:\\game\\info\\some.file"
|
||||
|
||||
@@ -17,10 +17,12 @@ namespace UnitTest
|
||||
MockComponentApplication::MockComponentApplication()
|
||||
{
|
||||
AZ::ComponentApplicationBus::Handler::BusConnect();
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Register(this);
|
||||
}
|
||||
|
||||
MockComponentApplication::~MockComponentApplication()
|
||||
{
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Unregister(this);
|
||||
AZ::ComponentApplicationBus::Handler::BusDisconnect();
|
||||
}
|
||||
} // namespace UnitTest
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
namespace UnitTest
|
||||
@@ -30,6 +31,8 @@ namespace UnitTest
|
||||
MOCK_METHOD0(Destroy, void ());
|
||||
MOCK_METHOD1(RegisterComponentDescriptor, void (const AZ::ComponentDescriptor*));
|
||||
MOCK_METHOD1(UnregisterComponentDescriptor, void (const AZ::ComponentDescriptor*));
|
||||
MOCK_METHOD1(RegisterEntityAddedEventHandler, void(AZ::EntityAddedEvent::Handler&));
|
||||
MOCK_METHOD1(RegisterEntityRemovedEventHandler, void(AZ::EntityRemovedEvent::Handler&));
|
||||
MOCK_METHOD1(RemoveEntity, bool (AZ::Entity*));
|
||||
MOCK_METHOD1(DeleteEntity, bool (const AZ::EntityId&));
|
||||
MOCK_METHOD1(GetEntityName, AZStd::string (const AZ::EntityId&));
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/UnitTest/UnitTest.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class MockSettingsRegistry;
|
||||
using NiceSettingsRegistrySimpleMock = ::testing::NiceMock<MockSettingsRegistry>;
|
||||
|
||||
class MockSettingsRegistry
|
||||
: public AZ::SettingsRegistryInterface
|
||||
{
|
||||
public:
|
||||
MOCK_CONST_METHOD1(GetType, Type(AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Visit, bool(Visitor&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Visit, bool(const VisitorCallback&, AZStd::string_view));
|
||||
MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(const NotifyCallback&));
|
||||
MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(NotifyCallback&&));
|
||||
|
||||
MOCK_CONST_METHOD2(Get, bool(bool&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(s64&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(u64&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(double&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(AZStd::string&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD2(Get, bool(FixedValueString&, AZStd::string_view));
|
||||
MOCK_CONST_METHOD3(GetObject, bool(void*, Uuid, AZStd::string_view));
|
||||
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, bool));
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, s64));
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, u64));
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, double));
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, AZStd::string_view));
|
||||
MOCK_METHOD2(Set, bool(AZStd::string_view, const char*));
|
||||
MOCK_METHOD3(SetObject, bool(AZStd::string_view, const void*, Uuid));
|
||||
|
||||
MOCK_METHOD1(Remove, bool(AZStd::string_view));
|
||||
|
||||
MOCK_METHOD3(MergeCommandLineArgument, bool(AZStd::string_view, AZStd::string_view, const CommandLineArgumentSettings&));
|
||||
MOCK_METHOD2(MergeSettings, bool(AZStd::string_view, Format));
|
||||
MOCK_METHOD4(MergeSettingsFile, bool(AZStd::string_view, Format, AZStd::string_view, AZStd::vector<char>*));
|
||||
MOCK_METHOD5(
|
||||
MergeSettingsFolder,
|
||||
bool(AZStd::string_view, const Specializations&, AZStd::string_view, AZStd::string_view, AZStd::vector<char>*));
|
||||
};
|
||||
} // namespace AZ
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace UnitTest
|
||||
#define AZ_TEST_STATIC_ASSERT(_Exp) static_assert(_Exp, "Test Static Assert")
|
||||
#ifdef AZ_ENABLE_TRACING
|
||||
/*
|
||||
* The AZ_TEST_START_ASSERTTEST and AZ_TEST_STOP_ASSERTTEST macros have been deprecated and will be removed in a future Lumberyard release.
|
||||
* The AZ_TEST_START_ASSERTTEST and AZ_TEST_STOP_ASSERTTEST macros have been deprecated and will be removed in a future Open 3D Engine release.
|
||||
* The AZ_TEST_START_TRACE_SUPPRESSION and AZ_TEST_STOP_TRACE_SUPPRESSION is the recommend macros
|
||||
* The reason for the deprecation is that the AZ_TEST_(START|STOP)_ASSERTTEST implies that they should be used to for writing assert unit test
|
||||
* where the asserts themselves are expected to cause the test process to terminate.
|
||||
|
||||
@@ -505,6 +505,8 @@ set(FILES
|
||||
Serialization/Json/BasicContainerSerializer.cpp
|
||||
Serialization/Json/BoolSerializer.h
|
||||
Serialization/Json/BoolSerializer.cpp
|
||||
Serialization/Json/ByteStreamSerializer.h
|
||||
Serialization/Json/ByteStreamSerializer.cpp
|
||||
Serialization/Json/CastingHelpers.h
|
||||
Serialization/Json/DoubleSerializer.h
|
||||
Serialization/Json/DoubleSerializer.cpp
|
||||
@@ -605,6 +607,8 @@ set(FILES
|
||||
Utils/Utils.h
|
||||
Script/lua/lua.h
|
||||
Memory/HeapSchema.cpp
|
||||
PlatformId/PlatformDefaults.h
|
||||
PlatformId/PlatformDefaults.cpp
|
||||
PlatformId/PlatformId.h
|
||||
PlatformId/PlatformId.cpp
|
||||
Socket/AzSocket_fwd.h
|
||||
|
||||
@@ -15,4 +15,5 @@ set(FILES
|
||||
UnitTest/UnitTest.h
|
||||
UnitTest/TestTypes.h
|
||||
UnitTest/Mocks/MockFileIOBase.h
|
||||
UnitTest/Mocks/MockSettingsRegistry.h
|
||||
)
|
||||
|
||||
@@ -636,7 +636,6 @@ namespace AZStd
|
||||
{
|
||||
AZSTD_CONTAINER_ASSERT(!full(), "Cannot emplace on a full fixed_vector");
|
||||
AZSTD_CONTAINER_ASSERT(insertPos >= cbegin() && insertPos <= cend(), "insert position must be in range of container");
|
||||
pointer dataStart = data();
|
||||
pointer dataEnd = data() + size();
|
||||
pointer insertPosPtr = data() + AZStd::distance(cbegin(), insertPos);
|
||||
|
||||
@@ -896,7 +895,7 @@ namespace AZStd
|
||||
if (numInitializedToFill < numElements)
|
||||
{
|
||||
// Copy the elements after insert position.
|
||||
iterator newLast = AZStd::uninitialized_move(insertPosPtr, dataEnd, insertPosPtr + numElements);
|
||||
AZStd::uninitialized_move(insertPosPtr, dataEnd, insertPosPtr + numElements);
|
||||
// get last iterator to use move assignment operator
|
||||
Iterator lastToAssign = AZStd::next(first, numInitializedToFill);
|
||||
|
||||
|
||||
@@ -40,14 +40,13 @@ ly_add_target(
|
||||
${common_dir}
|
||||
${AZ_CORE_RADTELEMETRY_INCLUDE_DIRECTORIES}
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
3rdParty::zlib
|
||||
3rdParty::zstd
|
||||
3rdParty::cityhash
|
||||
PUBLIC
|
||||
3rdParty::Lua
|
||||
3rdParty::RapidJSON
|
||||
3rdParty::RapidXML
|
||||
3rdParty::zlib
|
||||
3rdParty::zstd
|
||||
3rdParty::cityhash
|
||||
${AZ_CORE_RADTELEMETRY_BUILD_DEPENDENCIES}
|
||||
)
|
||||
ly_add_source_properties(
|
||||
|
||||
@@ -105,7 +105,6 @@
|
||||
#define AZ_TRAIT_THREAD_HARDWARE_CONCURRENCY_RETURN_VALUE static_cast<unsigned int>(sysconf(_SC_NPROCESSORS_ONLN));
|
||||
#define AZ_TRAIT_UNITTEST_NON_PREALLOCATED_HPHA_TEST 0
|
||||
#define AZ_TRAIT_UNITTEST_USE_TEST_RUNNER_ENVIRONMENT 1
|
||||
#define AZ_TRAIT_USE_ASSET_CACHE_FOLDER 0
|
||||
#define AZ_TRAIT_USE_CRY_SIGNAL_HANDLER 0
|
||||
#define AZ_TRAIT_USE_POSIX_STRERROR_R 1
|
||||
#define AZ_TRAIT_USE_SECURE_CRT_FUNCTIONS 0
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Platform::Internal
|
||||
void FindFilesInApk(const char* filter, const SystemFile::FindFileCB& cb)
|
||||
{
|
||||
// Separate the directory from the filename portion of the filter
|
||||
AZ::IO::PathView filterPath(AZ::Android::Utils::StripApkPrefix(filter));
|
||||
AZ::IO::FixedMaxPath filterPath(AZ::Android::Utils::StripApkPrefix(filter));
|
||||
AZ::IO::FixedMaxPathString filterDir{ filterPath.ParentPath().Native() };
|
||||
AZStd::string_view fileFilter{ filterPath.Filename().Native() };
|
||||
|
||||
|
||||
+2
-4
@@ -28,8 +28,7 @@ namespace AZ::Platform
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD error = ::GetLastError();
|
||||
AZ_Assert(event, "Failed to create a required event for IO Scheduler (Error: %u).", error);
|
||||
AZ_Assert(event, "Failed to create a required event for IO Scheduler (Error: %u).", ::GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,8 +42,7 @@ namespace AZ::Platform
|
||||
{
|
||||
if (!::CloseHandle(event))
|
||||
{
|
||||
DWORD error = ::GetLastError();
|
||||
AZ_Assert(false, "Failed to close an event handle for IO Scheduler (Error: %u)", error);
|
||||
AZ_Assert(false, "Failed to close an event handle for IO Scheduler (Error: %u)", ::GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ namespace AZStd
|
||||
// detect a sitaution where the mutex or the cond var are invalid, or the duration
|
||||
AZ_Assert(lastError == AZ_ERROR_TIMEOUT, "Error from SleepConditionVariableCS: 0x%08x\n", lastError);
|
||||
// asserts are continuable so we still check.
|
||||
if (GetLastError() == AZ_ERROR_TIMEOUT)
|
||||
if (lastError == AZ_ERROR_TIMEOUT)
|
||||
{
|
||||
return cv_status::timeout;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,6 @@
|
||||
#define AZ_TRAIT_THREAD_HARDWARE_CONCURRENCY_RETURN_VALUE static_cast<unsigned int>(sysconf(_SC_NPROCESSORS_ONLN));
|
||||
#define AZ_TRAIT_UNITTEST_NON_PREALLOCATED_HPHA_TEST 0
|
||||
#define AZ_TRAIT_UNITTEST_USE_TEST_RUNNER_ENVIRONMENT 0
|
||||
#define AZ_TRAIT_USE_ASSET_CACHE_FOLDER 1
|
||||
#define AZ_TRAIT_USE_CRY_SIGNAL_HANDLER 1
|
||||
#define AZ_TRAIT_USE_POSIX_STRERROR_R 1
|
||||
#define AZ_TRAIT_USE_SECURE_CRT_FUNCTIONS 0
|
||||
|
||||
@@ -105,7 +105,6 @@
|
||||
#define AZ_TRAIT_THREAD_HARDWARE_CONCURRENCY_RETURN_VALUE static_cast<unsigned int>(sysconf(_SC_NPROCESSORS_ONLN));
|
||||
#define AZ_TRAIT_UNITTEST_NON_PREALLOCATED_HPHA_TEST 0
|
||||
#define AZ_TRAIT_UNITTEST_USE_TEST_RUNNER_ENVIRONMENT 0
|
||||
#define AZ_TRAIT_USE_ASSET_CACHE_FOLDER 1
|
||||
#define AZ_TRAIT_USE_CRY_SIGNAL_HANDLER 1
|
||||
#define AZ_TRAIT_USE_POSIX_STRERROR_R 1
|
||||
#define AZ_TRAIT_USE_SECURE_CRT_FUNCTIONS 0
|
||||
|
||||
@@ -105,7 +105,6 @@
|
||||
#define AZ_TRAIT_THREAD_HARDWARE_CONCURRENCY_RETURN_VALUE INVALID_RETURN_VALUE
|
||||
#define AZ_TRAIT_UNITTEST_NON_PREALLOCATED_HPHA_TEST 1
|
||||
#define AZ_TRAIT_UNITTEST_USE_TEST_RUNNER_ENVIRONMENT 0
|
||||
#define AZ_TRAIT_USE_ASSET_CACHE_FOLDER 1
|
||||
#define AZ_TRAIT_USE_CRY_SIGNAL_HANDLER 0
|
||||
#define AZ_TRAIT_USE_POSIX_STRERROR_R 0
|
||||
#define AZ_TRAIT_USE_SECURE_CRT_FUNCTIONS 1
|
||||
|
||||
@@ -106,7 +106,6 @@
|
||||
#define AZ_TRAIT_THREAD_HARDWARE_CONCURRENCY_RETURN_VALUE static_cast<unsigned int>(sysconf(_SC_NPROCESSORS_ONLN));
|
||||
#define AZ_TRAIT_UNITTEST_NON_PREALLOCATED_HPHA_TEST 0
|
||||
#define AZ_TRAIT_UNITTEST_USE_TEST_RUNNER_ENVIRONMENT 0
|
||||
#define AZ_TRAIT_USE_ASSET_CACHE_FOLDER 0
|
||||
#define AZ_TRAIT_USE_CRY_SIGNAL_HANDLER 1
|
||||
#define AZ_TRAIT_USE_POSIX_STRERROR_R 1
|
||||
#define AZ_TRAIT_USE_SECURE_CRT_FUNCTIONS 0
|
||||
|
||||
@@ -70,5 +70,4 @@ set(FILES
|
||||
AzCore/Utils/Utils_iOS.mm
|
||||
../Common/Apple/AzCore/Utils/Utils_Apple.cpp
|
||||
../Common/UnixLike/AzCore/Utils/Utils_UnixLike.cpp
|
||||
../Common/Unimplemented/AzCore/Utils/Utils_Unimplemented.cpp
|
||||
)
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace UnitTest
|
||||
|
||||
TEST_F(OptionalFixture, ConstructorInPlaceWithInitializerList)
|
||||
{
|
||||
const optional<ConstructibleWithInitializerListClass> opt(in_place, {"Lumberyard"}, 4);
|
||||
const optional<ConstructibleWithInitializerListClass> opt(in_place, {"O3DE"}, 4);
|
||||
EXPECT_TRUE(bool(opt)) << "optional constructed with args should be true";
|
||||
}
|
||||
|
||||
|
||||
@@ -1769,7 +1769,6 @@ namespace UnitTest
|
||||
{
|
||||
return "HelloWorld";
|
||||
};
|
||||
constexpr const TypeParam* compileTimeString1 = MakeCompileTimeString1();
|
||||
constexpr basic_string_view<TypeParam> modifierView("HelloWorld");
|
||||
// A constexpr lambda is used to evaluate non constexpr string_view instances' member functions which
|
||||
// have been marked as constexpr at compile time
|
||||
@@ -2334,7 +2333,6 @@ namespace UnitTest
|
||||
const char* filter1{ "*" };
|
||||
const char* filter2{ "*?" };
|
||||
const char* filter3{ "?*" };
|
||||
const char* testValue{ "" };
|
||||
EXPECT_TRUE(wildcard_match(filter1, "Hello"));
|
||||
EXPECT_TRUE(wildcard_match(filter1, "?"));
|
||||
EXPECT_TRUE(wildcard_match(filter1, "*"));
|
||||
|
||||
@@ -53,35 +53,27 @@ namespace UnitTest
|
||||
{
|
||||
// Trvially validate that we can create and destroy an asset manager instance, and that it's only ready while it's created.
|
||||
|
||||
// Before creation, IsReady() should be false and trying to get an Instance() should cause an assert.
|
||||
// Before creation, IsReady() should be false.
|
||||
EXPECT_FALSE(AssetManager::IsReady());
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto& badInstance = AssetManager::Instance();
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
|
||||
|
||||
AssetManager::Descriptor desc;
|
||||
AssetManager::Create(desc);
|
||||
|
||||
// After creation, the system should be ready and queryable via Instance().
|
||||
EXPECT_TRUE(AssetManager::IsReady());
|
||||
auto& goodInstance = AssetManager::Instance();
|
||||
AssetManager::Instance();
|
||||
|
||||
AssetManager::Destroy();
|
||||
|
||||
// After destruction, these should fail again
|
||||
EXPECT_FALSE(AssetManager::IsReady());
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto& badInstance2 = AssetManager::Instance();
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
|
||||
}
|
||||
#endif // !AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_CREATE_DESTROY_TEST
|
||||
|
||||
TEST_F(AssetManagerSystemTest, AssetManager_SetInstance_TriviallyWorks)
|
||||
{
|
||||
// There shouldn't be an instance yet.
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto& badInstance = AssetManager::Instance();
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
|
||||
EXPECT_FALSE(AssetManager::IsReady());
|
||||
|
||||
// Create an instance and set it.
|
||||
AssetManager::Descriptor desc;
|
||||
@@ -669,7 +661,6 @@ namespace UnitTest
|
||||
EmptyAssetWithInstanceCount* origData = assetWithData.Get();
|
||||
AssetId origId = assetWithData.GetId();
|
||||
AssetType origType = assetWithData.GetType();
|
||||
AssetLoadBehavior origBehavior = assetWithData.GetAutoLoadBehavior();
|
||||
|
||||
Asset<EmptyAssetWithInstanceCount> assetWithData2(AZStd::move(assetWithData));
|
||||
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
@@ -29,10 +31,12 @@ namespace UnitTest
|
||||
m_behaviorContext = aznew AZ::BehaviorContext();
|
||||
|
||||
AZ::ComponentApplicationBus::Handler::BusConnect();
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Register(this);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Unregister(this);
|
||||
AZ::ComponentApplicationBus::Handler::BusDisconnect();
|
||||
|
||||
// Just destroy everything before we complete the tear down.
|
||||
@@ -45,7 +49,8 @@ namespace UnitTest
|
||||
// ComponentApplicationBus
|
||||
AZ::ComponentApplication* GetApplication() override { return nullptr; }
|
||||
void RegisterComponentDescriptor(const AZ::ComponentDescriptor*) override {}
|
||||
|
||||
void RegisterEntityAddedEventHandler(AZ::EntityAddedEvent::Handler&) override {}
|
||||
void RegisterEntityRemovedEventHandler(AZ::EntityRemovedEvent::Handler&) override {}
|
||||
void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override {}
|
||||
bool AddEntity(AZ::Entity*) override { return true; }
|
||||
bool RemoveEntity(AZ::Entity*) override { return true; }
|
||||
|
||||
@@ -1081,13 +1081,11 @@ namespace UnitTest
|
||||
AZStd::string filePath;
|
||||
if (providerId == UserSettings::CT_GLOBAL)
|
||||
{
|
||||
filePath.append(static_cast<AZStd::string_view>(m_exeDirectory));
|
||||
filePath.append("GlobalUserSettings.xml");
|
||||
filePath = (m_exeDirectory / "GlobalUserSettings.xml").String();
|
||||
}
|
||||
else if (providerId == UserSettings::CT_LOCAL)
|
||||
{
|
||||
filePath.append(static_cast<AZStd::string_view>(m_exeDirectory));
|
||||
filePath.append("LocalUserSettings.xml");
|
||||
filePath = (m_exeDirectory / "LocalUserSettings.xml").String();
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace AZ::Debug
|
||||
|
||||
realLogger.Start(logFilePath.c_str());
|
||||
|
||||
LargeBlock& block = logger->RecordEventBegin<LargeBlock>(largeBlockId);
|
||||
logger->RecordEventBegin<LargeBlock>(largeBlockId);
|
||||
logger->RecordEventEnd();
|
||||
|
||||
logger->RecordStringEvent(MessageId, message);
|
||||
|
||||
@@ -97,8 +97,6 @@ namespace UnitTest
|
||||
SAFE_EXPECT_EQ(AZ::ClampedIntegralLimits<ValueType, ClampType>::Max(), (std::numeric_limits<ValueType>::max)());
|
||||
|
||||
// Expect the natural numerical limits of ValueType to be equal to the natural numerical limits of ClampType
|
||||
ValueType vMin = AZ::ClampedIntegralLimits<ValueType, ClampType>::Min();
|
||||
ClampType cMin = std::numeric_limits<ClampType>::lowest();
|
||||
SAFE_EXPECT_EQ(AZ::ClampedIntegralLimits<ValueType, ClampType>::Min(), std::numeric_limits<ClampType>::lowest());
|
||||
SAFE_EXPECT_EQ(AZ::ClampedIntegralLimits<ValueType, ClampType>::Max(), (std::numeric_limits<ClampType>::max)());
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user