diff --git a/Code/Framework/AzCore/AzCore/Asset/AssetSerializer.h b/Code/Framework/AzCore/AzCore/Asset/AssetSerializer.h index f2ac6ea459..a9e7f5f02a 100644 --- a/Code/Framework/AzCore/AzCore/Asset/AssetSerializer.h +++ b/Code/Framework/AzCore/AzCore/Asset/AssetSerializer.h @@ -10,6 +10,7 @@ #include #include +#include namespace AZ { struct Uuid; diff --git a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl index 690bbb0b04..bba79e36f7 100644 --- a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl +++ b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl @@ -7,18 +7,17 @@ */ #pragma once -#include #include #include #include -#include -#include -#include -#include -#include +#include #include #include -#include + +#ifndef AZ_USE_CUSTOM_SCRIPT_BIND +struct lua_State; +struct lua_Debug; +#endif // AZ_USE_CUSTOM_SCRIPT_BIND // forward declare specialized types namespace AZStd @@ -59,6 +58,26 @@ namespace AZ class BehaviorContext; class ScriptDataContext; + namespace OnDemandLuaFunctions + { + inline void AnyToLua(lua_State* lua, BehaviorValueParameter& param); + } + namespace ScriptCanvasOnDemandReflection + { + template + struct OnDemandPrettyName; + template + struct OnDemandToolTip; + template + struct OnDemandCategoryName; + } + namespace CommonOnDemandReflections + { + void ReflectCommonString(ReflectContext* context); + void ReflectCommonStringView(ReflectContext* context); + void ReflectStdAny(ReflectContext* context); + void ReflectVoidOutcome(ReflectContext* context); + } /// OnDemand reflection for AZStd::basic_string template struct OnDemandReflection< AZStd::basic_string > @@ -66,108 +85,16 @@ namespace AZ using ContainerType = AZStd::basic_string; using SizeType = typename ContainerType::size_type; using ValueType = typename ContainerType::value_type; - + static void Reflect(ReflectContext* context) { - if (BehaviorContext* behaviorContext = azrtti_cast(context)) + constexpr bool is_string = AZStd::is_same_v && AZStd::is_same_v> + && AZStd::is_same_v; + if constexpr(is_string) { - behaviorContext->Class() - ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) - ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) - ->template Constructor() - ->Attribute(AZ::Script::Attributes::ConstructorOverride, &OnDemandLuaFunctions::ConstructBasicString) - ->Attribute(AZ::Script::Attributes::ReaderWriterOverride, ScriptContext::CustomReaderWriter(&OnDemandLuaFunctions::StringTypeToLua, &OnDemandLuaFunctions::StringTypeFromLua)) - ->template WrappingMember(&ContainerType::c_str) - ->Method("c_str", &ContainerType::c_str) - ->Method("Length", [](ContainerType* thisPtr) { return aznumeric_cast(thisPtr->length()); }) - ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Length) - ->Method("Equal", [](const ContainerType& lhs, const ContainerType& rhs) - { - return lhs == rhs; - }) - ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Equal) - ->Method("Find", [](ContainerType* thisPtr, const ContainerType& stringToFind, const int& startPos) - { - return aznumeric_cast(thisPtr->find(stringToFind, startPos)); - }) - ->Method("Substring", [](ContainerType* thisPtr, const int& pos, const int& len) - { - return thisPtr->substr(pos, len); - }) - ->Method("Replace", [](ContainerType* thisPtr, const ContainerType& stringToReplace, const ContainerType& replacementString) - { - SizeType startPos = 0; - while ((startPos = thisPtr->find(stringToReplace, startPos)) != ContainerType::npos && !stringToReplace.empty()) - { - thisPtr->replace(startPos, stringToReplace.length(), replacementString); - startPos += replacementString.length(); - } - - return *thisPtr; - }) - ->Method("ReplaceByIndex", [](ContainerType* thisPtr, const int& beginIndex, const int& endIndex, const ContainerType& replacementString) - { - thisPtr->replace(beginIndex, endIndex - beginIndex + 1, replacementString); - return *thisPtr; - }) - ->Method("Add", [](ContainerType* thisPtr, const ContainerType& addend) - { - return *thisPtr + addend; - }) - ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Concat) - ->Method("TrimLeft", [](ContainerType* thisPtr) - { - auto wsfront = AZStd::find_if_not(thisPtr->begin(), thisPtr->end(), [](char c) {return AZStd::is_space(c);}); - thisPtr->erase(thisPtr->begin(), wsfront); - return *thisPtr; - }) - ->Method("TrimRight", [](ContainerType* thisPtr) - { - auto wsend = AZStd::find_if_not(thisPtr->rbegin(), thisPtr->rend(), [](char c) {return AZStd::is_space(c);}); - thisPtr->erase(wsend.base(), thisPtr->end()); - return *thisPtr; - }) - ->Method("ToLower", [](ContainerType* thisPtr) - { - ContainerType toLowerString; - for (auto itr = thisPtr->begin(); itr < thisPtr->end(); itr++) - { - toLowerString.push_back(static_cast(tolower(*itr))); - } - return toLowerString; - }) - ->Method("ToUpper", [](ContainerType* thisPtr) - { - ContainerType toUpperString; - for (auto itr = thisPtr->begin(); itr < thisPtr->end(); itr++) - { - toUpperString.push_back(static_cast(toupper(*itr))); - } - return toUpperString; - }) - ->Method("Join", [](AZStd::vector* stringsToJoinPtr, const ContainerType& joinStr) - { - ContainerType joinString; - for (auto& stringToJoin : *stringsToJoinPtr) - { - joinString.append(stringToJoin).append(joinStr); - } - //Cut off the last join str - if (!stringsToJoinPtr->empty()) - { - joinString = joinString.substr(0, joinString.length() - joinStr.length()); - } - return joinString; - }) - - ->Method("Split", [](ContainerType* thisPtr, const ContainerType& splitter) - { - AZStd::vector splitStringList; - AZStd::tokenize(*thisPtr, splitter, splitStringList); - return splitStringList; - }) - ; + CommonOnDemandReflections::ReflectCommonString(context); } + static_assert (is_string, "Unspecialized basic_string<> template reflection requested."); } }; @@ -181,44 +108,9 @@ namespace AZ static void Reflect(ReflectContext* context) { - if (BehaviorContext* behaviorContext = azrtti_cast(context)) - { - behaviorContext->Class() - ->Attribute(AZ::Script::Attributes::Category, "Core") - ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) - ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) - ->template Constructor() - ->Attribute(AZ::Script::Attributes::ConstructorOverride, &OnDemandLuaFunctions::ConstructStringView) - ->Attribute(AZ::Script::Attributes::ReaderWriterOverride, ScriptContext::CustomReaderWriter(&OnDemandLuaFunctions::StringTypeToLua, &OnDemandLuaFunctions::StringTypeFromLua)) - ->Method("ToString", [](const ContainerType& stringView) { return static_cast(stringView).c_str(); }, { { { "Reference", "String view object being converted to string" } } }) - ->Attribute(AZ::Script::Attributes::ToolTip, "Converts string_view to string") - ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::ToString) - ->template WrappingMember(&ContainerType::data) - ->Method("data", &ContainerType::data) - ->Attribute(AZ::Script::Attributes::ToolTip, "Returns reference to raw string data") - ->Method("length", [](ContainerType* thisPtr) { return aznumeric_cast(thisPtr->length()); }, { { { "This", "Reference to the object the method is being performed on" } } }) - ->Attribute(AZ::Script::Attributes::ToolTip, "Returns length of string view") - ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Length) - ->Method("size", [](ContainerType* thisPtr) { return aznumeric_cast(thisPtr->size()); }, { { { "This", "Reference to the object the method is being performed on" }} }) - ->Attribute(AZ::Script::Attributes::ToolTip, "Returns length of string view") - ->Method("find", [](ContainerType* thisPtr, ContainerType stringToFind, int startPos) - { - return aznumeric_cast(thisPtr->find(stringToFind, startPos)); - }, { { { "This", "Reference to the object the method is being performed on" }, { "View", "View to search " }, { "Position", "Index in view to start search" }} }) - ->Attribute(AZ::Script::Attributes::ToolTip, "Searches for supplied string within this string") - ->Method("substr", [](ContainerType* thisPtr, int pos, int len) - { - return thisPtr->substr(pos, len); - }, { {{"This", "Reference to the object the method is being performed on"}, {"Position", "Index in view that indicates the beginning of the sub string"}, {"Count", "Length of characters that sub string view occupies" }} }) - ->Attribute(AZ::Script::Attributes::ToolTip, "Creates a sub view of this string view. The string data is not actually modified") - ->Method("remove_prefix", [](ContainerType* thisPtr, int n) {thisPtr->remove_prefix(n); }, - { { { "This", "Reference to the object the method is being performed on" }, { "Count", "Number of characters to remove from start of view" }} }) - ->Attribute(AZ::Script::Attributes::ToolTip, "Moves the supplied number of characters from the beginning of this sub view") - ->Method("remove_suffix", [](ContainerType* thisPtr, int n) {thisPtr->remove_suffix(n); }, - { { { "This", "Reference to the object the method is being performed on" } ,{ "Count", "Number of characters to remove from end of view" }} }) - ->Attribute(AZ::Script::Attributes::ToolTip, "Moves the supplied number of characters from the end of this sub view") - ; - } + constexpr bool is_common = AZStd::is_same_v && AZStd::is_same_v>; + static_assert (is_common, "Unspecialized basic_string_view<> template reflection requested."); + CommonOnDemandReflections::ReflectCommonStringView(context); } }; @@ -228,7 +120,7 @@ namespace AZ { using ContainerType = AZStd::intrusive_ptr; - // TODO: Count reflection types for a proper un-reflect + // TODO: Count reflection types for a proper un-reflect static void CustomConstructor(ContainerType* thisPtr, ScriptDataContext& dc) { @@ -276,7 +168,7 @@ namespace AZ { using ContainerType = AZStd::shared_ptr; - // TODO: Count reflection types for a proper un-reflect + // TODO: Count reflection types for a proper un-reflect static void CustomConstructor(ContainerType* thisPtr, ScriptDataContext& dc) { @@ -435,7 +327,7 @@ namespace AZ thisPtr[uindex] = value; } - + static bool EraseCheck_VM(ContainerType& thisPtr, AZ::u64 index) { if (index < thisPtr.size()) @@ -448,7 +340,7 @@ namespace AZ return false; } } - + static ContainerType& ErasePost_VM(ContainerType& thisPtr, AZ::u64 /*index*/) { return thisPtr; @@ -604,7 +496,7 @@ namespace AZ return AZ::Failure(AZStd::string::format("Index out of bounds: %zu (size: %zu)", index, thisContainer.size())); } } - + static AZ::Outcome Replace(ContainerType& thisContainer, size_t index, T& value) { if (index >= 0 && index < thisContainer.size()) @@ -634,7 +526,7 @@ namespace AZ ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Length) ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Attribute(AZ::Script::Attributes::Deprecated, true) - + ->Method(k_accessElementName, &At, {{ {}, { "Index", "The index to read from", nullptr, BehaviorParameter::Traits::TR_INDEX }}}) ->Method(k_sizeName, [](ContainerType*) { return aznumeric_cast(N); }) ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Length) @@ -743,27 +635,8 @@ namespace AZ template<> // in case someone has an issue with bool struct OnDemandReflection> { - using OutcomeType = AZ::Outcome; - - static void Reflect(ReflectContext* context) - { - if (BehaviorContext* behaviorContext = azrtti_cast(context)) - { - // note we can reflect iterator types and support iterators, as of know we want to keep it simple - behaviorContext->Class() - ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) - ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) - ->Attribute(AZ::ScriptCanvasAttributes::AllowInternalCreation, true) - ->Attribute(AZ::ScriptCanvasAttributes::PrettyName, &ScriptCanvasOnDemandReflection::OnDemandPrettyName::Get) - ->Attribute(AZ::Script::Attributes::ToolTip, &ScriptCanvasOnDemandReflection::OnDemandToolTip::Get) - ->Attribute(AZ::Script::Attributes::Category, &ScriptCanvasOnDemandReflection::OnDemandCategoryName::Get) - ->Attribute(AZ::ScriptCanvasAttributes::AllowInternalCreation, AttributeIsValid::IfPresent) - ->Attribute(AZ::ScriptCanvasAttributes::VariableCreationForbidden, AttributeIsValid::IfPresent) - ->Method("Failure", []() -> OutcomeType { return AZ::Failure(); }) - ->Method("Success", []() -> OutcomeType { return AZ::Success(); }) - ->Method("IsSuccess", &OutcomeType::IsSuccess) - ; - } + static void Reflect(ReflectContext* context) { + CommonOnDemandReflections::ReflectVoidOutcome(context); } }; @@ -1179,16 +1052,8 @@ namespace AZ template <> struct OnDemandReflection { - static void Reflect(ReflectContext* context) - { - if (BehaviorContext* behaviorContext = azrtti_cast(context)) - { - behaviorContext->Class() - ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) - ->Attribute(Script::Attributes::Ignore, true) // Don't reflect any type to script (there should never be an any instance in script) - ->Attribute(Script::Attributes::ReaderWriterOverride, ScriptContext::CustomReaderWriter(&AZ::OnDemandLuaFunctions::AnyToLua, &OnDemandLuaFunctions::AnyFromLua)) - ; - } + static void Reflect(ReflectContext* context) { + CommonOnDemandReflections::ReflectStdAny(context); } }; diff --git a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflectionSpecializations.cpp b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflectionSpecializations.cpp new file mode 100644 index 0000000000..c42e32cd42 --- /dev/null +++ b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflectionSpecializations.cpp @@ -0,0 +1,208 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +namespace AZ::CommonOnDemandReflections +{ + void ReflectCommonString(ReflectContext* context) + { + using ContainerType = AZStd::string; + using SizeType = typename ContainerType::size_type; + using ValueType = typename ContainerType::value_type; + if (BehaviorContext* behaviorContext = azrtti_cast(context)) + { + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) + ->template Constructor() + ->Attribute(AZ::Script::Attributes::ConstructorOverride, &OnDemandLuaFunctions::ConstructBasicString) + ->Attribute(AZ::Script::Attributes::ReaderWriterOverride, ScriptContext::CustomReaderWriter(&OnDemandLuaFunctions::StringTypeToLua, &OnDemandLuaFunctions::StringTypeFromLua)) + ->template WrappingMember(&ContainerType::c_str) + ->Method("c_str", &ContainerType::c_str) + ->Method("Length", [](ContainerType* thisPtr) { return aznumeric_cast(thisPtr->length()); }) + ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Length) + ->Method("Equal", [](const ContainerType& lhs, const ContainerType& rhs) + { + return lhs == rhs; + }) + ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Equal) + ->Method("Find", [](ContainerType* thisPtr, const ContainerType& stringToFind, const int& startPos) + { + return aznumeric_cast(thisPtr->find(stringToFind, startPos)); + }) + ->Method("Substring", [](ContainerType* thisPtr, const int& pos, const int& len) + { + return thisPtr->substr(pos, len); + }) + ->Method("Replace", [](ContainerType* thisPtr, const ContainerType& stringToReplace, const ContainerType& replacementString) + { + SizeType startPos = 0; + while ((startPos = thisPtr->find(stringToReplace, startPos)) != ContainerType::npos && !stringToReplace.empty()) + { + thisPtr->replace(startPos, stringToReplace.length(), replacementString); + startPos += replacementString.length(); + } + + return *thisPtr; + }) + ->Method("ReplaceByIndex", [](ContainerType* thisPtr, const int& beginIndex, const int& endIndex, const ContainerType& replacementString) + { + thisPtr->replace(beginIndex, endIndex - beginIndex + 1, replacementString); + return *thisPtr; + }) + ->Method("Add", [](ContainerType* thisPtr, const ContainerType& addend) + { + return *thisPtr + addend; + }) + ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Concat) + ->Method("TrimLeft", [](ContainerType* thisPtr) + { + auto wsfront = AZStd::find_if_not(thisPtr->begin(), thisPtr->end(), [](char c) {return AZStd::is_space(c);}); + thisPtr->erase(thisPtr->begin(), wsfront); + return *thisPtr; + }) + ->Method("TrimRight", [](ContainerType* thisPtr) + { + auto wsend = AZStd::find_if_not(thisPtr->rbegin(), thisPtr->rend(), [](char c) {return AZStd::is_space(c);}); + thisPtr->erase(wsend.base(), thisPtr->end()); + return *thisPtr; + }) + ->Method("ToLower", [](ContainerType* thisPtr) + { + ContainerType toLowerString; + for (auto itr = thisPtr->begin(); itr < thisPtr->end(); itr++) + { + toLowerString.push_back(static_cast(tolower(*itr))); + } + return toLowerString; + }) + ->Method("ToUpper", [](ContainerType* thisPtr) + { + ContainerType toUpperString; + for (auto itr = thisPtr->begin(); itr < thisPtr->end(); itr++) + { + toUpperString.push_back(static_cast(toupper(*itr))); + } + return toUpperString; + }) + ->Method("Join", [](AZStd::vector* stringsToJoinPtr, const ContainerType& joinStr) + { + ContainerType joinString; + for (auto& stringToJoin : *stringsToJoinPtr) + { + joinString.append(stringToJoin).append(joinStr); + } + //Cut off the last join str + if (!stringsToJoinPtr->empty()) + { + joinString = joinString.substr(0, joinString.length() - joinStr.length()); + } + return joinString; + }) + + ->Method("Split", [](ContainerType* thisPtr, const ContainerType& splitter) + { + AZStd::vector splitStringList; + AZStd::tokenize(*thisPtr, splitter, splitStringList); + return splitStringList; + }) + ; + } + } + void ReflectCommonStringView(ReflectContext* context) + { + using ContainerType = AZStd::string_view; + + if (BehaviorContext* behaviorContext = azrtti_cast(context)) + { + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Category, "Core") + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) + ->template Constructor() + ->Attribute(AZ::Script::Attributes::ConstructorOverride, &OnDemandLuaFunctions::ConstructStringView) + ->Attribute(AZ::Script::Attributes::ReaderWriterOverride, ScriptContext::CustomReaderWriter(&OnDemandLuaFunctions::StringTypeToLua, &OnDemandLuaFunctions::StringTypeFromLua)) + ->Method("ToString", [](const ContainerType& stringView) { return static_cast(stringView).c_str(); }, { { { "Reference", "String view object being converted to string" } } }) + ->Attribute(AZ::Script::Attributes::ToolTip, "Converts string_view to string") + ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::ToString) + ->template WrappingMember(&ContainerType::data) + ->Method("data", &ContainerType::data) + ->Attribute(AZ::Script::Attributes::ToolTip, "Returns reference to raw string data") + ->Method("length", [](ContainerType* thisPtr) { return aznumeric_cast(thisPtr->length()); }, { { { "This", "Reference to the object the method is being performed on" } } }) + ->Attribute(AZ::Script::Attributes::ToolTip, "Returns length of string view") + ->Attribute(AZ::Script::Attributes::Operator, AZ::Script::Attributes::OperatorType::Length) + ->Method("size", [](ContainerType* thisPtr) { return aznumeric_cast(thisPtr->size()); }, { { { "This", "Reference to the object the method is being performed on" }} }) + ->Attribute(AZ::Script::Attributes::ToolTip, "Returns length of string view") + ->Method("find", [](ContainerType* thisPtr, ContainerType stringToFind, int startPos) + { + return aznumeric_cast(thisPtr->find(stringToFind, startPos)); + }, { { { "This", "Reference to the object the method is being performed on" }, { "View", "View to search " }, { "Position", "Index in view to start search" }} }) + ->Attribute(AZ::Script::Attributes::ToolTip, "Searches for supplied string within this string") + ->Method("substr", [](ContainerType* thisPtr, int pos, int len) + { + return thisPtr->substr(pos, len); + }, { {{"This", "Reference to the object the method is being performed on"}, {"Position", "Index in view that indicates the beginning of the sub string"}, {"Count", "Length of characters that sub string view occupies" }} }) + ->Attribute(AZ::Script::Attributes::ToolTip, "Creates a sub view of this string view. The string data is not actually modified") + ->Method("remove_prefix", [](ContainerType* thisPtr, int n) {thisPtr->remove_prefix(n); }, + { { { "This", "Reference to the object the method is being performed on" }, { "Count", "Number of characters to remove from start of view" }} }) + ->Attribute(AZ::Script::Attributes::ToolTip, "Moves the supplied number of characters from the beginning of this sub view") + ->Method("remove_suffix", [](ContainerType* thisPtr, int n) {thisPtr->remove_suffix(n); }, + { { { "This", "Reference to the object the method is being performed on" } ,{ "Count", "Number of characters to remove from end of view" }} }) + ->Attribute(AZ::Script::Attributes::ToolTip, "Moves the supplied number of characters from the end of this sub view") + ; + } + } + + + void ReflectVoidOutcome(ReflectContext* context) + { + using OutcomeType = AZ::Outcome; + + if (BehaviorContext* behaviorContext = azrtti_cast(context)) + { + // note we can reflect iterator types and support iterators, as of know we want to keep it simple + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ->Attribute(AZ::ScriptCanvasAttributes::AllowInternalCreation, true) + ->Attribute(AZ::ScriptCanvasAttributes::PrettyName, &ScriptCanvasOnDemandReflection::OnDemandPrettyName::Get) + ->Attribute(AZ::Script::Attributes::ToolTip, &ScriptCanvasOnDemandReflection::OnDemandToolTip::Get) + ->Attribute(AZ::Script::Attributes::Category, &ScriptCanvasOnDemandReflection::OnDemandCategoryName::Get) + ->Attribute(AZ::ScriptCanvasAttributes::AllowInternalCreation, AttributeIsValid::IfPresent) + ->Attribute(AZ::ScriptCanvasAttributes::VariableCreationForbidden, AttributeIsValid::IfPresent) + ->Method("Failure", []() -> OutcomeType { return AZ::Failure(); }) + ->Method("Success", []() -> OutcomeType { return AZ::Success(); }) + ->Method("IsSuccess", &OutcomeType::IsSuccess) + ; + } + } + + void ReflectStdAny(ReflectContext* context) + { + if (BehaviorContext* behaviorContext = azrtti_cast(context)) + { + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ->Attribute( + Script::Attributes::Ignore, true) // Don't reflect any type to script (there should never be an any instance in script) + ->Attribute( + Script::Attributes::ReaderWriterOverride, + ScriptContext::CustomReaderWriter(&AZ::OnDemandLuaFunctions::AnyToLua, &OnDemandLuaFunctions::AnyFromLua)); + } + } + +} // namespace AZ diff --git a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryScriptUtils.cpp b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryScriptUtils.cpp index abaab425d3..c32591874b 100644 --- a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryScriptUtils.cpp +++ b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryScriptUtils.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Code/Framework/AzCore/AzCore/azcore_files.cmake b/Code/Framework/AzCore/AzCore/azcore_files.cmake index c2ee439645..b2ef586053 100644 --- a/Code/Framework/AzCore/AzCore/azcore_files.cmake +++ b/Code/Framework/AzCore/AzCore/azcore_files.cmake @@ -440,6 +440,7 @@ set(FILES RTTI/AttributeReader.h RTTI/AzStdOnDemandPrettyName.inl RTTI/AzStdOnDemandReflection.inl + RTTI/AzStdOnDemandReflectionSpecializations.cpp RTTI/AzStdOnDemandReflectionLuaFunctions.inl RTTI/BehaviorContext.cpp RTTI/BehaviorContext.h diff --git a/Code/Framework/AzCore/Tests/Settings/SettingsRegistryScriptUtilsTests.cpp b/Code/Framework/AzCore/Tests/Settings/SettingsRegistryScriptUtilsTests.cpp index 111b4a027a..0fc491ac34 100644 --- a/Code/Framework/AzCore/Tests/Settings/SettingsRegistryScriptUtilsTests.cpp +++ b/Code/Framework/AzCore/Tests/Settings/SettingsRegistryScriptUtilsTests.cpp @@ -10,11 +10,12 @@ #include #include #include +#include namespace SettingsRegistryScriptUtilsTests { static constexpr const char* SettingsRegistryScriptClassName = "SettingsRegistryInterface"; - + class SettingsRegistryBehaviorContextFixture : public UnitTest::ScopedAllocatorSetupFixture @@ -77,7 +78,7 @@ namespace SettingsRegistryScriptUtilsTests // so the invoking the getter on global Settings Registry should succeed, but return nullptr EXPECT_TRUE(globalSettingsRegistryGetter->InvokeResult(settingsRegistryObject)); EXPECT_EQ(nullptr, settingsRegistryObject.m_settingsRegistry); - + // Register the Settings Registry stored on the fixture with the SettingsRegistry Interface AZ::SettingsRegistry::Register(m_registry.get()); EXPECT_TRUE(globalSettingsRegistryGetter->InvokeResult(settingsRegistryObject)); @@ -227,7 +228,7 @@ namespace SettingsRegistryScriptUtilsTests R"( "intIndex": -55)" "\n" R"( })" "\n" R"(])"; - + // Populate the settings registry to match the expected json values m_registry->Set("/TestObject/boolValue", false); m_registry->Set("/TestObject/intValue", aznumeric_cast(17)); @@ -562,4 +563,4 @@ namespace SettingsRegistryScriptUtilsTests SettingsRegistryBehaviorContextParams{ "/TestObject/stringValue", AZStd::string_view{"Hello World"}, "GetString", "SetString" } ) ); -} +} diff --git a/Code/Framework/AzFramework/AzFramework/Terrain/TerrainDataRequestBus.cpp b/Code/Framework/AzFramework/AzFramework/Terrain/TerrainDataRequestBus.cpp index 59a49a48e1..947d3821ab 100644 --- a/Code/Framework/AzFramework/AzFramework/Terrain/TerrainDataRequestBus.cpp +++ b/Code/Framework/AzFramework/AzFramework/Terrain/TerrainDataRequestBus.cpp @@ -7,6 +7,7 @@ */ #include "TerrainDataRequestBus.h" +#include namespace AzFramework { diff --git a/Code/Tools/SceneAPI/SceneCore/Events/ExportProductList.cpp b/Code/Tools/SceneAPI/SceneCore/Events/ExportProductList.cpp index d8a4cf1991..2392ed8219 100644 --- a/Code/Tools/SceneAPI/SceneCore/Events/ExportProductList.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Events/ExportProductList.cpp @@ -8,6 +8,7 @@ #include #include +#include #include namespace AZ diff --git a/Gems/AWSClientAuth/Code/Include/Public/Authorization/ClientAuthAWSCredentials.h b/Gems/AWSClientAuth/Code/Include/Public/Authorization/ClientAuthAWSCredentials.h index ba08534d91..9a838be556 100644 --- a/Gems/AWSClientAuth/Code/Include/Public/Authorization/ClientAuthAWSCredentials.h +++ b/Gems/AWSClientAuth/Code/Include/Public/Authorization/ClientAuthAWSCredentials.h @@ -8,11 +8,15 @@ #pragma once -#include #include #include +namespace AZ +{ + class ReflectContext; +} + namespace AWSClientAuth { //! Client auth AWS Credentials object for serialization. @@ -54,31 +58,8 @@ namespace AWSClientAuth return m_sessionToken; } - static void Reflect(AZ::ReflectContext* context) - { - auto serializeContext = azrtti_cast(context); - if (serializeContext) - { - serializeContext->Class() - ->Field("AWSAccessKeyId", &ClientAuthAWSCredentials::m_accessKeyId) - ->Field("AWSSecretKey", &ClientAuthAWSCredentials::m_secretKey) - ->Field("AWSSessionToken", &ClientAuthAWSCredentials::m_sessionToken); - } + static void Reflect(AZ::ReflectContext* context); - AZ::BehaviorContext* behaviorContext = azrtti_cast(context); - if (behaviorContext) - { - behaviorContext->Class() - ->Attribute(AZ::Script::Attributes::Category, "AWSClientAuth") - ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) - ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) - ->Constructor() - ->Constructor() - ->Property("AWSAccessKeyId", BehaviorValueGetter(&ClientAuthAWSCredentials::m_accessKeyId), BehaviorValueSetter(&ClientAuthAWSCredentials::m_accessKeyId)) - ->Property("AWSSecretKey", BehaviorValueGetter(&ClientAuthAWSCredentials::m_secretKey), BehaviorValueSetter(&ClientAuthAWSCredentials::m_secretKey)) - ->Property("AWSSessionToken", BehaviorValueGetter(&ClientAuthAWSCredentials::m_sessionToken), BehaviorValueSetter(&ClientAuthAWSCredentials::m_sessionToken)); - } - } private: AZStd::string m_accessKeyId; diff --git a/Gems/AWSClientAuth/Code/Source/Authorization/ClientAuthAWSCredentials.cpp b/Gems/AWSClientAuth/Code/Source/Authorization/ClientAuthAWSCredentials.cpp new file mode 100644 index 0000000000..764c67a4a6 --- /dev/null +++ b/Gems/AWSClientAuth/Code/Source/Authorization/ClientAuthAWSCredentials.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include + +#include +#include +#include +#include +#include + +namespace AWSClientAuth +{ + void ClientAuthAWSCredentials::Reflect(AZ::ReflectContext* context) + { + auto serializeContext = azrtti_cast(context); + if (serializeContext) + { + serializeContext->Class() + ->Field("AWSAccessKeyId", &ClientAuthAWSCredentials::m_accessKeyId) + ->Field("AWSSecretKey", &ClientAuthAWSCredentials::m_secretKey) + ->Field("AWSSessionToken", &ClientAuthAWSCredentials::m_sessionToken); + } + + AZ::BehaviorContext* behaviorContext = azrtti_cast(context); + if (behaviorContext) + { + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Category, "AWSClientAuth") + ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Constructor() + ->Constructor() + ->Property( + "AWSAccessKeyId", BehaviorValueGetter(&ClientAuthAWSCredentials::m_accessKeyId), + BehaviorValueSetter(&ClientAuthAWSCredentials::m_accessKeyId)) + ->Property( + "AWSSecretKey", BehaviorValueGetter(&ClientAuthAWSCredentials::m_secretKey), + BehaviorValueSetter(&ClientAuthAWSCredentials::m_secretKey)) + ->Property( + "AWSSessionToken", BehaviorValueGetter(&ClientAuthAWSCredentials::m_sessionToken), + BehaviorValueSetter(&ClientAuthAWSCredentials::m_sessionToken)); + } + } +} // namespace AWSClientAuth diff --git a/Gems/AWSClientAuth/Code/awsclientauth_files.cmake b/Gems/AWSClientAuth/Code/awsclientauth_files.cmake index ad679fe13a..bd4c971377 100644 --- a/Gems/AWSClientAuth/Code/awsclientauth_files.cmake +++ b/Gems/AWSClientAuth/Code/awsclientauth_files.cmake @@ -42,6 +42,7 @@ set(FILES Source/Authentication/LWAAuthenticationProvider.cpp Source/Authentication/GoogleAuthenticationProvider.cpp + Source/Authorization/ClientAuthAWSCredentials.cpp Source/Authorization/AWSCognitoAuthorizationController.cpp Source/Authorization/AWSClientAuthPersistentCognitoIdentityProvider.cpp diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/RadiusWeightModifier/RadiusWeightModifierComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/RadiusWeightModifier/RadiusWeightModifierComponentController.cpp index c2d7176436..434fc81e8f 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/RadiusWeightModifier/RadiusWeightModifierComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/RadiusWeightModifier/RadiusWeightModifierComponentController.cpp @@ -8,6 +8,7 @@ #include #include +#include namespace AZ { diff --git a/Gems/Blast/Code/Source/Asset/BlastChunksAsset.cpp b/Gems/Blast/Code/Source/Asset/BlastChunksAsset.cpp index 1d0ce15241..2a1ae5eb04 100644 --- a/Gems/Blast/Code/Source/Asset/BlastChunksAsset.cpp +++ b/Gems/Blast/Code/Source/Asset/BlastChunksAsset.cpp @@ -7,6 +7,7 @@ #include #include +#include namespace Blast { diff --git a/Gems/EditorPythonBindings/Code/Source/PythonReflectionComponent.cpp b/Gems/EditorPythonBindings/Code/Source/PythonReflectionComponent.cpp index 38e00e73ed..4ca40a5bab 100644 --- a/Gems/EditorPythonBindings/Code/Source/PythonReflectionComponent.cpp +++ b/Gems/EditorPythonBindings/Code/Source/PythonReflectionComponent.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/Gems/EditorPythonBindings/Code/Source/PythonUtility.cpp b/Gems/EditorPythonBindings/Code/Source/PythonUtility.cpp index bc1a7d45a3..d324c6c14b 100644 --- a/Gems/EditorPythonBindings/Code/Source/PythonUtility.cpp +++ b/Gems/EditorPythonBindings/Code/Source/PythonUtility.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -276,7 +277,7 @@ namespace EditorPythonBindings } return false; } - + bool AllocateBehaviorValueParameter(const AZ::BehaviorMethod* behaviorMethod, AZ::BehaviorValueParameter& result, Convert::StackVariableAllocator& stackVariableAllocator) { if (const AZ::BehaviorParameter* resultType = behaviorMethod->GetResult()) @@ -390,7 +391,7 @@ namespace EditorPythonBindings cleanUp(); } } - + void StackVariableAllocator::StoreVariableDeleter(VariableDeleter&& deleter) { m_cleanUpItems.emplace_back(deleter); diff --git a/Gems/LmbrCentral/Code/Source/Shape/ShapeComponent.cpp b/Gems/LmbrCentral/Code/Source/Shape/ShapeComponent.cpp index 522493e1b4..9599b3f6e7 100644 --- a/Gems/LmbrCentral/Code/Source/Shape/ShapeComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Shape/ShapeComponent.cpp @@ -7,6 +7,7 @@ */ #include +#include #include namespace LmbrCentral @@ -23,7 +24,7 @@ namespace LmbrCentral Call(FN_OnShapeChanged, changeReason); } }; - + void ShapeComponentGeneric::Reflect(AZ::ReflectContext* context) { AZ::BehaviorContext* behaviorContext = azrtti_cast(context); @@ -41,7 +42,7 @@ namespace LmbrCentral behaviorContext->Enum<(int)ShapeComponentNotifications::ShapeChangeReasons::TransformChanged>("ShapeChangeReasons_TransformChanged") ->Enum<(int)LmbrCentral::ShapeComponentNotifications::ShapeChangeReasons::ShapeChanged>("ShapeChangeReasons_ShapeChanged"); - + behaviorContext->EBus("ShapeComponentNotificationsBus") ->Handler() ; diff --git a/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.h b/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.h index 0239170640..a75685fb12 100644 --- a/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.h +++ b/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -41,7 +42,7 @@ namespace Terrain /////////////////////////////////////////// // TerrainSystemServiceRequestBus::Handler Impl - + void SetWorldBounds(const AZ::Aabb& worldBounds) override; void SetHeightQueryResolution(AZ::Vector2 queryResolution) override; diff --git a/Gems/WhiteBox/Code/Source/WhiteBoxToolApiReflection.cpp b/Gems/WhiteBox/Code/Source/WhiteBoxToolApiReflection.cpp index f1b015b359..9c954e628c 100644 --- a/Gems/WhiteBox/Code/Source/WhiteBoxToolApiReflection.cpp +++ b/Gems/WhiteBox/Code/Source/WhiteBoxToolApiReflection.cpp @@ -10,6 +10,7 @@ #include "WhiteBoxToolApiReflection.h" #include +#include #include #include #include