From 8065caf0a22525ec5da3eddc8120b26c73557bb1 Mon Sep 17 00:00:00 2001 From: LlamaLad7 Date: Wed, 3 Jul 2024 17:43:56 +0100 Subject: [PATCH] New: Support `@WrapMethod`. (#132) --- .../mixin/common/data/Annotation.java | 1 + .../soft/SoftTargetMixinMethodVisitor.java | 3 ++ .../WrapMethodAnnotationVisitor.java | 32 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/main/java/net/fabricmc/tinyremapper/extension/mixin/soft/annotation/injection/WrapMethodAnnotationVisitor.java diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/common/data/Annotation.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/common/data/Annotation.java index e5a5930b..514809d7 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/common/data/Annotation.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/common/data/Annotation.java @@ -67,6 +67,7 @@ public final class Annotation { public static final String MIXIN_EXTRAS_MODIFY_EXPRESSION_VALUE = "Lcom/llamalad7/mixinextras/injector/ModifyExpressionValue;"; public static final String MIXIN_EXTRAS_MODIFY_RECEIVER = "Lcom/llamalad7/mixinextras/injector/ModifyReceiver;"; public static final String MIXIN_EXTRAS_MODIFY_RETURN_VALUE = "Lcom/llamalad7/mixinextras/injector/ModifyReturnValue;"; + public static final String MIXIN_EXTRAS_WRAP_METHOD = "Lcom/llamalad7/mixinextras/injector/wrapmethod/WrapMethod;"; public static final String MIXIN_EXTRAS_WRAP_OPERATION = "Lcom/llamalad7/mixinextras/injector/wrapoperation/WrapOperation;"; public static final String MIXIN_EXTRAS_WRAP_WITH_CONDITION = "Lcom/llamalad7/mixinextras/injector/WrapWithCondition;"; public static final String MIXIN_EXTRAS_WRAP_WITH_CONDITION_V2 = "Lcom/llamalad7/mixinextras/injector/v2/WrapWithCondition;"; diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/soft/SoftTargetMixinMethodVisitor.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/soft/SoftTargetMixinMethodVisitor.java index f97a9f4a..0b237d8f 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/soft/SoftTargetMixinMethodVisitor.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/soft/SoftTargetMixinMethodVisitor.java @@ -39,6 +39,7 @@ import net.fabricmc.tinyremapper.extension.mixin.soft.annotation.injection.ModifyReturnValueAnnotationVisitor; import net.fabricmc.tinyremapper.extension.mixin.soft.annotation.injection.ModifyVariableAnnotationVisitor; import net.fabricmc.tinyremapper.extension.mixin.soft.annotation.injection.RedirectAnnotationVisitor; +import net.fabricmc.tinyremapper.extension.mixin.soft.annotation.injection.WrapMethodAnnotationVisitor; import net.fabricmc.tinyremapper.extension.mixin.soft.annotation.injection.WrapOperationAnnotationVisitor; import net.fabricmc.tinyremapper.extension.mixin.soft.annotation.injection.WrapWithConditionAnnotationVisitor; import net.fabricmc.tinyremapper.extension.mixin.soft.annotation.injection.WrapWithConditionV2AnnotationVisitor; @@ -85,6 +86,8 @@ public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) { av = new ModifyReceiverAnnotationVisitor(data, av, remap, targets); } else if (Annotation.MIXIN_EXTRAS_MODIFY_RETURN_VALUE.equals(descriptor)) { av = new ModifyReturnValueAnnotationVisitor(data, av, remap, targets); + } else if (Annotation.MIXIN_EXTRAS_WRAP_METHOD.equals(descriptor)) { + av = new WrapMethodAnnotationVisitor(data, av, remap, targets); } else if (Annotation.MIXIN_EXTRAS_WRAP_OPERATION.equals(descriptor)) { av = new WrapOperationAnnotationVisitor(data, av, remap, targets); } else if (Annotation.MIXIN_EXTRAS_WRAP_WITH_CONDITION.equals(descriptor)) { diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/soft/annotation/injection/WrapMethodAnnotationVisitor.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/soft/annotation/injection/WrapMethodAnnotationVisitor.java new file mode 100644 index 00000000..df817bb3 --- /dev/null +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/soft/annotation/injection/WrapMethodAnnotationVisitor.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016, 2018, Player, asie + * Copyright (c) 2023, FabricMC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package net.fabricmc.tinyremapper.extension.mixin.soft.annotation.injection; + +import java.util.List; + +import org.objectweb.asm.AnnotationVisitor; + +import net.fabricmc.tinyremapper.extension.mixin.common.data.Annotation; +import net.fabricmc.tinyremapper.extension.mixin.common.data.CommonData; + +public class WrapMethodAnnotationVisitor extends CommonInjectionAnnotationVisitor { + public WrapMethodAnnotationVisitor(CommonData data, AnnotationVisitor delegate, boolean remap, List targets) { + super(Annotation.MIXIN_EXTRAS_WRAP_METHOD, data, delegate, remap, targets); + } +}