Skip to content

Commit

Permalink
Fix parameter checking in functions (copy/paste error)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Feb 7, 2022
1 parent 1bf93e2 commit 3f3ace5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions EOBot/Interpreter/Variables/AsyncFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public AsyncFunction(string functionName, Func<TParam1, TParam2, TParam3, Task<T

public Task<T> CallAsync(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 3)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

return _referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2]);
Expand All @@ -102,7 +102,7 @@ public AsyncFunction(string functionName, Func<TParam1, TParam2, TParam3, TParam

public Task<T> CallAsync(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 4)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

return _referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2], (TParam4)(dynamic)parameters[3]);
Expand All @@ -123,7 +123,7 @@ public AsyncFunction(string functionName, Func<TParam1, TParam2, TParam3, TParam

public Task<T> CallAsync(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 5)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

return _referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2], (TParam4)(dynamic)parameters[3], (TParam5)(dynamic)parameters[4]);
Expand Down
6 changes: 3 additions & 3 deletions EOBot/Interpreter/Variables/AsyncVoidFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public AsyncVoidFunction(string functionName, Func<TParam1, TParam2, TParam3, Ta

public Task CallAsync(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 3)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

return _referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2]);
Expand All @@ -102,7 +102,7 @@ public AsyncVoidFunction(string functionName, Func<TParam1, TParam2, TParam3, TP

public Task CallAsync(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 4)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

return _referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2], (TParam4)(dynamic)parameters[3]);
Expand All @@ -123,7 +123,7 @@ public AsyncVoidFunction(string functionName, Func<TParam1, TParam2, TParam3, TP

public Task CallAsync(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 5)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

return _referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2], (TParam4)(dynamic)parameters[3], (TParam5)(dynamic)parameters[4]);
Expand Down
6 changes: 3 additions & 3 deletions EOBot/Interpreter/Variables/Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Function(string functionName, Func<TParam1, TParam2, TParam3, T> referenc

public T Call(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 3)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

return _referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2]);
Expand All @@ -101,7 +101,7 @@ public Function(string functionName, Func<TParam1, TParam2, TParam3, TParam4, T>

public T Call(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 4)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

return _referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2], (TParam4)(dynamic)parameters[3]);
Expand All @@ -122,7 +122,7 @@ public Function(string functionName, Func<TParam1, TParam2, TParam3, TParam4, TP

public T Call(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 5)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

return _referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2], (TParam4)(dynamic)parameters[3], (TParam5)(dynamic)parameters[4]);
Expand Down
6 changes: 3 additions & 3 deletions EOBot/Interpreter/Variables/VoidFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public VoidFunction(string functionName, Action<TParam1, TParam2, TParam3> refer

public void Call(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 3)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

_referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2]);
Expand All @@ -101,7 +101,7 @@ public VoidFunction(string functionName, Action<TParam1, TParam2, TParam3, TPara

public void Call(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 4)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

_referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2], (TParam4)(dynamic)parameters[3]);
Expand All @@ -122,7 +122,7 @@ public VoidFunction(string functionName, Action<TParam1, TParam2, TParam3, TPara

public void Call(params IIdentifiable[] parameters)
{
if (parameters.Length != 0)
if (parameters.Length != 5)
throw new ArgumentException($"Calling function '{StringValue}' with wrong number of parameters");

_referenceFunc((TParam1)(dynamic)parameters[0], (TParam2)(dynamic)parameters[1], (TParam3)(dynamic)parameters[2], (TParam4)(dynamic)parameters[3], (TParam5)(dynamic)parameters[4]);
Expand Down

0 comments on commit 3f3ace5

Please sign in to comment.