Merge pull request #1194 from aws-lumberyard-dev/carlito/stabilization/2106
Fixes for internal if-branch node parser bug (LYN-4347) and exposing…
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)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3356,23 +3356,27 @@ namespace ScriptCanvas
|
||||
|
||||
if (executionIf->GetId().m_node->IsIfBranchPrefacedWithBooleanExpression())
|
||||
{
|
||||
auto removeChildOutcome = RemoveChild(executionIf->ModParent(), executionIf);
|
||||
if (!removeChildOutcome.IsSuccess())
|
||||
ExecutionTreePtr booleanExpression;
|
||||
|
||||
{
|
||||
AddError(executionIf->GetNodeId(), executionIf, ScriptCanvas::ParseErrors::FailedToRemoveChild);
|
||||
auto removeChildOutcome = RemoveChild(executionIf->ModParent(), executionIf);
|
||||
if (!removeChildOutcome.IsSuccess())
|
||||
{
|
||||
AddError(executionIf->GetNodeId(), executionIf, ScriptCanvas::ParseErrors::FailedToRemoveChild);
|
||||
}
|
||||
|
||||
if (!IsErrorFree())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto indexAndChild = removeChildOutcome.TakeValue();
|
||||
|
||||
booleanExpression = CreateChild(executionIf->ModParent(), executionIf->GetId().m_node, executionIf->GetId().m_slot);
|
||||
executionIf->ModParent()->InsertChild(indexAndChild.first, { indexAndChild.second.m_slot, indexAndChild.second.m_output, booleanExpression });
|
||||
executionIf->SetParent(booleanExpression);
|
||||
}
|
||||
|
||||
if (!IsErrorFree())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto indexAndChild = removeChildOutcome.TakeValue();
|
||||
|
||||
ExecutionTreePtr booleanExpression = CreateChild(executionIf->ModParent(), executionIf->GetId().m_node, executionIf->GetId().m_slot);
|
||||
executionIf->ModParent()->InsertChild(indexAndChild.first, { indexAndChild.second.m_slot, indexAndChild.second.m_output, booleanExpression });
|
||||
executionIf->SetParent(booleanExpression);
|
||||
|
||||
// make a condition here
|
||||
auto symbol = CheckLogicalExpressionSymbol(booleanExpression);
|
||||
if (symbol != Symbol::FunctionCall && symbol != Symbol::Count)
|
||||
@@ -3402,7 +3406,7 @@ namespace ScriptCanvas
|
||||
return;
|
||||
}
|
||||
|
||||
const auto indexAndChild2 = removeChildOutcome.TakeValue();
|
||||
const auto indexAndChild2 = removeChildOutcome2.TakeValue();
|
||||
|
||||
// parse if statement internal function
|
||||
ExecutionTreePtr internalFunction = CreateChild(booleanExpression->ModParent(), booleanExpression->GetId().m_node, booleanExpression->GetId().m_slot);
|
||||
@@ -4782,7 +4786,7 @@ namespace ScriptCanvas
|
||||
{
|
||||
PropertyExtractionPtr extraction = AZStd::make_shared<PropertyExtraction>();
|
||||
extraction->m_slot = slot;
|
||||
extraction->m_name = propertyField.first;
|
||||
extraction->m_name = AZ::ReplaceCppArtifacts(propertyField.first);
|
||||
execution->AddPropertyExtractionSource(slot, extraction);
|
||||
}
|
||||
else
|
||||
|
||||
+2499
File diff suppressed because it is too large
Load Diff
@@ -90,6 +90,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ScriptCanvasTestFixture, ParseFunctionIfBranchWithConnectedInput)
|
||||
{
|
||||
RunUnitTestGraph("LY_SC_UnitTest_ParseFunctionIfBranchWithConnectedInput");
|
||||
}
|
||||
|
||||
TEST_F(ScriptCanvasTestFixture, UseRawBehaviorProperties)
|
||||
{
|
||||
RunUnitTestGraph("LY_SC_UnitTest_UseRawBehaviorProperties");
|
||||
|
||||
Reference in New Issue
Block a user