From 2881ca17a09f98ac1bbb4c3c643d736974f2f40c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 22 May 2023 18:06:08 +0200 Subject: [PATCH] Fix bindings code instance object param `obj` to `__obj` to prevent name collisions --- .../Bindings/BindingsGenerator.CSharp.cs | 2 +- .../Bindings/BindingsGenerator.Cpp.cs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs index 6f7cba455..1495c7e70 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs @@ -450,7 +450,7 @@ namespace Flax.Build.Bindings var separator = false; if (!functionInfo.IsStatic) { - contents.Append("IntPtr obj"); + contents.Append("IntPtr __obj"); separator = true; } diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index 9acaf1f9c..826d77248 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -948,7 +948,7 @@ namespace Flax.Build.Bindings var separator = false; if (!functionInfo.IsStatic) { - contents.Append(string.Format("{0}* obj", caller.Name)); + contents.Append(string.Format("{0}* __obj", caller.Name)); separator = true; } @@ -1025,7 +1025,7 @@ namespace Flax.Build.Bindings contents.AppendLine(); contents.AppendLine(" {"); if (!functionInfo.IsStatic) - contents.AppendLine(" if (obj == nullptr) DebugLog::ThrowNullReference();"); + contents.AppendLine(" if (__obj == nullptr) DebugLog::ThrowNullReference();"); string callBegin = " "; if (functionInfo.Glue.UseReferenceForResult) @@ -1052,7 +1052,7 @@ namespace Flax.Build.Bindings else { // Call native member method - call = $"obj->{functionInfo.Name}"; + call = $"__obj->{functionInfo.Name}"; } string callParams = string.Empty; separator = false; @@ -1760,7 +1760,7 @@ namespace Flax.Build.Bindings continue; var paramsCount = eventInfo.Type.GenericArgs?.Count ?? 0; CppIncludeFiles.Add("Engine/Profiler/ProfilerCPU.h"); - var bindPrefix = eventInfo.IsStatic ? classTypeNameNative + "::" : "obj->"; + var bindPrefix = eventInfo.IsStatic ? classTypeNameNative + "::" : "__obj->"; if (useCSharp) { @@ -1838,7 +1838,7 @@ namespace Flax.Build.Bindings CppInternalCalls.Add(new KeyValuePair(eventInfo.Name + "_Bind", eventInfo.Name + "_ManagedBind")); contents.AppendFormat(" static void {0}_ManagedBind(", eventInfo.Name); if (!eventInfo.IsStatic) - contents.AppendFormat("{0}* obj, ", classTypeNameNative); + contents.AppendFormat("{0}* __obj, ", classTypeNameNative); contents.Append("bool bind)").AppendLine(); contents.Append(" {").AppendLine(); contents.Append(" Function();", eventInfo.Name).AppendLine(); else - contents.AppendFormat(" f.Bind<{1}Internal, &{1}Internal::{0}_ManagedWrapper>(({1}Internal*)obj);", eventInfo.Name, classTypeNameInternal).AppendLine(); + contents.AppendFormat(" f.Bind<{1}Internal, &{1}Internal::{0}_ManagedWrapper>(({1}Internal*)__obj);", eventInfo.Name, classTypeNameInternal).AppendLine(); contents.Append(" if (bind)").AppendLine(); contents.AppendFormat(" {0}{1}.Bind(f);", bindPrefix, eventInfo.Name).AppendLine(); contents.Append(" else").AppendLine(); @@ -1890,7 +1890,7 @@ namespace Flax.Build.Bindings // Scripting event wrapper binding method (binds/unbinds generic wrapper to C++ delegate) contents.AppendFormat(" static void {0}_Bind(", eventInfo.Name); - contents.AppendFormat("{0}* obj, void* instance, bool bind)", classTypeNameNative).AppendLine(); + contents.AppendFormat("{0}* __obj, void* instance, bool bind)", classTypeNameNative).AppendLine(); contents.Append(" {").AppendLine(); contents.Append(" Function();"); - contents.AppendLine(" wrapper->Object = obj;"); + contents.AppendLine(" wrapper->Object = __obj;"); contents.AppendLine(" return wrapper;"); contents.AppendLine(" }");