Build time reduction: AzStdOnDemandReflection (#3111)

* Move a few specializations from AzStdOnDemandReflection.inl to cpp file

This reduces compilation time and produced profile/debug file sizes.

The specializations for string and string_view are only implemented for 'char' type, since
others are not used anywhere.

Extracted `Reflect` method from `ClientAuthAWSCredentials` to a cpp file.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Windows build fixes.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Added missing license.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Fix missing spaces in template argument lists

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Clang format on ClientAuthAWSCredentials.cpp

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Merge upstream development and fix linux build.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>
monroegm-disable-blank-issue-2
Artur K 4 years ago committed by GitHub
parent cf4cb2750a
commit 3a4937456a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,7 @@
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
namespace AZ {
struct Uuid;

@ -7,18 +7,17 @@
*/
#pragma once
#include <AzCore/Casting/numeric_cast.h>
#include <AzCore/Script/ScriptContext.h>
#include <AzCore/Script/ScriptContextAttributes.h>
#include <AzCore/ScriptCanvas/ScriptCanvasAttributes.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/algorithm.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <AzCore/std/string/conversions.h>
#include <AzCore/std/string/tokenize.h>
#include <AzCore/ScriptCanvas/ScriptCanvasOnDemandNames.h>
#include <AzCore/RTTI/AzStdOnDemandPrettyName.inl>
#include <AzCore/RTTI/AzStdOnDemandReflectionLuaFunctions.inl>
#include <AzCore/EBus/Event.h>
#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<typename T>
struct OnDemandPrettyName;
template<typename T>
struct OnDemandToolTip;
template<typename T>
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<class Element, class Traits, class Allocator>
struct OnDemandReflection< AZStd::basic_string<Element, Traits, Allocator> >
@ -66,108 +85,16 @@ namespace AZ
using ContainerType = AZStd::basic_string<Element, Traits, Allocator>;
using SizeType = typename ContainerType::size_type;
using ValueType = typename ContainerType::value_type;
static void Reflect(ReflectContext* context)
{
if (BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context))
constexpr bool is_string = AZStd::is_same_v<Element, char> && AZStd::is_same_v<Traits, AZStd::char_traits<char>>
&& AZStd::is_same_v<Allocator, AZStd::allocator>;
if constexpr(is_string)
{
behaviorContext->Class<ContainerType>()
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
->template Constructor<typename ContainerType::value_type*>()
->Attribute(AZ::Script::Attributes::ConstructorOverride, &OnDemandLuaFunctions::ConstructBasicString<Element, Traits, Allocator>)
->Attribute(AZ::Script::Attributes::ReaderWriterOverride, ScriptContext::CustomReaderWriter(&OnDemandLuaFunctions::StringTypeToLua<ContainerType>, &OnDemandLuaFunctions::StringTypeFromLua<ContainerType>))
->template WrappingMember<const char*>(&ContainerType::c_str)
->Method("c_str", &ContainerType::c_str)
->Method("Length", [](ContainerType* thisPtr) { return aznumeric_cast<int>(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<int>(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<ValueType>(tolower(*itr)));
}
return toLowerString;
})
->Method("ToUpper", [](ContainerType* thisPtr)
{
ContainerType toUpperString;
for (auto itr = thisPtr->begin(); itr < thisPtr->end(); itr++)
{
toUpperString.push_back(static_cast<ValueType>(toupper(*itr)));
}
return toUpperString;
})
->Method("Join", [](AZStd::vector<ContainerType>* 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<ContainerType> 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<BehaviorContext*>(context))
{
behaviorContext->Class<ContainerType>()
->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<typename ContainerType::value_type*>()
->Attribute(AZ::Script::Attributes::ConstructorOverride, &OnDemandLuaFunctions::ConstructStringView<Element, Traits>)
->Attribute(AZ::Script::Attributes::ReaderWriterOverride, ScriptContext::CustomReaderWriter(&OnDemandLuaFunctions::StringTypeToLua<ContainerType>, &OnDemandLuaFunctions::StringTypeFromLua<ContainerType>))
->Method("ToString", [](const ContainerType& stringView) { return static_cast<AZStd::string>(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<const char*>(&ContainerType::data)
->Method("data", &ContainerType::data)
->Attribute(AZ::Script::Attributes::ToolTip, "Returns reference to raw string data")
->Method("length", [](ContainerType* thisPtr) { return aznumeric_cast<int>(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<int>(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<int>(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<Element,char> && AZStd::is_same_v<Traits,AZStd::char_traits<char>>;
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<T>;
// 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<T>;
// 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<void, void> 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<int>(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<AZ::Outcome<void, void>>
{
using OutcomeType = AZ::Outcome<void, void>;
static void Reflect(ReflectContext* context)
{
if (BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
// note we can reflect iterator types and support iterators, as of know we want to keep it simple
behaviorContext->Class<OutcomeType>()
->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<OutcomeType>::Get)
->Attribute(AZ::Script::Attributes::ToolTip, &ScriptCanvasOnDemandReflection::OnDemandToolTip<OutcomeType>::Get)
->Attribute(AZ::Script::Attributes::Category, &ScriptCanvasOnDemandReflection::OnDemandCategoryName<OutcomeType>::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<AZStd::any>
{
static void Reflect(ReflectContext* context)
{
if (BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<AZStd::any>()
->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);
}
};

@ -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 <AzCore/Math/Uuid.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/RTTI/TypeInfo.h>
#include <AzCore/std/string/alphanum.h>
#include <AzCore/std/string/conversions.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/string/tokenize.h>
#include <AzCore/RTTI/AzStdOnDemandReflection.inl>
#include <AzCore/RTTI/AzStdOnDemandReflectionLuaFunctions.inl>
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<BehaviorContext*>(context))
{
behaviorContext->Class<ContainerType>()
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
->template Constructor<typename ContainerType::value_type*>()
->Attribute(AZ::Script::Attributes::ConstructorOverride, &OnDemandLuaFunctions::ConstructBasicString<ContainerType::value_type, ContainerType::traits_type, ContainerType::allocator_type>)
->Attribute(AZ::Script::Attributes::ReaderWriterOverride, ScriptContext::CustomReaderWriter(&OnDemandLuaFunctions::StringTypeToLua<ContainerType>, &OnDemandLuaFunctions::StringTypeFromLua<ContainerType>))
->template WrappingMember<const char*>(&ContainerType::c_str)
->Method("c_str", &ContainerType::c_str)
->Method("Length", [](ContainerType* thisPtr) { return aznumeric_cast<int>(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<int>(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<ValueType>(tolower(*itr)));
}
return toLowerString;
})
->Method("ToUpper", [](ContainerType* thisPtr)
{
ContainerType toUpperString;
for (auto itr = thisPtr->begin(); itr < thisPtr->end(); itr++)
{
toUpperString.push_back(static_cast<ValueType>(toupper(*itr)));
}
return toUpperString;
})
->Method("Join", [](AZStd::vector<ContainerType>* 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<ContainerType> splitStringList;
AZStd::tokenize(*thisPtr, splitter, splitStringList);
return splitStringList;
})
;
}
}
void ReflectCommonStringView(ReflectContext* context)
{
using ContainerType = AZStd::string_view;
if (BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<ContainerType>()
->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<typename ContainerType::value_type*>()
->Attribute(AZ::Script::Attributes::ConstructorOverride, &OnDemandLuaFunctions::ConstructStringView<ContainerType::value_type, ContainerType::traits_type>)
->Attribute(AZ::Script::Attributes::ReaderWriterOverride, ScriptContext::CustomReaderWriter(&OnDemandLuaFunctions::StringTypeToLua<ContainerType>, &OnDemandLuaFunctions::StringTypeFromLua<ContainerType>))
->Method("ToString", [](const ContainerType& stringView) { return static_cast<AZStd::string>(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<const char*>(&ContainerType::data)
->Method("data", &ContainerType::data)
->Attribute(AZ::Script::Attributes::ToolTip, "Returns reference to raw string data")
->Method("length", [](ContainerType* thisPtr) { return aznumeric_cast<int>(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<int>(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<int>(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<void, void>;
if (BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
// note we can reflect iterator types and support iterators, as of know we want to keep it simple
behaviorContext->Class<OutcomeType>()
->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<OutcomeType>::Get)
->Attribute(AZ::Script::Attributes::ToolTip, &ScriptCanvasOnDemandReflection::OnDemandToolTip<OutcomeType>::Get)
->Attribute(AZ::Script::Attributes::Category, &ScriptCanvasOnDemandReflection::OnDemandCategoryName<OutcomeType>::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<BehaviorContext*>(context))
{
behaviorContext->Class<AZStd::any>()
->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

@ -6,6 +6,7 @@
*
*/
#include <AzCore/IO/ByteContainerStream.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>

@ -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

@ -10,11 +10,12 @@
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzCore/Settings/SettingsRegistryScriptUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/std/containers/variant.h>
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<T>
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<AZ::s64>(17));
@ -562,4 +563,4 @@ namespace SettingsRegistryScriptUtilsTests
SettingsRegistryBehaviorContextParams{ "/TestObject/stringValue", AZStd::string_view{"Hello World"}, "GetString", "SetString" }
)
);
}
}

@ -7,6 +7,7 @@
*/
#include "TerrainDataRequestBus.h"
#include <AzCore/Serialization/SerializeContext.h>
namespace AzFramework
{

@ -8,6 +8,7 @@
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/limits.h>
namespace AZ

@ -8,11 +8,15 @@
#pragma once
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/std/string/string.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
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<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<ClientAuthAWSCredentials>()
->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<AZ::BehaviorContext*>(context);
if (behaviorContext)
{
behaviorContext->Class<ClientAuthAWSCredentials>()
->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<const ClientAuthAWSCredentials&>()
->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;

@ -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 <Authorization/ClientAuthAWSCredentials.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/RTTI/AzStdOnDemandReflection.inl>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/AZStdContainers.inl>
namespace AWSClientAuth
{
void ClientAuthAWSCredentials::Reflect(AZ::ReflectContext* context)
{
auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<ClientAuthAWSCredentials>()
->Field("AWSAccessKeyId", &ClientAuthAWSCredentials::m_accessKeyId)
->Field("AWSSecretKey", &ClientAuthAWSCredentials::m_secretKey)
->Field("AWSSessionToken", &ClientAuthAWSCredentials::m_sessionToken);
}
AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context);
if (behaviorContext)
{
behaviorContext->Class<ClientAuthAWSCredentials>()
->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<const ClientAuthAWSCredentials&>()
->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

@ -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

@ -8,6 +8,7 @@
#include <PostProcess/RadiusWeightModifier/RadiusWeightModifierComponentController.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
namespace AZ
{

@ -7,6 +7,7 @@
#include <Asset/BlastChunksAsset.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
namespace Blast
{

@ -23,6 +23,7 @@
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/Serialization/EditContextConstants.inl>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/PlatformDef.h>
#include <AzCore/IO/SystemFile.h>

@ -13,6 +13,7 @@
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/RTTI/TypeInfo.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <EditorPythonBindings/CustomTypeBindingBus.h>
#include <pybind11/embed.h>
@ -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);

@ -7,6 +7,7 @@
*/
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <LmbrCentral/Shape/ShapeComponentBus.h>
namespace LmbrCentral
@ -23,7 +24,7 @@ namespace LmbrCentral
Call(FN_OnShapeChanged, changeReason);
}
};
void ShapeComponentGeneric::Reflect(AZ::ReflectContext* context)
{
AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(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>("ShapeComponentNotificationsBus")
->Handler<BehaviorShapeComponentNotificationsBusHandler>()
;

@ -13,6 +13,7 @@
#include <AzCore/std/algorithm.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/std/parallel/shared_mutex.h>
#include <AzCore/std/containers/map.h>
#include <AzCore/Math/Color.h>
#include <AzCore/Math/Aabb.h>
@ -41,7 +42,7 @@ namespace Terrain
///////////////////////////////////////////
// TerrainSystemServiceRequestBus::Handler Impl
void SetWorldBounds(const AZ::Aabb& worldBounds) override;
void SetHeightQueryResolution(AZ::Vector2 queryResolution) override;

@ -10,6 +10,7 @@
#include "WhiteBoxToolApiReflection.h"
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <WhiteBox/EditorWhiteBoxComponentBus.h>
#include <WhiteBox/WhiteBoxComponentBus.h>
#include <WhiteBox/WhiteBoxToolApi.h>

Loading…
Cancel
Save