Add double-reference support for scripting function parameters to move value
This commit is contained in:
@@ -19,7 +19,7 @@ namespace Flax.Build.Bindings
|
||||
partial class BindingsGenerator
|
||||
{
|
||||
private static readonly Dictionary<string, Type> TypeCache = new Dictionary<string, Type>();
|
||||
private const int CacheVersion = 20;
|
||||
private const int CacheVersion = 21;
|
||||
|
||||
internal static void Write(BinaryWriter writer, string e)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user