mirror of
https://github.com/zaaarf/lillero-mapping-writer.git
synced 2024-11-22 20:24:50 +01:00
feat: (mostly) implemented TiyV2Writer
This commit is contained in:
parent
97f6819c9c
commit
2a028258cb
4 changed files with 43 additions and 5 deletions
|
@ -18,6 +18,7 @@ public interface IWriter {
|
||||||
* Writes in a {@link PrintWriter} the contents of a {@link IMapper}.
|
* Writes in a {@link PrintWriter} the contents of a {@link IMapper}.
|
||||||
* @param mapper the mapper
|
* @param mapper the mapper
|
||||||
* @param writer the writer
|
* @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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An {@link IWriter} that writes in the SRG format.
|
||||||
|
*/
|
||||||
@AutoService(IWriter.class)
|
@AutoService(IWriter.class)
|
||||||
public class SRGWriter implements IWriter {
|
public class SRGWriter implements IWriter {
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +22,7 @@ public class SRGWriter implements IWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(IMapper mapper, PrintWriter writer) {
|
public void write(IMapper mapper, PrintWriter writer, String... ignored) {
|
||||||
List<FieldData> fieldData = new ArrayList<>();
|
List<FieldData> fieldData = new ArrayList<>();
|
||||||
List<MethodData> methodData = new ArrayList<>();
|
List<MethodData> methodData = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ import ftbsc.lll.mapper.writer.IWriter;
|
||||||
import java.io.PrintWriter;
|
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)
|
@AutoService(IWriter.class)
|
||||||
public class TSRGWriter implements IWriter {
|
public class TSRGWriter implements IWriter {
|
||||||
|
@ -17,8 +18,10 @@ public class TSRGWriter implements IWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(IMapper mapper, PrintWriter writer) {
|
public void write(IMapper mapper, PrintWriter writer, String... args) {
|
||||||
writer.println("tsrg2 left right");
|
if(args.length < 2)
|
||||||
|
args = new String[] { "left", "right" };
|
||||||
|
writer.printf("tsrg2 %s %s\n", args[0], args[1]);
|
||||||
mapper.getRawMappings().forEach((name, data) -> {
|
mapper.getRawMappings().forEach((name, data) -> {
|
||||||
writer.printf("%s %s\n", name, data.nameMapped);
|
writer.printf("%s %s\n", name, data.nameMapped);
|
||||||
data.getFields().forEach((fieldName, fieldData) ->
|
data.getFields().forEach((fieldName, fieldData) ->
|
||||||
|
|
31
src/main/java/ftbsc/lll/mapper/writer/impl/TinyV2Writer.java
Normal file
31
src/main/java/ftbsc/lll/mapper/writer/impl/TinyV2Writer.java
Normal file
|
@ -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)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue