mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 05:33:00 +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:
		| @@ -188,8 +188,8 @@ public interface IArguments | ||||
|      * | ||||
|      * 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 | ||||
|      * they do not access off the computer thread (and so should not be used with main-thread functions) or once the | ||||
|      * function call has finished (for instance, in callbacks). | ||||
|      * they do not access the table the computer thread (and so should not be used with main-thread functions) or once | ||||
|      * the initial call has finished (for instance, in a callback to {@link MethodResult#pullEvent}). | ||||
|      * | ||||
|      * @param index The argument number. | ||||
|      * @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. | ||||
|      * | ||||
|      * 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() | ||||
|     { | ||||
|     } | ||||
|   | ||||
| @@ -5,12 +5,10 @@ | ||||
|  */ | ||||
| package dan200.computercraft.api.lua; | ||||
| 
 | ||||
| import javax.annotation.Nonnull; | ||||
| import javax.annotation.Nullable; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.Optional; | ||||
| 
 | ||||
| /** | ||||
|  * 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 boolean released = false; | ||||
|     private final List<Object> args; | ||||
| 
 | ||||
|     @Deprecated | ||||
| @@ -67,34 +64,4 @@ public final class ObjectArguments implements IArguments | ||||
|     { | ||||
|         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; | ||||
| 
 | ||||
| import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.api.lua.IArguments; | ||||
| import dan200.computercraft.api.lua.ILuaContext; | ||||
| import dan200.computercraft.api.lua.LuaException; | ||||
| import dan200.computercraft.api.lua.MethodResult; | ||||
| @@ -41,7 +40,7 @@ class BasicFunction extends VarArgFunction | ||||
|     @Override | ||||
|     public Varargs invoke( LuaState luaState, Varargs args ) throws LuaError | ||||
|     { | ||||
|         IArguments arguments = VarargArguments.of( args ); | ||||
|         VarargArguments arguments = VarargArguments.of( args ); | ||||
|         MethodResult results; | ||||
|         try | ||||
|         { | ||||
| @@ -61,7 +60,7 @@ class BasicFunction extends VarArgFunction | ||||
|         } | ||||
|         finally | ||||
|         { | ||||
|             arguments.releaseImmediate(); | ||||
|             arguments.close(); | ||||
|         } | ||||
| 
 | ||||
|         if( results.getCallback() != null ) | ||||
|   | ||||
| @@ -51,7 +51,7 @@ class ResultInterpreterFunction extends ResumableVarArgFunction<ResultInterprete | ||||
|     @Override | ||||
|     protected Varargs invoke( LuaState state, DebugFrame debugFrame, Varargs args ) throws LuaError, UnwindThrowable | ||||
|     { | ||||
|         IArguments arguments = VarargArguments.of( args ); | ||||
|         VarargArguments arguments = VarargArguments.of( args ); | ||||
|         MethodResult results; | ||||
|         try | ||||
|         { | ||||
| @@ -71,7 +71,7 @@ class ResultInterpreterFunction extends ResumableVarArgFunction<ResultInterprete | ||||
|         } | ||||
|         finally | ||||
|         { | ||||
|             arguments.releaseImmediate(); | ||||
|             arguments.close(); | ||||
|         } | ||||
| 
 | ||||
|         ILuaCallback callback = results.getCallback(); | ||||
|   | ||||
| @@ -133,7 +133,7 @@ class TableImpl implements dan200.computercraft.api.lua.LuaTable<Object, Object> | ||||
| 
 | ||||
|     private void checkValid() | ||||
|     { | ||||
|         if( arguments.released ) | ||||
|         if( arguments.closed ) | ||||
|         { | ||||
|             throw new IllegalStateException( "Cannot use LuaTable after IArguments has been released" ); | ||||
|         } | ||||
|   | ||||
| @@ -17,9 +17,9 @@ import java.util.Optional; | ||||
| 
 | ||||
| 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 Object[] cache; | ||||
| 
 | ||||
| @@ -28,7 +28,7 @@ final class VarargArguments implements IArguments | ||||
|         this.varargs = varargs; | ||||
|     } | ||||
| 
 | ||||
|     static IArguments of( Varargs values ) | ||||
|     static VarargArguments of( Varargs values ) | ||||
|     { | ||||
|         return values == Constants.NONE ? EMPTY : new VarargArguments( values ); | ||||
|     } | ||||
| @@ -109,9 +109,9 @@ final class VarargArguments implements IArguments | ||||
|     @Override | ||||
|     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 ); | ||||
| @@ -123,9 +123,9 @@ final class VarargArguments implements IArguments | ||||
|     @Override | ||||
|     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 ); | ||||
| @@ -134,9 +134,8 @@ final class VarargArguments implements IArguments | ||||
|         return Optional.of( new TableImpl( this, (LuaTable) value ) ); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void releaseImmediate() | ||||
|     public void close() | ||||
|     { | ||||
|         released = true; | ||||
|         closed = true; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates