Class WrapIdentifier<T>

java.lang.Object
io.github.douira.glsl_transformer.transform.Transformation<T>
io.github.douira.glsl_transformer.core.WrapIdentifier<T>

public class WrapIdentifier<T> extends Transformation<T>
The wrap identifier transformation wraps the usage of a certain identifier with new code by replacing its usage with a new expression and inserting code that takes care of handling the conversion from the new to the old value. It also checks that the wrapped value isn't already present in the code.
  • Constructor Details

    • WrapIdentifier

      public WrapIdentifier(String wrapTarget, String wrapResult, HandlerTarget<T> replaceTarget, RunPhase<T> wrappingInjector)
      Creates a new wrap identifier transformation.
      Parameters:
      wrapTarget - The identifier to replace
      wrapResult - The identifier that will be used to replace it
      replaceTarget - The target that is used as a replacement
      wrappingInjector - A transformation phase that does the additional code injection
  • Method Details

    • fromExpression

      public static <T> WrapIdentifier<T> fromExpression(String wrapTarget, String wrapResult, String wrapExpression, RunPhase<T> wrappingInjector)
      Creates a new wrap identifier transformation that uses a parsed replace target that replaces identifiers with an expression. (which may also just be an identifier)
      Type Parameters:
      T - The job parameter type
      Parameters:
      wrapTarget - The identifier to replace
      wrapResult - The identifier that will be used to replace it
      wrapExpression - The expression to insert instead of the wrapTarget
      wrappingInjector - A transformation phase that does the additional code injection
      Returns:
      The wrap identifier transformation with the given parameters
    • withExternalDeclaration

      public static <T> WrapIdentifier<T> withExternalDeclaration(String wrapTarget, String wrapResult, String wrapExpression, TransformationPhase.InjectionPoint location, String injectedCode)
      Creates a new wrap identifier transformation that inserts a parsed expression as a replacement and inserts a new external declaration.
      Type Parameters:
      T - The job parameter type
      Parameters:
      wrapTarget - The identifier to replace
      wrapResult - The identifier that will be used to replace it
      wrapExpression - The expression to insert instead of the wrapTarget
      location - The injection location for the new code
      injectedCode - The code to parse and inject as an external declaration at the given location
      Returns:
      The wrap identifier transformation with the given parameters
      See Also: