mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-12-03 19:55:26 +00:00
Update dependencies
- Update Loom — required for MC 26.2. - Update TeaVM, using the new reflection API.
This commit is contained in:
5 files changed
+352
-373
No files matched your search
@@ -61,7 +61,7 @@ cctJavadoc = "1.9.0"
|
||||
checkstyle = "13.4.1"
|
||||
errorProne-core = "2.49.0"
|
||||
errorProne-plugin = "4.3.0"
|
||||
fabric-loom = "1.16.1"
|
||||
fabric-loom = "1.17.11"
|
||||
githubRelease = "2.5.2"
|
||||
gradleVersions = "0.54.0"
|
||||
ideaExt = "1.3"
|
||||
@@ -72,7 +72,7 @@ modDevGradle = "2.0.141"
|
||||
nullAway = "0.13.4"
|
||||
shadow = "9.4.1"
|
||||
spotless = "8.4.0"
|
||||
teavm = "0.14.0"
|
||||
teavm = "0.15.0"
|
||||
vanillaExtract = "0.3.1"
|
||||
versionCatalogUpdate = "1.1.0"
|
||||
|
||||
@@ -161,8 +161,7 @@ teavm-core = { module = "org.teavm:teavm-core", version.ref = "teavm" }
|
||||
teavm-jso = { module = "org.teavm:teavm-jso", version.ref = "teavm" }
|
||||
teavm-jso-apis = { module = "org.teavm:teavm-jso-apis", version.ref = "teavm" }
|
||||
teavm-jso-impl = { module = "org.teavm:teavm-jso-impl", version.ref = "teavm" }
|
||||
teavm-metaprogramming-api = { module = "org.teavm:teavm-metaprogramming-api", version.ref = "teavm" }
|
||||
teavm-metaprogramming-impl = { module = "org.teavm:teavm-metaprogramming-impl", version.ref = "teavm" }
|
||||
teavm-extension-apis = { module = "org.teavm:teavm-extension-apis", version.ref = "teavm" }
|
||||
teavm-platform = { module = "org.teavm:teavm-platform", version.ref = "teavm" }
|
||||
teavm-tooling = { module = "org.teavm:teavm-tooling", version.ref = "teavm" }
|
||||
vanillaExtract = { module = "cc.tweaked.vanilla-extract:plugin", version.ref = "vanillaExtract" }
|
||||
@@ -191,5 +190,5 @@ test = ["junit-jupiter-api", "junit-jupiter-params", "hamcrest", "jqwik-api"]
|
||||
testRuntime = ["junit-jupiter-engine", "junit-platform-launcher", "jqwik-engine"]
|
||||
|
||||
# Build tools
|
||||
teavm-api = ["teavm-jso", "teavm-jso-apis", "teavm-platform", "teavm-classlib", "teavm-metaprogramming-api"]
|
||||
teavm-tooling = ["teavm-tooling", "teavm-metaprogramming-impl", "teavm-jso-impl"]
|
||||
teavm-api = ["teavm-jso", "teavm-jso-apis", "teavm-platform", "teavm-classlib", "teavm-extension-apis"]
|
||||
teavm-tooling = ["teavm-tooling", "teavm-jso-impl"]
|
||||
Generated
+298
-322
File diff suppressed because it is too large.
Load diff
@@ -140,80 +140,80 @@ loom {
|
||||
|
||||
runs {
|
||||
configureEach {
|
||||
ideConfigGenerated(true)
|
||||
generateRunConfig = true
|
||||
ideConfigFolder = "Fabric"
|
||||
}
|
||||
|
||||
named("client") {
|
||||
configName = "Client"
|
||||
displayName = "Client"
|
||||
}
|
||||
|
||||
named("server") {
|
||||
configName = "Server"
|
||||
runDir("run/server")
|
||||
displayName = "Server"
|
||||
runDirectory = layout.projectDirectory.dir("run/server")
|
||||
}
|
||||
|
||||
fun RunConfigSettings.configureForData(sourceSet: SourceSet) {
|
||||
client()
|
||||
runDir("run/run${name.capitalise()}")
|
||||
property("fabric-api.datagen")
|
||||
property(
|
||||
runDirectory = layout.buildDirectory.dir("run${name.capitalise()}")
|
||||
systemProperties.put("fabric-api.datagen", "true")
|
||||
systemProperties.put(
|
||||
"fabric-api.datagen.output-dir",
|
||||
layout.buildDirectory.dir(sourceSet.getTaskName("generateResources", null)).getAbsolutePath(),
|
||||
)
|
||||
property("fabric-api.datagen.strict-validation")
|
||||
systemProperties.put("fabric-api.datagen.strict-validation", "true")
|
||||
}
|
||||
|
||||
register("data") {
|
||||
configName = "Datagen"
|
||||
displayName = "Datagen"
|
||||
configureForData(sourceSets.main.get())
|
||||
source(sourceSets.datagen.get())
|
||||
sourceSet = sourceSets.datagen.name
|
||||
}
|
||||
|
||||
fun RunConfigSettings.configureForGameTest() {
|
||||
source(sourceSets.testMod.get())
|
||||
sourceSet = sourceSets.testMod.name
|
||||
|
||||
val testSources = project(":common").file("src/testMod/resources/data/cctest").absolutePath
|
||||
property("cctest.sources", testSources)
|
||||
systemProperties.put("cctest.sources", testSources)
|
||||
|
||||
// Load cctest last, so it can override resources. This bypasses Fabric's shuffling of mods
|
||||
property("fabric.debug.loadLate", "cctest")
|
||||
systemProperties.put("fabric.debug.loadLate", "cctest")
|
||||
|
||||
vmArg("-ea")
|
||||
jvmArguments.add("-ea")
|
||||
}
|
||||
|
||||
val testClient by registering {
|
||||
configName = "Test Client"
|
||||
displayName = "Test Client"
|
||||
client()
|
||||
configureForGameTest()
|
||||
|
||||
runDir("run/testClient")
|
||||
property("cctest.tags", "client,common")
|
||||
runDirectory = layout.projectDirectory.dir("run/testClient")
|
||||
systemProperties.put("cctest.tags", "client,common")
|
||||
}
|
||||
|
||||
register("gametest") {
|
||||
configName = "Game Test"
|
||||
displayName = "Game Test"
|
||||
server()
|
||||
configureForGameTest()
|
||||
|
||||
property("fabric-api.gametest")
|
||||
property(
|
||||
systemProperties.put("fabric-api.gametest", "true")
|
||||
systemProperties.put(
|
||||
"fabric-api.gametest.report-file",
|
||||
layout.buildDirectory.dir("test-results/runGametest.xml").getAbsolutePath(),
|
||||
)
|
||||
runDir("run/gametest")
|
||||
runDirectory = layout.projectDirectory.dir("run/gametest")
|
||||
}
|
||||
|
||||
register("exampleClient") {
|
||||
client()
|
||||
configName = "Example Mod Client"
|
||||
source(sourceSets.examples.get())
|
||||
displayName = "Example Mod Client"
|
||||
sourceSet = sourceSets.examples.name
|
||||
}
|
||||
|
||||
register("exampleData") {
|
||||
configName = "Example Mod Datagen"
|
||||
displayName = "Example Mod Datagen"
|
||||
configureForData(sourceSets.examples.get())
|
||||
source(sourceSets.examples.get())
|
||||
sourceSet = sourceSets.examples.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,11 @@ import dan200.computercraft.api.peripheral.PeripheralType;
|
||||
import dan200.computercraft.core.methods.LuaMethod;
|
||||
import dan200.computercraft.core.methods.NamedMethod;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.teavm.metaprogramming.*;
|
||||
import org.teavm.extension.introspect.IntrospectClass;
|
||||
import org.teavm.metaprogramming.CompileTime;
|
||||
import org.teavm.metaprogramming.Meta;
|
||||
import org.teavm.metaprogramming.Metaprogramming;
|
||||
import org.teavm.metaprogramming.Value;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -35,7 +39,7 @@ public class MethodReflection {
|
||||
@Meta
|
||||
public static native boolean getMethods(Class<?> type, Consumer<NamedMethod<LuaMethod>> make);
|
||||
|
||||
private static void getMethods(ReflectClass<?> klass, Value<Consumer<NamedMethod<LuaMethod>>> make) {
|
||||
private static void getMethods(IntrospectClass<?> klass, Value<Consumer<NamedMethod<LuaMethod>>> make) {
|
||||
var result = getMethodsImpl(klass, make);
|
||||
// Using "unsupportedCase" here causes us to skip generating any code and just return null. While null isn't
|
||||
// a boolean, it's still false-y and thus has the same effect in the generated JS!
|
||||
@@ -43,15 +47,15 @@ public class MethodReflection {
|
||||
Metaprogramming.exit(() -> result);
|
||||
}
|
||||
|
||||
private static boolean getMethodsImpl(ReflectClass<?> klass, Value<Consumer<NamedMethod<LuaMethod>>> make) {
|
||||
if (!klass.getName().startsWith("dan200.computercraft.") && !klass.getName().startsWith("cc.tweaked.web.peripheral")) {
|
||||
private static boolean getMethodsImpl(IntrospectClass<?> klass, Value<Consumer<NamedMethod<LuaMethod>>> make) {
|
||||
if (!klass.name().startsWith("dan200.computercraft.") && !klass.name().startsWith("cc.tweaked.web.peripheral")) {
|
||||
return false;
|
||||
}
|
||||
if (klass.getName().contains("lambda")) return false;
|
||||
if (klass.name().contains("lambda")) return false;
|
||||
|
||||
Class<?> actualClass;
|
||||
try {
|
||||
actualClass = Metaprogramming.getClassLoader().loadClass(klass.getName());
|
||||
actualClass = Metaprogramming.environment().classLoader().loadClass(klass.name());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -60,7 +64,7 @@ public class MethodReflection {
|
||||
for (var method : methods) {
|
||||
var name = method.name();
|
||||
var nonYielding = method.nonYielding();
|
||||
var actualField = method.method().getField("INSTANCE");
|
||||
var actualField = Metaprogramming.accessor(method.method().field("INSTANCE"));
|
||||
|
||||
Metaprogramming.emit(() -> make.get().accept(new NamedMethod<>(name, (LuaMethod) actualField.get(null), nonYielding, null)));
|
||||
}
|
||||
@@ -69,7 +73,7 @@ public class MethodReflection {
|
||||
}
|
||||
|
||||
private static final class Internal {
|
||||
private static final LoadingCache<Class<?>, List<NamedMethod<ReflectClass<LuaMethod>>>> CLASS_CACHE = CacheBuilder
|
||||
private static final LoadingCache<Class<?>, List<NamedMethod<IntrospectClass<LuaMethod>>>> CLASS_CACHE = CacheBuilder
|
||||
.newBuilder()
|
||||
.build(CacheLoader.from(Internal::getMethodsImpl));
|
||||
|
||||
@@ -77,7 +81,7 @@ public class MethodReflection {
|
||||
LuaMethod.class, List.of(ILuaContext.class), Internal::createClass
|
||||
);
|
||||
|
||||
static List<NamedMethod<ReflectClass<LuaMethod>>> getMethods(Class<?> klass) {
|
||||
static List<NamedMethod<IntrospectClass<LuaMethod>>> getMethods(Class<?> klass) {
|
||||
try {
|
||||
return CLASS_CACHE.get(klass);
|
||||
} catch (ExecutionException e) {
|
||||
@@ -85,7 +89,7 @@ public class MethodReflection {
|
||||
}
|
||||
}
|
||||
|
||||
private static ReflectClass<?> createClass(byte[] bytes) {
|
||||
private static IntrospectClass<?> createClass(byte[] bytes) {
|
||||
/*
|
||||
StaticGenerator is not declared to be @CompileTime, to ensure it loads in the same module/classloader as
|
||||
other files in this package. This means it can't call Metaprogramming.createClass directly, as that's
|
||||
@@ -94,11 +98,11 @@ public class MethodReflection {
|
||||
We need to use an explicit call (rather than a MethodReference), as TeaVM doesn't correctly rewrite the
|
||||
latter.
|
||||
*/
|
||||
return Metaprogramming.createClass(bytes);
|
||||
return Metaprogramming.environment().createClass(bytes);
|
||||
}
|
||||
|
||||
private static List<NamedMethod<ReflectClass<LuaMethod>>> getMethodsImpl(Class<?> klass) {
|
||||
ArrayList<NamedMethod<ReflectClass<LuaMethod>>> methods = null;
|
||||
private static List<NamedMethod<IntrospectClass<LuaMethod>>> getMethodsImpl(Class<?> klass) {
|
||||
ArrayList<NamedMethod<IntrospectClass<LuaMethod>>> methods = null;
|
||||
|
||||
// Find all methods on the current class
|
||||
for (var method : klass.getMethods()) {
|
||||
@@ -122,7 +126,7 @@ public class MethodReflection {
|
||||
return Collections.unmodifiableList(methods);
|
||||
}
|
||||
|
||||
private static void addMethod(List<NamedMethod<ReflectClass<LuaMethod>>> methods, Method method, LuaFunction annotation, @Nullable PeripheralType genericType, ReflectClass<LuaMethod> instance) {
|
||||
private static void addMethod(List<NamedMethod<IntrospectClass<LuaMethod>>> methods, Method method, LuaFunction annotation, @Nullable PeripheralType genericType, IntrospectClass<LuaMethod> instance) {
|
||||
var names = annotation.value();
|
||||
var isSimple = method.getReturnType() != MethodResult.class && !annotation.mainThread();
|
||||
if (names.length == 0) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.jspecify.annotations.Nullable;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.teavm.metaprogramming.ReflectClass;
|
||||
import org.teavm.extension.introspect.IntrospectClass;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -58,13 +58,13 @@ public final class StaticGenerator<T> {
|
||||
private final String methodDesc;
|
||||
private final String classPrefix;
|
||||
|
||||
private final Function<byte[], ReflectClass<?>> createClass;
|
||||
private final Function<byte[], IntrospectClass<?>> createClass;
|
||||
|
||||
private final LoadingCache<Method, Optional<ReflectClass<T>>> methodCache = CacheBuilder
|
||||
private final LoadingCache<Method, Optional<IntrospectClass<T>>> methodCache = CacheBuilder
|
||||
.newBuilder()
|
||||
.build(CacheLoader.from(catching(this::build, Optional.empty())));
|
||||
|
||||
public StaticGenerator(Class<T> base, List<Class<?>> context, Function<byte[], ReflectClass<?>> createClass) {
|
||||
public StaticGenerator(Class<T> base, List<Class<?>> context, Function<byte[], IntrospectClass<?>> createClass) {
|
||||
this.base = base;
|
||||
this.context = context;
|
||||
this.createClass = createClass;
|
||||
@@ -79,11 +79,11 @@ public final class StaticGenerator<T> {
|
||||
classPrefix = StaticGenerator.class.getPackageName() + "." + base.getSimpleName() + "$";
|
||||
}
|
||||
|
||||
public Optional<ReflectClass<T>> getMethod(Method method) {
|
||||
public Optional<IntrospectClass<T>> getMethod(Method method) {
|
||||
return methodCache.getUnchecked(method);
|
||||
}
|
||||
|
||||
private Optional<ReflectClass<T>> build(Method method) {
|
||||
private Optional<IntrospectClass<T>> build(Method method) {
|
||||
var name = method.getDeclaringClass().getName() + "." + method.getName();
|
||||
var modifiers = method.getModifiers();
|
||||
|
||||
|
||||
Reference in new issue
Block a user