Convert ClassMetadata to Kotlin

The dependency/interface properties are translated to getDependency and
getInterface. I don't know if it is possible to fix this, but it won't matter
when the rest of the codebase is converted to Kotlin.
master
Graham 5 years ago
parent 07bb22f795
commit e5af454815
  1. 4
      asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.java
  2. 34
      asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.java
  3. 26
      asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt
  4. 4
      asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.java
  5. 8
      deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.java

@ -22,12 +22,12 @@ public final class AsmClassMetadata extends ClassMetadata {
} }
@Override @Override
public boolean isDependency() { public boolean getDependency() {
return dependency; return dependency;
} }
@Override @Override
public boolean isInterface() { public boolean getInterface() {
return (clazz.access & Opcodes.ACC_INTERFACE) != 0; return (clazz.access & Opcodes.ACC_INTERFACE) != 0;
} }

@ -1,34 +0,0 @@
package dev.openrs2.asm.classpath;
import java.util.Objects;
import com.google.common.collect.ImmutableList;
import dev.openrs2.asm.MemberDesc;
public abstract class ClassMetadata {
public abstract String getName();
public abstract boolean isDependency();
public abstract boolean isInterface();
public abstract ClassMetadata getSuperClass();
public abstract ImmutableList<ClassMetadata> getSuperInterfaces();
public abstract ImmutableList<MemberDesc> getFields();
public abstract ImmutableList<MemberDesc> getMethods();
public abstract boolean isNative(MemberDesc method);
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
var that = (ClassMetadata) o;
return getName().equals(that.getName());
}
@Override
public int hashCode() {
return Objects.hash(getName());
}
}

@ -0,0 +1,26 @@
package dev.openrs2.asm.classpath
import dev.openrs2.asm.MemberDesc
abstract class ClassMetadata {
abstract val name: String
abstract val dependency: Boolean
abstract val `interface`: Boolean
abstract val superClass: ClassMetadata?
abstract val superInterfaces: List<ClassMetadata>
abstract val fields: List<MemberDesc>
abstract val methods: List<MemberDesc>
abstract fun isNative(method: MemberDesc): Boolean
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is ClassMetadata) return false
return name == other.name
}
override fun hashCode(): Int {
return name.hashCode()
}
}

@ -22,12 +22,12 @@ public final class ReflectionClassMetadata extends ClassMetadata {
} }
@Override @Override
public boolean isDependency() { public boolean getDependency() {
return true; return true;
} }
@Override @Override
public boolean isInterface() { public boolean getInterface() {
return clazz.isInterface(); return clazz.isInterface();
} }

@ -91,7 +91,7 @@ public final class TypedRemapper extends Remapper {
private static String populateClassMapping(Map<String, String> mapping, Map<String, Integer> prefixes, ClassMetadata clazz) { private static String populateClassMapping(Map<String, String> mapping, Map<String, Integer> prefixes, ClassMetadata clazz) {
var name = clazz.getName(); var name = clazz.getName();
if (mapping.containsKey(name) || EXCLUDED_CLASSES.contains(name) || clazz.isDependency()) { if (mapping.containsKey(name) || EXCLUDED_CLASSES.contains(name) || clazz.getDependency()) {
return mapping.getOrDefault(name, name); return mapping.getOrDefault(name, name);
} }
@ -103,7 +103,7 @@ public final class TypedRemapper extends Remapper {
superName = superName.substring(superName.lastIndexOf('/') + 1); superName = superName.substring(superName.lastIndexOf('/') + 1);
mappedName += generateName(prefixes, superName + "_Sub"); mappedName += generateName(prefixes, superName + "_Sub");
} else if (clazz.isInterface()) { } else if (clazz.getInterface()) {
mappedName += generateName(prefixes, "Interface"); mappedName += generateName(prefixes, "Interface");
} else { } else {
mappedName += generateName(prefixes, "Class"); mappedName += generateName(prefixes, "Class");
@ -128,7 +128,7 @@ public final class TypedRemapper extends Remapper {
break; break;
} }
if (clazz.isDependency()) { if (clazz.getDependency()) {
skip = true; skip = true;
break; break;
} }
@ -185,7 +185,7 @@ public final class TypedRemapper extends Remapper {
return true; return true;
} }
if (clazz.isDependency()) { if (clazz.getDependency()) {
return true; return true;
} }

Loading…
Cancel
Save