mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-20 12:19:52 +00:00
0.6.15 Add support for multiple constants in ModifyConstant, closes #190
This commit is contained in:
1 parent
c6ce27efb0
commit
64feb8cbfd
5 files changed
+26
-11
No files matched your search
@@ -62,7 +62,7 @@ public abstract class MixinBootstrap {
|
||||
/**
|
||||
* Subsystem version
|
||||
*/
|
||||
public static final String VERSION = "0.6.14";
|
||||
public static final String VERSION = "0.6.15";
|
||||
|
||||
// Consts
|
||||
private static final String LAUNCH_PACKAGE = "org.spongepowered.asm.launch.";
|
||||
|
||||
@@ -77,13 +77,13 @@ public @interface ModifyConstant {
|
||||
public Slice slice() default @Slice;
|
||||
|
||||
/**
|
||||
* Discriminator for the constant to match (injection point), if not
|
||||
* Discriminator for the constant(s) to match (injection points), if not
|
||||
* specified then all constants matching the annotated handler's return type
|
||||
* are matched
|
||||
*
|
||||
* @return the constant discriminator
|
||||
*/
|
||||
public Constant constant() default @Constant;
|
||||
public Constant[] constant() default {};
|
||||
|
||||
/**
|
||||
* By default, the annotation processor will attempt to locate an
|
||||
|
||||
@@ -84,6 +84,11 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC
|
||||
* Method slice descriptors parsed from the annotation
|
||||
*/
|
||||
protected final MethodSlices slices;
|
||||
|
||||
/**
|
||||
* The key into the annotation which contains the injection points
|
||||
*/
|
||||
protected final String atKey;
|
||||
|
||||
/**
|
||||
* Injection points parsed from
|
||||
@@ -134,9 +139,14 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC
|
||||
* @param annotation Annotation to parse
|
||||
*/
|
||||
protected InjectionInfo(MixinTargetContext mixin, MethodNode method, AnnotationNode annotation) {
|
||||
this(mixin, method, annotation, "at");
|
||||
}
|
||||
|
||||
protected InjectionInfo(MixinTargetContext mixin, MethodNode method, AnnotationNode annotation, String atKey) {
|
||||
super(mixin, method, annotation);
|
||||
this.isStatic = Bytecode.methodIsStatic(method);
|
||||
this.slices = MethodSlices.parse(this);
|
||||
this.atKey = atKey;
|
||||
this.readAnnotation();
|
||||
}
|
||||
|
||||
@@ -176,9 +186,9 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC
|
||||
}
|
||||
|
||||
protected List<AnnotationNode> readInjectionPoints(String type) {
|
||||
List<AnnotationNode> ats = Annotations.<AnnotationNode>getValue(this.annotation, "at", false);
|
||||
List<AnnotationNode> ats = Annotations.<AnnotationNode>getValue(this.annotation, this.atKey, false);
|
||||
if (ats == null) {
|
||||
throw new InvalidInjectionException(this, type + " annotation on " + this.method.name + " is missing 'at' value(s)");
|
||||
throw new InvalidInjectionException(this, type + " annotation on " + this.method.name + " is missing '" + this.atKey + "' value(s)");
|
||||
}
|
||||
return ats;
|
||||
}
|
||||
|
||||
+10
-5
@@ -24,7 +24,6 @@
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.injection.struct;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -49,6 +48,7 @@ import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
/**
|
||||
@@ -215,15 +215,20 @@ public class ModifyConstantInjectionInfo extends InjectionInfo {
|
||||
|
||||
}
|
||||
|
||||
private static final String CONSTANT_ANNOTATION_CLASS = Constant.class.getName().replace('.', '/');
|
||||
|
||||
public ModifyConstantInjectionInfo(MixinTargetContext mixin, MethodNode method, AnnotationNode annotation) {
|
||||
super(mixin, method, annotation);
|
||||
super(mixin, method, annotation, "constant");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AnnotationNode> readInjectionPoints(String type) {
|
||||
AnnotationNode constantAnnotation = Annotations.<AnnotationNode>getValue(this.annotation, "constant");
|
||||
List<AnnotationNode> ats = new ArrayList<AnnotationNode>();
|
||||
ats.add(constantAnnotation);
|
||||
List<AnnotationNode> ats = super.readInjectionPoints(type);
|
||||
if (ats.isEmpty()) {
|
||||
AnnotationNode c = new AnnotationNode(ModifyConstantInjectionInfo.CONSTANT_ANNOTATION_CLASS);
|
||||
c.visit("log", Boolean.TRUE);
|
||||
ats = ImmutableList.<AnnotationNode>of(c);
|
||||
}
|
||||
return ats;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user