1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-28 09:54:47 +00:00

Move VarargArguments factory to VarargArguments itself

This commit is contained in:
Jonathan Coates 2022-05-03 15:55:26 +01:00
parent e2189535b8
commit 7ad6132494
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
4 changed files with 10 additions and 10 deletions

View File

@ -41,7 +41,7 @@ class BasicFunction extends VarArgFunction
@Override
public Varargs invoke( LuaState luaState, Varargs args ) throws LuaError
{
IArguments arguments = CobaltLuaMachine.toArguments( args );
IArguments arguments = VarargArguments.of( args );
MethodResult results;
try
{

View File

@ -424,11 +424,6 @@ public class CobaltLuaMachine implements ILuaMachine
return objects;
}
static IArguments toArguments( Varargs values )
{
return values == Constants.NONE ? VarargArguments.EMPTY : new VarargArguments( values );
}
/**
* A {@link DebugHandler} which observes the {@link TimeoutState} and responds accordingly.
*/

View File

@ -51,7 +51,7 @@ class ResultInterpreterFunction extends ResumableVarArgFunction<ResultInterprete
@Override
protected Varargs invoke( LuaState state, DebugFrame debugFrame, Varargs args ) throws LuaError, UnwindThrowable
{
IArguments arguments = CobaltLuaMachine.toArguments( args );
IArguments arguments = VarargArguments.of( args );
MethodResult results;
try
{

View File

@ -15,19 +15,24 @@ import javax.annotation.Nullable;
import java.nio.ByteBuffer;
import java.util.Optional;
class VarargArguments implements IArguments
final class VarargArguments implements IArguments
{
static final IArguments EMPTY = new VarargArguments( Constants.NONE );
private static final IArguments EMPTY = new VarargArguments( Constants.NONE );
boolean released;
private final Varargs varargs;
private Object[] cache;
VarargArguments( Varargs varargs )
private VarargArguments( Varargs varargs )
{
this.varargs = varargs;
}
static IArguments of( Varargs values )
{
return values == Constants.NONE ? EMPTY : new VarargArguments( values );
}
@Override
public int count()
{