Merge branch 'stabilization/2106' into JsonSerialization/UnsupportedWarnings
This commit is contained in:
@@ -161,7 +161,56 @@ namespace AZ
|
||||
return "A pair is an fixed size collection of two elements.";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
void GetTypeNamesFold(AZStd::vector<AZStd::string>& result, AZ::BehaviorContext& context)
|
||||
{
|
||||
result.push_back(OnDemandPrettyName<T>::Get(context));
|
||||
};
|
||||
|
||||
template<typename... T>
|
||||
void GetTypeNames(AZStd::vector<AZStd::string>& result, AZ::BehaviorContext& context)
|
||||
{
|
||||
(GetTypeNamesFold<T>(result, context), ...);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void GetTypeNamesFold(AZStd::string& result, AZ::BehaviorContext& context)
|
||||
{
|
||||
if (!result.empty())
|
||||
{
|
||||
result += ", ";
|
||||
}
|
||||
|
||||
result += OnDemandPrettyName<T>::Get(context);
|
||||
};
|
||||
|
||||
template<typename... T>
|
||||
void GetTypeNames(AZStd::string& result, AZ::BehaviorContext& context)
|
||||
{
|
||||
(GetTypeNamesFold<T>(result, context), ...);
|
||||
};
|
||||
|
||||
template<typename... T>
|
||||
struct OnDemandPrettyName<AZStd::tuple<T...>>
|
||||
{
|
||||
static AZStd::string Get(AZ::BehaviorContext& context)
|
||||
{
|
||||
AZStd::string typeNames;
|
||||
GetTypeNames<T...>(typeNames, context);
|
||||
return AZStd::string::format("Tuple<%s>", typeNames.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
template<typename... T>
|
||||
struct OnDemandToolTip<AZStd::tuple<T...>>
|
||||
{
|
||||
static AZStd::string Get(AZ::BehaviorContext&)
|
||||
{
|
||||
return "A tuple is an fixed size collection of any number of any type of element.";
|
||||
}
|
||||
};
|
||||
|
||||
template<class Key, class MappedType, class Hasher, class EqualKey, class Allocator>
|
||||
struct OnDemandPrettyName< AZStd::unordered_map<Key, MappedType, Hasher, EqualKey, Allocator> >
|
||||
{
|
||||
|
||||
@@ -813,20 +813,27 @@ namespace AZ
|
||||
{
|
||||
using ContainerType = AZStd::tuple<T...>;
|
||||
|
||||
template<size_t Index>
|
||||
static void ReflectUnpackMethodFold(BehaviorContext::ClassBuilder<ContainerType>& builder)
|
||||
template<typename Targ, size_t Index>
|
||||
static void ReflectUnpackMethodFold(BehaviorContext::ClassBuilder<ContainerType>& builder, const AZStd::vector<AZStd::string>& typeNames)
|
||||
{
|
||||
const AZStd::string methodName = AZStd::string::format("Get%zu", Index);
|
||||
builder->Method(methodName.data(), [](ContainerType& value) { return AZStd::get<Index>(value); })
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
builder->Method(methodName.data(), [](ContainerType& thisPointer) { return AZStd::get<Index>(thisPointer); })
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::List)
|
||||
->Attribute(AZ::ScriptCanvasAttributes::TupleGetFunctionIndex, Index)
|
||||
;
|
||||
|
||||
builder->Property
|
||||
( AZStd::string::format("element_%zu_%s", Index, typeNames[Index].c_str()).c_str()
|
||||
, [](ContainerType& thisPointer) { return AZStd::get<Index>(thisPointer); }
|
||||
, [](ContainerType& thisPointer, const Targ& element) { AZStd::get<Index>(thisPointer) = element; });
|
||||
}
|
||||
|
||||
template<size_t... Indices>
|
||||
template<typename... Targ, size_t... Indices>
|
||||
static void ReflectUnpackMethods(BehaviorContext::ClassBuilder<ContainerType>& builder, AZStd::index_sequence<Indices...>)
|
||||
{
|
||||
(ReflectUnpackMethodFold<Indices>(builder), ...);
|
||||
AZStd::vector<AZStd::string> typeNames;
|
||||
ScriptCanvasOnDemandReflection::GetTypeNames<T...>(typeNames, *builder.m_context);
|
||||
(ReflectUnpackMethodFold<Targ, Indices>(builder, typeNames), ...);
|
||||
}
|
||||
|
||||
static void Reflect(ReflectContext* context)
|
||||
@@ -851,9 +858,10 @@ namespace AZ
|
||||
->Attribute(AZ::ScriptCanvasAttributes::TupleConstructorFunction, constructorHolder)
|
||||
;
|
||||
|
||||
ReflectUnpackMethods(builder, AZStd::make_index_sequence<sizeof...(T)>{});
|
||||
ReflectUnpackMethods<T...>(builder, AZStd::make_index_sequence<sizeof...(T)>{});
|
||||
|
||||
builder->Method("GetSize", []() { return AZStd::tuple_size<ContainerType>::value; })
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::List)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,8 @@ namespace AZ
|
||||
//! Save a string to a file. Otherwise returns a failure with error message.
|
||||
AZ::Outcome<void, AZStd::string> WriteFile(AZStd::string_view content, AZStd::string_view filePath);
|
||||
|
||||
//! Read a file into a string. Returns a failure with error message if the content could not be loaded.
|
||||
//! Read a file into a string. Returns a failure with error message if the content could not be loaded or if
|
||||
//! the file size is larger than the max file size provided.
|
||||
template<typename Container = AZStd::string>
|
||||
AZ::Outcome<Container, AZStd::string> ReadFile(AZStd::string_view filePath, size_t maxFileSize = DefaultMaxFileSize);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user