diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cache.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cache.cs index 900d04e95..079a5839f 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cache.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cache.cs @@ -19,7 +19,7 @@ namespace Flax.Build.Bindings partial class BindingsGenerator { private static readonly Dictionary TypeCache = new Dictionary(); - private const int CacheVersion = 20; + private const int CacheVersion = 21; internal static void Write(BinaryWriter writer, string e) { diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index 0acab326a..e0fc42c4b 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -1241,6 +1241,11 @@ namespace Flax.Build.Bindings callParams += parameterInfo.Name; callParams += "Temp"; } + // Instruct for more optoimized value move operation + else if (parameterInfo.Type.IsMoveRef) + { + callParams += $"MoveTemp({param})"; + } else { callParams += param; diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs index e187724af..7c7a3e4cb 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs @@ -266,10 +266,12 @@ namespace Flax.Build.Bindings // Reference `&` character else if (token.Type == TokenType.And) { - if (type.IsRef) - type.Type += '&'; - else + if (!type.IsRef) type.IsRef = true; + else if (!type.IsMoveRef) + type.IsMoveRef = true; + else + type.Type += '&'; } // Namespace else if (token.Type == TokenType.Colon) diff --git a/Source/Tools/Flax.Build/Bindings/TypeInfo.cs b/Source/Tools/Flax.Build/Bindings/TypeInfo.cs index df47c85e4..e3bbfb6a1 100644 --- a/Source/Tools/Flax.Build/Bindings/TypeInfo.cs +++ b/Source/Tools/Flax.Build/Bindings/TypeInfo.cs @@ -16,6 +16,7 @@ namespace Flax.Build.Bindings public string Type; public bool IsConst; public bool IsRef; + public bool IsMoveRef; public bool IsPtr; public bool IsArray; public bool IsBitField; @@ -56,6 +57,7 @@ namespace Flax.Build.Bindings Type = other.Type; IsConst = other.IsConst; IsRef = other.IsRef; + IsMoveRef = other.IsMoveRef; IsPtr = other.IsPtr; IsArray = other.IsArray; IsBitField = other.IsBitField; @@ -122,6 +124,7 @@ namespace Flax.Build.Bindings // TODO: pack as flags writer.Write(IsConst); writer.Write(IsRef); + writer.Write(IsMoveRef); writer.Write(IsPtr); writer.Write(IsArray); writer.Write(IsBitField); @@ -136,6 +139,7 @@ namespace Flax.Build.Bindings // TODO: convert into flags IsConst = reader.ReadBoolean(); IsRef = reader.ReadBoolean(); + IsMoveRef = reader.ReadBoolean(); IsPtr = reader.ReadBoolean(); IsArray = reader.ReadBoolean(); IsBitField = reader.ReadBoolean(); @@ -197,6 +201,8 @@ namespace Flax.Build.Bindings sb.Append('*'); if (IsRef) sb.Append('&'); + if (IsMoveRef) + sb.Append('&'); return sb.ToString(); } @@ -217,6 +223,7 @@ namespace Flax.Build.Bindings return string.Equals(Type, other.Type) && IsConst == other.IsConst && IsRef == other.IsRef && + IsMoveRef == other.IsMoveRef && IsPtr == other.IsPtr && IsArray == other.IsArray && IsBitField == other.IsBitField && @@ -237,6 +244,7 @@ namespace Flax.Build.Bindings var hashCode = (Type != null ? Type.GetHashCode() : 0); hashCode = (hashCode * 397) ^ IsConst.GetHashCode(); hashCode = (hashCode * 397) ^ IsRef.GetHashCode(); + hashCode = (hashCode * 397) ^ IsMoveRef.GetHashCode(); hashCode = (hashCode * 397) ^ IsPtr.GetHashCode(); hashCode = (hashCode * 397) ^ IsArray.GetHashCode(); hashCode = (hashCode * 397) ^ IsBitField.GetHashCode();