From e07a0ac4238ecd8b2014237073e2daa5e6dee028 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Sun, 27 Aug 2023 09:49:12 +0200 Subject: feat: added support for field type descriptor --- .../java/ftbsc/lll/mapper/impl/TinyV2Mapper.java | 2 +- .../ftbsc/lll/mapper/tools/data/ClassData.java | 10 +++++++++ .../ftbsc/lll/mapper/tools/data/FieldData.java | 24 +++++++++++++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/ftbsc/lll/mapper/impl/TinyV2Mapper.java b/src/main/java/ftbsc/lll/mapper/impl/TinyV2Mapper.java index d27756d..b7b58a1 100644 --- a/src/main/java/ftbsc/lll/mapper/impl/TinyV2Mapper.java +++ b/src/main/java/ftbsc/lll/mapper/impl/TinyV2Mapper.java @@ -53,7 +53,7 @@ public class TinyV2Mapper extends AbstractMapper { case 'f': //fields if(tokens.length == 4) break; - this.mappings.get(currentClass).addField(tokens[2], tokens[3]); + this.mappings.get(currentClass).addField(tokens[2], tokens[3], tokens[1]); continue; } break; diff --git a/src/main/java/ftbsc/lll/mapper/tools/data/ClassData.java b/src/main/java/ftbsc/lll/mapper/tools/data/ClassData.java index cdcec4d..4bd0af0 100644 --- a/src/main/java/ftbsc/lll/mapper/tools/data/ClassData.java +++ b/src/main/java/ftbsc/lll/mapper/tools/data/ClassData.java @@ -68,6 +68,16 @@ public class ClassData { this.fields.put(plain, new FieldData(this, plain, mapped)); } + /** + * Adds a field to the target class. + * @param plain the name of the field + * @param mapped the mapped name of the field + * @param descriptor the plain type descriptor of the field + */ + public void addField(String plain, String mapped, String descriptor) { + this.fields.put(plain, new FieldData(this, plain, mapped, descriptor)); + } + /** * Generates the reverse mappings for this class. * Should always be called only after the given mapper has finished diff --git a/src/main/java/ftbsc/lll/mapper/tools/data/FieldData.java b/src/main/java/ftbsc/lll/mapper/tools/data/FieldData.java index bcc3985..e239d66 100644 --- a/src/main/java/ftbsc/lll/mapper/tools/data/FieldData.java +++ b/src/main/java/ftbsc/lll/mapper/tools/data/FieldData.java @@ -21,7 +21,14 @@ public class FieldData { public final String nameMapped; /** - * Constructs a new {@link FieldData}. + * The field's type descriptor. + * Some formats may not specify it; if this was created in one such format, + * this is going to be null. + */ + public final String descriptor; + + /** + * Constructs a new {@link FieldData} with unspecified descriptor. * @param parentClass the {@link ClassData} representation of the parent class * @param name the field name * @param nameMapped the mapped field name @@ -30,5 +37,20 @@ public class FieldData { this.parentClass = parentClass; this.name = name; this.nameMapped = nameMapped; + this.descriptor = null; + } + + /** + * Constructs a new {@link FieldData} with descriptor. + * @param parentClass the {@link ClassData} representation of the parent class + * @param name the field name + * @param nameMapped the mapped field name + * @param descriptor the field's type descriptor + */ + public FieldData(ClassData parentClass, String name, String nameMapped, String descriptor) { + this.parentClass = parentClass; + this.name = name; + this.nameMapped = nameMapped; + this.descriptor = descriptor; } } -- cgit v1.2.3-56-ga3b1