From a3e541cc47564b3823b016fb0ce3c068f376fbb0 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Tue, 25 Jan 2022 16:14:02 -0800 Subject: [PATCH] Adding back NodeableOutNative.h per PR request Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- .../NodeableOut/NodeableOutNative.h_unused | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/NodeableOut/NodeableOutNative.h_unused diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/NodeableOut/NodeableOutNative.h_unused b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/NodeableOut/NodeableOutNative.h_unused new file mode 100644 index 0000000000..ab6859db1e --- /dev/null +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/NodeableOut/NodeableOutNative.h_unused @@ -0,0 +1,66 @@ +/* + * 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 + * + */ + +#pragma once + +#include +#include +#include + +#include + +namespace ScriptCanvas +{ + namespace Execution + { + template + FunctorOut CreateOutWithArgs(Callable&& callable, Allocator& allocator, AZStd::Internal::pack_traits_arg_sequence, std::index_sequence, ReturnTypeIsNotVoid) + { + auto nodeCallWrapper = [callable = AZStd::forward(callable)](AZ::BehaviorValueParameter* result, AZ::BehaviorValueParameter* arguments, int numArguments) mutable + { + [[maybe_unused]] constexpr size_t numFunctorArguments = sizeof...(Args); + (void)numArguments; + AZ_Assert(numArguments == numFunctorArguments, "number of arguments doesn't match number of parameters"); + AZ_Assert(result, "no null result allowed"); + result->StoreResult(AZStd::invoke(callable, *arguments[IndexSequence].GetAsUnsafe()...)); + }; + + static_assert(!AZStd::is_same_v || sizeof(nodeCallWrapper) <= MaxNodeableOutStackSize, "Lambda is too large to fit within NodebleOut functor"); + return FunctorOut(AZStd::move(nodeCallWrapper), allocator); + } + + template + FunctorOut CreateOutWithArgs(Callable&& callable, Allocator& allocator, AZStd::Internal::pack_traits_arg_sequence, std::index_sequence, ReturnTypeIsVoid) + { + auto nodeCallWrapper = [callable = AZStd::forward(callable)](AZ::BehaviorValueParameter*, AZ::BehaviorValueParameter* arguments, int numArguments) mutable + { + [[maybe_unused]] constexpr size_t numFunctorArguments = sizeof...(Args); + (void)numArguments; + AZ_Assert(numArguments == numFunctorArguments, "number of arguments doesn't match number of parameters"); + AZStd::invoke(callable, *arguments[IndexSequence].GetAsUnsafe()...); + }; + + static_assert(!AZStd::is_same_v || sizeof(nodeCallWrapper) <= MaxNodeableOutStackSize, "Lambda is too large to fit within NodebleOut functor"); + return FunctorOut(AZStd::move(nodeCallWrapper), allocator); + } + + template + FunctorOut CreateOut(Callable&& callable, Allocator& allocator) + { + using CallableTraits = AZStd::function_traits>; + return CreateOutWithArgs + ( AZStd::forward(callable) + , allocator + , typename CallableTraits::arg_types{} + , typename CallableTraits::template expand_args{} + , typename AZStd::is_void::type{}); + } + + } + +}