Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Meta({
- @Do(
- // Possible values: Do.Type.{
- // REMOVE_STATEMENT, ADD_ENTITY, REMOVE_ENTITY, GENERATE_CLASS
- // }
- // Note that there is no task for manipulating subclasses because subclasses are not actually "sub"classes
- type = Do.Type.APPEND_STATEMENT,
- // These fields are (mostly) specific to Do.Type.APPEND
- target = @SelectEntity("#method;<staticInit>"), // <staticInit> is a special way to refer to it created by JMeta
- // All sequences contain entities
- statements = @Statements(
- source = @SelectEntity(
- value = "#field;/.*/;$type",
- target = Block.class,
- condition = "$type <: $block",
- arguments = {
- @Pair(name = "block", clazz = Block.class)
- }
- ),
- // Finalize refers to a @MetaStatement method in the current class. The method must recieve the results' type
- // from previous processing steps (field -> T, method -> MetaMethod)
- finalize = "addBlockStatement"
- )
- )
- })
- class CollectBlocksExample {
- static {} // For @SelectEntity("<staticInit>"), technically not needed because java compiler auto-generates them
- public static final List<Block> BLOCKS = new ArrayList<>();
- // Excludes this method in the final output
- // All usages of @MetaStatement require the method have `void` return type and
- @MetaStatement
- private static void addBlockStatement(Block block) {
- BLOCKS.add(block);
- }
- }
- @Meta({
- @Do(
- type = Do.Type.APPEND_ENTITY,
- source = @SelectEntity(value = "#field;/.*/;_", target = MixinClassExample_Source.class)
- ),
- @Do(
- type = Do.Type.APPEND_ENTITY,
- source = @SelectEntity(value = "#method;/.*/;_", target = MixinClassExample_Source.class)
- )
- })
- class MixinClassExample {
- public void setX(int x) { this.x = x; }
- public void setY(int y) { this.y = y; }
- }
- class MixinClassExample_Source {
- protected int x, y;
- protected int absX, absY;
- public setParent(MixinClassExample_Source parent) {
- this.absX = parent.absX + x;
- this.absY = parent.absY + y;
- }
- public getX() { return x; }
- public getY() { return y; }
- public getAbsX() { return absX; }
- public getAbsY() { return absY; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement