Class ScriptInstanceFactory

java.lang.Object
com.blackrook.rookscript.ScriptInstanceFactory

public class ScriptInstanceFactory extends Object
Factory class for assembling script instances. This factory pools ScriptInstanceStacks, since creating and destroying them could be costly on the GC.
Author:
Matthew Tropiano
  • Field Details

  • Constructor Details

    • ScriptInstanceFactory

      public ScriptInstanceFactory(Script script, ScriptEnvironment environment)
      Creates a new instance factory, default depths.
      Parameters:
      script - the script to use for each instance.
      environment - the script environment to use for each instance.
      See Also:
    • ScriptInstanceFactory

      public ScriptInstanceFactory(Script script, int activationDepth, int stackDepth, ScriptEnvironment environment)
      Creates a new instance factory.
      Parameters:
      script - the script to use for each instance.
      activationDepth - the activation stack depth for new instances.
      stackDepth - the value stack depth for new instances.
      environment - the script environment to use for each instance.
    • ScriptInstanceFactory

      public ScriptInstanceFactory(Script script, int activationDepth, int stackDepth, ScriptEnvironment environment, int runawayLimit)
      Creates a new instance factory.
      Parameters:
      script - the script to use for each instance.
      activationDepth - the activation stack depth for new instances.
      stackDepth - the value stack depth for new instances.
      environment - the script environment to use for each instance.
      runawayLimit - the amount of commands to run before the endless loop protection triggers.
    • ScriptInstanceFactory

      public ScriptInstanceFactory(Script script, int activationDepth, int stackDepth, ScriptWaitHandler waitHandler, ScriptEnvironment environment)
      Creates a new instance factory.
      Parameters:
      script - the script to use for each instance.
      activationDepth - the activation stack depth for new instances.
      stackDepth - the value stack depth for new instances.
      waitHandler - the wait handler to use for each instance.
      environment - the script environment to use for each instance.
    • ScriptInstanceFactory

      public ScriptInstanceFactory(Script script, int activationDepth, int stackDepth, ScriptWaitHandler waitHandler, ScriptEnvironment environment, int runawayLimit)
      Creates a new instance factory.
      Parameters:
      script - the script to use for each instance.
      activationDepth - the activation stack depth for new instances.
      stackDepth - the value stack depth for new instances.
      waitHandler - the wait handler to use for each instance.
      environment - the script environment to use for each instance.
      runawayLimit - the amount of commands to run before the endless loop protection triggers.
  • Method Details

    • create

      public ScriptInstance create()
      Creates a new instance.
      Returns:
      a new instance with all of the associated resolvers and handlers attached to it.
    • create

      public ScriptInstance create(ScriptEnvironment environment)
      Creates a new instance.
      Parameters:
      environment - the script environment override.
      Returns:
      a new instance with all of the associated resolvers and handlers attached to it.
    • release

      public void release(ScriptInstance instance)
      Destroys an instance and releases pooled objects.
      Parameters:
      instance - the script instance.
    • getFreeStackCount

      public int getFreeStackCount()
      Gets how many stacks were created but not in use.
      Returns:
      the amount of created stacks.