Skip to content

Commit 7738626

Browse files
committed
Merge pull request #107800 from Joy-less/add-ROS-overload-for-Callable.Call
Add `ReadOnlySpan<Variant>` overload for `Callable.Call`
2 parents 25981be + d956bcf commit 7738626

File tree

1 file changed

+14
-2
lines changed
  • modules/mono/glue/GodotSharp/GodotSharp/Core

1 file changed

+14
-2
lines changed

modules/mono/glue/GodotSharp/GodotSharp/Core/Callable.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,19 @@ private unsafe Callable(Delegate @delegate,
7979

8080
private const int VarArgsSpanThreshold = 10;
8181

82+
/// <inheritdoc cref="Call(ReadOnlySpan{Variant})"/>
83+
public Variant Call(params Variant[] args)
84+
{
85+
return Call(args.AsSpan());
86+
}
87+
8288
/// <summary>
8389
/// Calls the method represented by this <see cref="Callable"/>.
8490
/// Arguments can be passed and should match the method's signature.
8591
/// </summary>
8692
/// <param name="args">Arguments that will be passed to the method call.</param>
8793
/// <returns>The value returned by the method.</returns>
88-
public unsafe Variant Call(params Variant[] args)
94+
public unsafe Variant Call(scoped ReadOnlySpan<Variant> args)
8995
{
9096
using godot_callable callable = Marshaling.ConvertCallableToNative(this);
9197

@@ -115,12 +121,18 @@ public unsafe Variant Call(params Variant[] args)
115121
}
116122
}
117123

124+
/// <inheritdoc cref="CallDeferred(ReadOnlySpan{Variant})"/>
125+
public void CallDeferred(params Variant[] args)
126+
{
127+
CallDeferred(args.AsSpan());
128+
}
129+
118130
/// <summary>
119131
/// Calls the method represented by this <see cref="Callable"/> in deferred mode, i.e. during the idle frame.
120132
/// Arguments can be passed and should match the method's signature.
121133
/// </summary>
122134
/// <param name="args">Arguments that will be passed to the method call.</param>
123-
public unsafe void CallDeferred(params Variant[] args)
135+
public unsafe void CallDeferred(scoped ReadOnlySpan<Variant> args)
124136
{
125137
using godot_callable callable = Marshaling.ConvertCallableToNative(this);
126138

0 commit comments

Comments
 (0)