Enum Class CSTInjectionPoint

java.lang.Object
java.lang.Enum<CSTInjectionPoint>
io.github.douira.glsl_transformer.cst.transform.CSTInjectionPoint
All Implemented Interfaces:
Serializable, Comparable<CSTInjectionPoint>, Constable

public enum CSTInjectionPoint extends Enum<CSTInjectionPoint>
Shader code is expected to be roughly structured as follows: version, extensions, other directives (#define, #pragma etc.), declarations (layout etc.), functions (void main etc.). These injection points can be used to insert nodes into the translation unit's child list. An injection will happen before the syntax feature it describes and any that follow it in the list. This enum is used to specify where the injection methods in TransformationPhase should insert things.
Implementation Note:
AFTER versions of these points would be the same as the next BEFORE point in the list.
  • Enum Constant Details

    • BEFORE_VERSION

      public static final CSTInjectionPoint BEFORE_VERSION
      Before the #version statement (and all other syntax features by necessity)
    • BEFORE_EXTENSIONS

      public static final CSTInjectionPoint BEFORE_EXTENSIONS
      Before the #extension statement, before other directives, declarations and function definitions
    • BEFORE_DIRECTIVES

      public static final CSTInjectionPoint BEFORE_DIRECTIVES
      Before non-extension parsed #-directives such as #pragma, before declarations and function definitions. (after extension statements if they aren't mixed with other directives and directly follow the #version)
    • BEFORE_DECLARATIONS

      public static final CSTInjectionPoint BEFORE_DECLARATIONS
      Before declarations like layout and struct, before function definitions
    • BEFORE_FUNCTIONS

      public static final CSTInjectionPoint BEFORE_FUNCTIONS
      Before function definitions
    • END

      public static final CSTInjectionPoint END
      Before the end of the file, basically the last possible location
  • Method Details

    • values

      public static CSTInjectionPoint[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CSTInjectionPoint valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • checkChildRelevant

      protected boolean checkChildRelevant(Class<?> childClass)
      Checks if the given class of the child of an external declaration makes the external declaration one that should be injected before. When this method returns true, the injection happens right before the external declaration that has the child that was found to be relevant.
      Parameters:
      childClass - The class of the only child node of the external declaration being tested for being a node before which the injection has to happen
      Returns:
      true if the class means the injection should happen before this external declaration according to the implementing injection location