summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-08-27 02:13:20 +0200
committer zaaarf <zaaarf@proton.me>2023-08-27 02:13:20 +0200
commit97f6819c9c0a05c70a57305274bc027318566f94 (patch)
tree45d605a7565677614225cb77fda46384ef8f6799
parent1d13d08565f354c479d860244d2ea9e92ae2e9d2 (diff)
feat: SRGWriter
-rw-r--r--src/main/java/ftbsc/lll/mapper/writer/impl/SRGWriter.java43
-rw-r--r--src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java2
2 files changed, 44 insertions, 1 deletions
diff --git a/src/main/java/ftbsc/lll/mapper/writer/impl/SRGWriter.java b/src/main/java/ftbsc/lll/mapper/writer/impl/SRGWriter.java
new file mode 100644
index 0000000..b1b5ef7
--- /dev/null
+++ b/src/main/java/ftbsc/lll/mapper/writer/impl/SRGWriter.java
@@ -0,0 +1,43 @@
+package ftbsc.lll.mapper.writer.impl;
+
+import com.google.auto.service.AutoService;
+import ftbsc.lll.mapper.IMapper;
+import ftbsc.lll.mapper.tools.MappingUtils;
+import ftbsc.lll.mapper.tools.data.FieldData;
+import ftbsc.lll.mapper.tools.data.MethodData;
+import ftbsc.lll.mapper.writer.IWriter;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+@AutoService(IWriter.class)
+public class SRGWriter implements IWriter {
+ @Override
+ public String uniqueId() {
+ return "srg";
+ }
+
+ @Override
+ public void write(IMapper mapper, PrintWriter writer) {
+ List<FieldData> fieldData = new ArrayList<>();
+ List<MethodData> methodData = new ArrayList<>();
+
+ //print classes and save rest for later
+ mapper.getRawMappings().forEach((name, data) -> {
+ writer.printf("CL: %s, %s\n", name, data.nameMapped);
+ fieldData.addAll(data.getFields().values());
+ methodData.addAll(data.getMethods().values());
+ });
+
+ //print fields
+ fieldData.forEach(data -> writer.printf("FD: %s/%s %s/%s\n",
+ data.parentClass.name, data.name, data.parentClass.nameMapped, data.nameMapped));
+
+ //print methods
+ methodData.forEach(data -> writer.printf("MD: %s/%s %s %s/%s %s\n",
+ data.parentClass.name, data.signature.name, data.signature.descriptor,
+ data.parentClass.nameMapped, data.nameMapped, MappingUtils.mapMethodDescriptor(
+ data.signature.descriptor, mapper, false)));
+ }
+}
diff --git a/src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java b/src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java
index 2fbb812..fce3156 100644
--- a/src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java
+++ b/src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java
@@ -20,7 +20,7 @@ public class TSRGWriter implements IWriter {
public void write(IMapper mapper, PrintWriter writer) {
writer.println("tsrg2 left right");
mapper.getRawMappings().forEach((name, data) -> {
- writer.printf("%s %s\n", data.name, data.nameMapped);
+ writer.printf("%s %s\n", name, data.nameMapped);
data.getFields().forEach((fieldName, fieldData) ->
writer.printf("\t%s %s\n", fieldName, fieldData.nameMapped));
data.getMethods().forEach(((methodSignature, methodData) ->