Pass const ref parameters as in parameters in C# bindings
This commit is contained in:
@@ -525,7 +525,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
var restored = actor.AddScript(removed.PrefabObject.GetType());
|
var restored = actor.AddScript(removed.PrefabObject.GetType());
|
||||||
var prefabId = actor.PrefabID;
|
var prefabId = actor.PrefabID;
|
||||||
var prefabObjectId = restored.PrefabObjectID;
|
var prefabObjectId = restored.PrefabObjectID;
|
||||||
Script.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), ref prefabId, ref prefabObjectId);
|
Script.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), prefabId, prefabObjectId);
|
||||||
string data = JsonSerializer.Serialize(removed.PrefabObject);
|
string data = JsonSerializer.Serialize(removed.PrefabObject);
|
||||||
JsonSerializer.Deserialize(restored, data);
|
JsonSerializer.Deserialize(restored, data);
|
||||||
|
|
||||||
@@ -547,7 +547,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
string data = JsonSerializer.Serialize(removedActor.PrefabObject);
|
string data = JsonSerializer.Serialize(removedActor.PrefabObject);
|
||||||
JsonSerializer.Deserialize(restored, data);
|
JsonSerializer.Deserialize(restored, data);
|
||||||
Presenter.Owner.SceneContext.Spawn(restored, parentActor, removedActor.OrderInParent);
|
Presenter.Owner.SceneContext.Spawn(restored, parentActor, removedActor.OrderInParent);
|
||||||
Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), ref prefabId, ref prefabObjectId);
|
Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), prefabId, prefabObjectId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Camera.Internal_IntersectsItselfEditor(FlaxEngine.Object.GetUnmanagedPtr(_actor), ref ray.Ray, out distance);
|
return Camera.Internal_IntersectsItselfEditor(FlaxEngine.Object.GetUnmanagedPtr(_actor), ray.Ray, out distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ namespace FlaxEditor.Actions
|
|||||||
script.OrderInParent = _orderInParent;
|
script.OrderInParent = _orderInParent;
|
||||||
_orderInParent = script.OrderInParent; // Ensure order is correct for script that want to use it later
|
_orderInParent = script.OrderInParent; // Ensure order is correct for script that want to use it later
|
||||||
if (_prefabObjectId != Guid.Empty)
|
if (_prefabObjectId != Guid.Empty)
|
||||||
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(script), ref _prefabId, ref _prefabObjectId);
|
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(script), _prefabId, _prefabObjectId);
|
||||||
Editor.Instance.Scene.MarkSceneEdited(parentActor.Scene);
|
Editor.Instance.Scene.MarkSceneEdited(parentActor.Scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ namespace FlaxEditor.Actions
|
|||||||
var item = items[i];
|
var item = items[i];
|
||||||
var obj = Object.Find<Object>(ref item.ID);
|
var obj = Object.Find<Object>(ref item.ID);
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), ref item.PrefabID, ref item.PrefabObjectID);
|
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), item.PrefabID, item.PrefabObjectID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ namespace FlaxEditor.Actions
|
|||||||
Guid prefabId = _prefabIds[i];
|
Guid prefabId = _prefabIds[i];
|
||||||
if (prefabId != Guid.Empty)
|
if (prefabId != Guid.Empty)
|
||||||
{
|
{
|
||||||
Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(actors[i]), ref prefabId, ref _prefabObjectIds[i]);
|
Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(actors[i]), prefabId, _prefabObjectIds[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ namespace FlaxEditor.Actions
|
|||||||
{
|
{
|
||||||
var obj = Object.Find<SceneObject>(ref _idsForPrefab[i]);
|
var obj = Object.Find<SceneObject>(ref _idsForPrefab[i]);
|
||||||
if (obj != null && _prefabIds[i] != Guid.Empty)
|
if (obj != null && _prefabIds[i] != Guid.Empty)
|
||||||
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), ref _prefabIds[i], ref _prefabObjectIds[i]);
|
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), _prefabIds[i], _prefabObjectIds[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace FlaxEngine
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
Quaternion.Euler(ref value, out var orientation);
|
Quaternion.Euler(ref value, out var orientation);
|
||||||
Internal_SetOrientation(__unmanagedPtr, ref orientation);
|
Internal_SetOrientation(__unmanagedPtr, orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ namespace FlaxEngine
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
Quaternion.Euler(ref value, out var orientation);
|
Quaternion.Euler(ref value, out var orientation);
|
||||||
Internal_SetLocalOrientation(__unmanagedPtr, ref orientation);
|
Internal_SetLocalOrientation(__unmanagedPtr, orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace FlaxEngine
|
|||||||
/// <param name="transform">The transformation to apply.</param>
|
/// <param name="transform">The transformation to apply.</param>
|
||||||
public static void PushTransform(Matrix3x3 transform)
|
public static void PushTransform(Matrix3x3 transform)
|
||||||
{
|
{
|
||||||
Internal_PushTransform(ref transform);
|
Internal_PushTransform(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -21,7 +21,7 @@ namespace FlaxEngine
|
|||||||
/// <param name="clipRect">The axis aligned clipping mask rectangle.</param>
|
/// <param name="clipRect">The axis aligned clipping mask rectangle.</param>
|
||||||
public static void PushClip(Rectangle clipRect)
|
public static void PushClip(Rectangle clipRect)
|
||||||
{
|
{
|
||||||
Internal_PushClip(ref clipRect);
|
Internal_PushClip(clipRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -32,7 +32,7 @@ namespace FlaxEngine
|
|||||||
public static void DrawTexture(GPUTextureView rt, Rectangle rect)
|
public static void DrawTexture(GPUTextureView rt, Rectangle rect)
|
||||||
{
|
{
|
||||||
var color = Color.White;
|
var color = Color.White;
|
||||||
Internal_DrawTexture(FlaxEngine.Object.GetUnmanagedPtr(rt), ref rect, ref color);
|
Internal_DrawTexture(FlaxEngine.Object.GetUnmanagedPtr(rt), rect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -43,7 +43,7 @@ namespace FlaxEngine
|
|||||||
public static void DrawTexture(GPUTexture t, Rectangle rect)
|
public static void DrawTexture(GPUTexture t, Rectangle rect)
|
||||||
{
|
{
|
||||||
var color = Color.White;
|
var color = Color.White;
|
||||||
Internal_DrawTexture1(FlaxEngine.Object.GetUnmanagedPtr(t), ref rect, ref color);
|
Internal_DrawTexture1(FlaxEngine.Object.GetUnmanagedPtr(t), rect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -54,7 +54,7 @@ namespace FlaxEngine
|
|||||||
public static void DrawTexture(TextureBase t, Rectangle rect)
|
public static void DrawTexture(TextureBase t, Rectangle rect)
|
||||||
{
|
{
|
||||||
var color = Color.White;
|
var color = Color.White;
|
||||||
Internal_DrawTexture2(FlaxEngine.Object.GetUnmanagedPtr(t), ref rect, ref color);
|
Internal_DrawTexture2(FlaxEngine.Object.GetUnmanagedPtr(t), rect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -75,7 +75,7 @@ namespace FlaxEngine
|
|||||||
public static void DrawTexturePoint(GPUTexture t, Rectangle rect)
|
public static void DrawTexturePoint(GPUTexture t, Rectangle rect)
|
||||||
{
|
{
|
||||||
var color = Color.White;
|
var color = Color.White;
|
||||||
Internal_DrawTexturePoint(FlaxEngine.Object.GetUnmanagedPtr(t), ref rect, ref color);
|
Internal_DrawTexturePoint(FlaxEngine.Object.GetUnmanagedPtr(t), rect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -96,7 +96,7 @@ namespace FlaxEngine
|
|||||||
public static void DrawMaterial(MaterialBase material, Rectangle rect)
|
public static void DrawMaterial(MaterialBase material, Rectangle rect)
|
||||||
{
|
{
|
||||||
var color = Color.White;
|
var color = Color.White;
|
||||||
Internal_DrawMaterial(FlaxEngine.Object.GetUnmanagedPtr(material), ref rect, ref color);
|
Internal_DrawMaterial(FlaxEngine.Object.GetUnmanagedPtr(material), rect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Flax.Build.Bindings
|
|||||||
partial class BindingsGenerator
|
partial class BindingsGenerator
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, Type> TypeCache = new Dictionary<string, Type>();
|
private static readonly Dictionary<string, Type> TypeCache = new Dictionary<string, Type>();
|
||||||
private const int CacheVersion = 23;
|
private const int CacheVersion = 24;
|
||||||
|
|
||||||
internal static void Write(BinaryWriter writer, string e)
|
internal static void Write(BinaryWriter writer, string e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Flax.Build.Bindings
|
namespace Flax.Build.Bindings
|
||||||
{
|
{
|
||||||
@@ -1041,7 +1042,12 @@ namespace Flax.Build.Bindings
|
|||||||
if (isGetter)
|
if (isGetter)
|
||||||
propertyInfo.Getter = functionInfo;
|
propertyInfo.Getter = functionInfo;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
propertyInfo.Setter = functionInfo;
|
propertyInfo.Setter = functionInfo;
|
||||||
|
|
||||||
|
// Setter value parameter should always be const, forces bindings to pass value as "in" instead of "ref"
|
||||||
|
CollectionsMarshal.AsSpan(functionInfo.Parameters)[0].IsConst = true;
|
||||||
|
}
|
||||||
propertyInfo.DeprecatedMessage = functionInfo.DeprecatedMessage;
|
propertyInfo.DeprecatedMessage = functionInfo.DeprecatedMessage;
|
||||||
propertyInfo.IsHidden |= functionInfo.IsHidden;
|
propertyInfo.IsHidden |= functionInfo.IsHidden;
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ namespace Flax.Build.Bindings
|
|||||||
{
|
{
|
||||||
Name = "value",
|
Name = "value",
|
||||||
Type = fieldInfo.Type,
|
Type = fieldInfo.Type,
|
||||||
|
IsConst = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
IsVirtual = false,
|
IsVirtual = false,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace Flax.Build.Bindings
|
|||||||
public string DefaultValue;
|
public string DefaultValue;
|
||||||
public string Attributes;
|
public string Attributes;
|
||||||
public bool IsRef;
|
public bool IsRef;
|
||||||
|
public bool IsConst;
|
||||||
public bool IsOut;
|
public bool IsOut;
|
||||||
public bool IsThis;
|
public bool IsThis;
|
||||||
public bool IsParams;
|
public bool IsParams;
|
||||||
@@ -36,6 +37,7 @@ namespace Flax.Build.Bindings
|
|||||||
BindingsGenerator.Write(writer, Attributes);
|
BindingsGenerator.Write(writer, Attributes);
|
||||||
// TODO: convert into flags
|
// TODO: convert into flags
|
||||||
writer.Write(IsRef);
|
writer.Write(IsRef);
|
||||||
|
writer.Write(IsConst);
|
||||||
writer.Write(IsOut);
|
writer.Write(IsOut);
|
||||||
writer.Write(IsThis);
|
writer.Write(IsThis);
|
||||||
writer.Write(IsParams);
|
writer.Write(IsParams);
|
||||||
@@ -49,6 +51,7 @@ namespace Flax.Build.Bindings
|
|||||||
Attributes = BindingsGenerator.Read(reader, Attributes);
|
Attributes = BindingsGenerator.Read(reader, Attributes);
|
||||||
// TODO: convert into flags
|
// TODO: convert into flags
|
||||||
IsRef = reader.ReadBoolean();
|
IsRef = reader.ReadBoolean();
|
||||||
|
IsConst = reader.ReadBoolean();
|
||||||
IsOut = reader.ReadBoolean();
|
IsOut = reader.ReadBoolean();
|
||||||
IsThis = reader.ReadBoolean();
|
IsThis = reader.ReadBoolean();
|
||||||
IsParams = reader.ReadBoolean();
|
IsParams = reader.ReadBoolean();
|
||||||
|
|||||||
Reference in New Issue
Block a user