diff --git a/Source/Engine/Core/ScopeExit.h b/Source/Engine/Core/ScopeExit.h index 37068a2ff..48064adc0 100644 --- a/Source/Engine/Core/ScopeExit.h +++ b/Source/Engine/Core/ScopeExit.h @@ -33,4 +33,6 @@ namespace THelpers }; } +// Utility to execute code from lambda on scope exit (no matter the place with scope arguments capture) +// Usage: SCOPE_EXIT{ DoSomething(); }; #define SCOPE_EXIT const auto CONCAT_MACROS(__scopeExit, __LINE__) = THelpers::ScopeExitInternal() * [&]() diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index 021d40dc6..1df84ad56 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -116,7 +116,8 @@ namespace Flax.Build.Bindings else { // Pass as pointer to local variable converted for managed runtime - if (paramType.IsPtr) + var paramApiType = FindApiTypeInfo(buildData, paramType, caller); + if (paramType.IsPtr && (paramApiType == null || !paramApiType.IsScriptingObject)) result = string.Format(nativeToManaged, '*' + paramName); contents.Append($" auto __param_{paramName} = {result};").AppendLine(); result = $"&__param_{paramName}";