diff options
author | zaaarf <zaaarf@proton.me> | 2023-08-27 02:26:32 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-08-27 02:26:32 +0200 |
commit | 2a028258cbb54fd115dd12a151efdef136b624aa (patch) | |
tree | b07125e2c14bbfdd0a1d0b254ad7116f8969c0c8 /src/main/java | |
parent | 97f6819c9c0a05c70a57305274bc027318566f94 (diff) |
feat: (mostly) implemented TiyV2Writer
Diffstat (limited to 'src/main/java')
4 files changed, 43 insertions, 5 deletions
diff --git a/src/main/java/ftbsc/lll/mapper/writer/IWriter.java b/src/main/java/ftbsc/lll/mapper/writer/IWriter.java index 13244a9..c53593d 100644 --- a/src/main/java/ftbsc/lll/mapper/writer/IWriter.java +++ b/src/main/java/ftbsc/lll/mapper/writer/IWriter.java @@ -18,6 +18,7 @@ public interface IWriter { * Writes in a {@link PrintWriter} the contents of a {@link IMapper}. * @param mapper the mapper * @param writer the writer + * @param args various arguments which the writers may need */ - void write(IMapper mapper, PrintWriter writer); + void write(IMapper mapper, PrintWriter writer, String... args); } diff --git a/src/main/java/ftbsc/lll/mapper/writer/impl/SRGWriter.java b/src/main/java/ftbsc/lll/mapper/writer/impl/SRGWriter.java index b1b5ef7..5abb2db 100644 --- a/src/main/java/ftbsc/lll/mapper/writer/impl/SRGWriter.java +++ b/src/main/java/ftbsc/lll/mapper/writer/impl/SRGWriter.java @@ -11,6 +11,9 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; +/** + * An {@link IWriter} that writes in the SRG format. + */ @AutoService(IWriter.class) public class SRGWriter implements IWriter { @Override @@ -19,7 +22,7 @@ public class SRGWriter implements IWriter { } @Override - public void write(IMapper mapper, PrintWriter writer) { + public void write(IMapper mapper, PrintWriter writer, String... ignored) { List<FieldData> fieldData = new ArrayList<>(); List<MethodData> methodData = new ArrayList<>(); 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 fce3156..9828b4e 100644 --- a/src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java +++ b/src/main/java/ftbsc/lll/mapper/writer/impl/TSRGWriter.java @@ -7,7 +7,8 @@ import ftbsc.lll.mapper.writer.IWriter; import java.io.PrintWriter; /** - * Writes to TSRG, an intermediary format used by Forge. + * An {@link IWriter} that writes in the TSRG format, + * an intermediary format used by Forge. */ @AutoService(IWriter.class) public class TSRGWriter implements IWriter { @@ -17,8 +18,10 @@ public class TSRGWriter implements IWriter { } @Override - public void write(IMapper mapper, PrintWriter writer) { - writer.println("tsrg2 left right"); + public void write(IMapper mapper, PrintWriter writer, String... args) { + if(args.length < 2) + args = new String[] { "left", "right" }; + writer.printf("tsrg2 %s %s\n", args[0], args[1]); mapper.getRawMappings().forEach((name, data) -> { writer.printf("%s %s\n", name, data.nameMapped); data.getFields().forEach((fieldName, fieldData) -> diff --git a/src/main/java/ftbsc/lll/mapper/writer/impl/TinyV2Writer.java b/src/main/java/ftbsc/lll/mapper/writer/impl/TinyV2Writer.java new file mode 100644 index 0000000..fb233c3 --- /dev/null +++ b/src/main/java/ftbsc/lll/mapper/writer/impl/TinyV2Writer.java @@ -0,0 +1,31 @@ +package ftbsc.lll.mapper.writer.impl; + +import com.google.auto.service.AutoService; +import ftbsc.lll.mapper.IMapper; +import ftbsc.lll.mapper.writer.IWriter; + +import java.io.PrintWriter; + +/** + * An {@link IWriter} that writes in the Tiny v2 format. + */ +@AutoService(IWriter.class) +public class TinyV2Writer implements IWriter { + @Override + public String uniqueId() { + return "tinyv2"; + } + + @Override + public void write(IMapper mapper, PrintWriter writer, String... args) { + writer.printf("tiny\t2\t0\t%s\t%s", args[0], args[1]); //TODO namespace naming support + mapper.getRawMappings().forEach((name, data) -> { + writer.printf("c\t%s\t%s\n", name, data.nameMapped); + data.getFields().forEach((fieldName, fieldData) -> + writer.printf("\tf\t?\t%s\t%s\n", fieldName, fieldData.nameMapped)); //TODO field descriptors + data.getMethods().forEach(((methodSignature, methodData) -> + writer.printf("\tm\t%s\t%s\t%s\n", methodSignature.descriptor, + methodSignature.name, methodData.nameMapped))); + }); + } +} |