Skip to content

Fix/avoid re-entrance #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ buildscript {
}
}
dependencies {
classpath 'com.github.Chocohead:fabric-loom:415c6b'
classpath 'com.github.Chocohead:fabric-loom:49aa217'
}
}

@@ -34,9 +34,9 @@ minecraft {
}

dependencies {
minecraft "com.mojang:minecraft:1.14 Pre-Release 3"
mappings "net.fabricmc:yarn:1.14 Pre-Release 3+build.1:tiny@gz"
modCompile "net.fabricmc:fabric-loader:0.7.0+build.171"
minecraft "com.mojang:minecraft:1.14"
mappings "net.fabricmc:yarn:1.14+build.1:tiny@gz"
modCompile "net.fabricmc:fabric-loader:0.10.0+build.208"
}

sourceSets {
2 changes: 1 addition & 1 deletion example/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
]
},
"depends": {
"fabricloader": ">=0.7.0",
"fabricloader": ">=0.10.0",
"mm": ">=2.3"
}
}
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
]
},
"depends": {
"fabricloader": ">=0.7.0"
"fabricloader": ">=0.10.0"
},
"mixins": [{
"config": "mixins.mm.json"
9 changes: 7 additions & 2 deletions src/com/chocohead/mm/EnumExtender.java
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@
import com.chocohead.mm.api.EnumAdder.EnumAddition;

public final class EnumExtender {
public static final Map<String, Object[]> POOL = new HashMap<>();
public static final Map<String, Supplier<Object[]>> POOL = new HashMap<>();


static Consumer<ClassNode> makeEnumExtender(EnumAdder builder) {
@@ -176,6 +176,10 @@ static Consumer<ClassNode> makeEnumExtender(EnumAdder builder) {
InsnList arrayFilling = new InsnList();

for (EnumAddition addition : builder.getAdditions()) {
String additionType = addition.isEnumSubclass() ? anonymousClassFactory.get() : node.name;
if (addition.isEnumSubclass() && node.permittedSubclasses != null) {
node.permittedSubclasses.add(additionType);
}
node.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC + Opcodes.ACC_ENUM, addition.name, 'L' + node.name + ';', null, null);

LabelNode stuffStart;
@@ -186,14 +190,15 @@ static Consumer<ClassNode> makeEnumExtender(EnumAdder builder) {
POOL.put(poolKey, addition.getParameters());
fieldSetting.add(new LdcInsnNode(poolKey));
fieldSetting.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "java/util/Map", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", true));
fieldSetting.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/util/function/Supplier"));
fieldSetting.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "java/util/function/Supplier", "get", "()Ljava/lang/Object;", true));
fieldSetting.add(new TypeInsnNode(Opcodes.CHECKCAST, "[Ljava/lang/Object;"));
fieldSetting.add(new VarInsnNode(Opcodes.ASTORE, 0));

stuffStart = new LabelNode();
fieldSetting.add(stuffStart);
} else stuffStart = null;

String additionType = addition.isEnumSubclass() ? anonymousClassFactory.get() : node.name;
fieldSetting.add(new TypeInsnNode(Opcodes.NEW, additionType));
fieldSetting.add(new InsnNode(Opcodes.DUP));

4 changes: 2 additions & 2 deletions src/com/chocohead/mm/api/EnumAdder.java
Original file line number Diff line number Diff line change
@@ -67,8 +67,8 @@ public final class EnumAddition {
*
* @throws IllegalArgumentException If the factory produces an invalid parameter array
*/
public Object[] getParameters() {
return checkParameters(parameterFactory.get());
public Supplier<Object[]> getParameters() {
return () -> checkParameters(parameterFactory.get());
}

/**