mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-15 04:30:29 +00:00
Deprecate IArguments.releaseImmediate
This is only ever defined (and called) within the ILuaMachine-specific code. Not sure why I ever made this public.
This commit is contained in:
parent
d631111610
commit
2639b84eb2
@ -188,8 +188,8 @@ public interface IArguments
|
|||||||
*
|
*
|
||||||
* Classes implementing this interface may choose to implement a more optimised version which does not copy the
|
* Classes implementing this interface may choose to implement a more optimised version which does not copy the
|
||||||
* table, instead returning a wrapper version, making it more efficient. However, the caller must guarantee that
|
* table, instead returning a wrapper version, making it more efficient. However, the caller must guarantee that
|
||||||
* they do not access off the computer thread (and so should not be used with main-thread functions) or once the
|
* they do not access the table the computer thread (and so should not be used with main-thread functions) or once
|
||||||
* function call has finished (for instance, in callbacks).
|
* the initial call has finished (for instance, in a callback to {@link MethodResult#pullEvent}).
|
||||||
*
|
*
|
||||||
* @param index The argument number.
|
* @param index The argument number.
|
||||||
* @return The argument's value.
|
* @return The argument's value.
|
||||||
@ -448,7 +448,10 @@ public interface IArguments
|
|||||||
* This is called when the current function finishes, before any main thread tasks have run.
|
* This is called when the current function finishes, before any main thread tasks have run.
|
||||||
*
|
*
|
||||||
* Called when the current function returns, and so some values are no longer guaranteed to be safe to access.
|
* Called when the current function returns, and so some values are no longer guaranteed to be safe to access.
|
||||||
|
*
|
||||||
|
* @deprecated This method was an internal implementation detail and is no longer used.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
default void releaseImmediate()
|
default void releaseImmediate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
package dan200.computercraft.api.lua;
|
package dan200.computercraft.api.lua;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of {@link IArguments} which wraps an array of {@link Object}.
|
* An implementation of {@link IArguments} which wraps an array of {@link Object}.
|
||||||
@ -19,7 +17,6 @@ public final class ObjectArguments implements IArguments
|
|||||||
{
|
{
|
||||||
private static final IArguments EMPTY = new ObjectArguments();
|
private static final IArguments EMPTY = new ObjectArguments();
|
||||||
|
|
||||||
private boolean released = false;
|
|
||||||
private final List<Object> args;
|
private final List<Object> args;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -67,34 +64,4 @@ public final class ObjectArguments implements IArguments
|
|||||||
{
|
{
|
||||||
return args.toArray();
|
return args.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public LuaTable<?, ?> getTableUnsafe( int index ) throws LuaException
|
|
||||||
{
|
|
||||||
if( released )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( "Cannot use getTableUnsafe after IArguments has been released" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return IArguments.super.getTableUnsafe( index );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public Optional<LuaTable<?, ?>> optTableUnsafe( int index ) throws LuaException
|
|
||||||
{
|
|
||||||
if( released )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( "Cannot use optTableUnsafe after IArguments has been released" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return IArguments.super.optTableUnsafe( index );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void releaseImmediate()
|
|
||||||
{
|
|
||||||
released = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
package dan200.computercraft.core.lua;
|
package dan200.computercraft.core.lua;
|
||||||
|
|
||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.ComputerCraft;
|
||||||
import dan200.computercraft.api.lua.IArguments;
|
|
||||||
import dan200.computercraft.api.lua.ILuaContext;
|
import dan200.computercraft.api.lua.ILuaContext;
|
||||||
import dan200.computercraft.api.lua.LuaException;
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
import dan200.computercraft.api.lua.MethodResult;
|
import dan200.computercraft.api.lua.MethodResult;
|
||||||
@ -41,7 +40,7 @@ class BasicFunction extends VarArgFunction
|
|||||||
@Override
|
@Override
|
||||||
public Varargs invoke( LuaState luaState, Varargs args ) throws LuaError
|
public Varargs invoke( LuaState luaState, Varargs args ) throws LuaError
|
||||||
{
|
{
|
||||||
IArguments arguments = VarargArguments.of( args );
|
VarargArguments arguments = VarargArguments.of( args );
|
||||||
MethodResult results;
|
MethodResult results;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -61,7 +60,7 @@ class BasicFunction extends VarArgFunction
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
arguments.releaseImmediate();
|
arguments.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( results.getCallback() != null )
|
if( results.getCallback() != null )
|
||||||
|
@ -51,7 +51,7 @@ class ResultInterpreterFunction extends ResumableVarArgFunction<ResultInterprete
|
|||||||
@Override
|
@Override
|
||||||
protected Varargs invoke( LuaState state, DebugFrame debugFrame, Varargs args ) throws LuaError, UnwindThrowable
|
protected Varargs invoke( LuaState state, DebugFrame debugFrame, Varargs args ) throws LuaError, UnwindThrowable
|
||||||
{
|
{
|
||||||
IArguments arguments = VarargArguments.of( args );
|
VarargArguments arguments = VarargArguments.of( args );
|
||||||
MethodResult results;
|
MethodResult results;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -71,7 +71,7 @@ class ResultInterpreterFunction extends ResumableVarArgFunction<ResultInterprete
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
arguments.releaseImmediate();
|
arguments.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
ILuaCallback callback = results.getCallback();
|
ILuaCallback callback = results.getCallback();
|
||||||
|
@ -133,7 +133,7 @@ class TableImpl implements dan200.computercraft.api.lua.LuaTable<Object, Object>
|
|||||||
|
|
||||||
private void checkValid()
|
private void checkValid()
|
||||||
{
|
{
|
||||||
if( arguments.released )
|
if( arguments.closed )
|
||||||
{
|
{
|
||||||
throw new IllegalStateException( "Cannot use LuaTable after IArguments has been released" );
|
throw new IllegalStateException( "Cannot use LuaTable after IArguments has been released" );
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ import java.util.Optional;
|
|||||||
|
|
||||||
final class VarargArguments implements IArguments
|
final class VarargArguments implements IArguments
|
||||||
{
|
{
|
||||||
private static final IArguments EMPTY = new VarargArguments( Constants.NONE );
|
private static final VarargArguments EMPTY = new VarargArguments( Constants.NONE );
|
||||||
|
|
||||||
boolean released;
|
boolean closed;
|
||||||
private final Varargs varargs;
|
private final Varargs varargs;
|
||||||
private Object[] cache;
|
private Object[] cache;
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ final class VarargArguments implements IArguments
|
|||||||
this.varargs = varargs;
|
this.varargs = varargs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IArguments of( Varargs values )
|
static VarargArguments of( Varargs values )
|
||||||
{
|
{
|
||||||
return values == Constants.NONE ? EMPTY : new VarargArguments( values );
|
return values == Constants.NONE ? EMPTY : new VarargArguments( values );
|
||||||
}
|
}
|
||||||
@ -109,9 +109,9 @@ final class VarargArguments implements IArguments
|
|||||||
@Override
|
@Override
|
||||||
public dan200.computercraft.api.lua.LuaTable<?, ?> getTableUnsafe( int index ) throws LuaException
|
public dan200.computercraft.api.lua.LuaTable<?, ?> getTableUnsafe( int index ) throws LuaException
|
||||||
{
|
{
|
||||||
if( released )
|
if( closed )
|
||||||
{
|
{
|
||||||
throw new IllegalStateException( "Cannot use getTableUnsafe after IArguments has been released" );
|
throw new IllegalStateException( "Cannot use getTableUnsafe after IArguments has been closed." );
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaValue value = varargs.arg( index + 1 );
|
LuaValue value = varargs.arg( index + 1 );
|
||||||
@ -123,9 +123,9 @@ final class VarargArguments implements IArguments
|
|||||||
@Override
|
@Override
|
||||||
public Optional<dan200.computercraft.api.lua.LuaTable<?, ?>> optTableUnsafe( int index ) throws LuaException
|
public Optional<dan200.computercraft.api.lua.LuaTable<?, ?>> optTableUnsafe( int index ) throws LuaException
|
||||||
{
|
{
|
||||||
if( released )
|
if( closed )
|
||||||
{
|
{
|
||||||
throw new IllegalStateException( "Cannot use optTableUnsafe after IArguments has been released" );
|
throw new IllegalStateException( "Cannot use optTableUnsafe after IArguments has been closed." );
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaValue value = varargs.arg( index + 1 );
|
LuaValue value = varargs.arg( index + 1 );
|
||||||
@ -134,9 +134,8 @@ final class VarargArguments implements IArguments
|
|||||||
return Optional.of( new TableImpl( this, (LuaTable) value ) );
|
return Optional.of( new TableImpl( this, (LuaTable) value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void close()
|
||||||
public void releaseImmediate()
|
|
||||||
{
|
{
|
||||||
released = true;
|
closed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user