Add MemberRefKeyDeserializer

Signed-off-by: Graham <gpe@openrs2.dev>
Graham 5 years ago
parent e8ecd5016d
commit 435dee8b6d
  1. 10
      asm/src/main/java/dev/openrs2/asm/MemberRef.kt
  2. 1
      deob-map/build.gradle.kts
  3. 12
      deob-map/src/main/java/dev/openrs2/deob/map/DeobfuscatorMapJacksonModule.kt
  4. 15
      deob-map/src/main/java/dev/openrs2/deob/map/DeobfuscatorMapModule.kt
  5. 11
      deob-map/src/main/java/dev/openrs2/deob/map/MemberRefKeyDeserializer.kt
  6. 2
      deob-processor/src/main/java/dev/openrs2/deob/processor/DeobfuscatorProcessorModule.kt

@ -30,4 +30,14 @@ data class MemberRef(val owner: String, val name: String, val desc: String) : Co
override fun toString(): String { override fun toString(): String {
return "$owner.$name $desc" return "$owner.$name $desc"
} }
companion object {
private val STRING_REGEX = Regex("([^.]+)[.]([^ ]+) (.+)")
fun fromString(str: String): MemberRef {
val result = STRING_REGEX.matchEntire(str)
require(result != null)
return MemberRef(result.groupValues[1], result.groupValues[2], result.groupValues[3])
}
}
} }

@ -5,6 +5,7 @@ plugins {
dependencies { dependencies {
api(project(":asm")) api(project(":asm"))
api(project(":yaml"))
} }
publishing { publishing {

@ -0,0 +1,12 @@
package dev.openrs2.deob.map
import com.fasterxml.jackson.databind.module.SimpleModule
import dev.openrs2.asm.MemberRef
import javax.inject.Singleton
@Singleton
class DeobfuscatorMapJacksonModule : SimpleModule() {
init {
addKeyDeserializer(MemberRef::class.java, MemberRefKeyDeserializer)
}
}

@ -0,0 +1,15 @@
package dev.openrs2.deob.map
import com.fasterxml.jackson.databind.Module
import com.google.inject.AbstractModule
import com.google.inject.multibindings.Multibinder
import dev.openrs2.yaml.YamlModule
object DeobfuscatorMapModule : AbstractModule() {
override fun configure() {
install(YamlModule)
Multibinder.newSetBinder(binder(), Module::class.java)
.addBinding().to(DeobfuscatorMapJacksonModule::class.java)
}
}

@ -0,0 +1,11 @@
package dev.openrs2.deob.map
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.KeyDeserializer
import dev.openrs2.asm.MemberRef
object MemberRefKeyDeserializer : KeyDeserializer() {
override fun deserializeKey(key: String, ctx: DeserializationContext): Any {
return MemberRef.fromString(key)
}
}

@ -1,10 +1,12 @@
package dev.openrs2.deob.processor package dev.openrs2.deob.processor
import com.google.inject.AbstractModule import com.google.inject.AbstractModule
import dev.openrs2.deob.map.DeobfuscatorMapModule
import dev.openrs2.yaml.YamlModule import dev.openrs2.yaml.YamlModule
object DeobfuscatorProcessorModule : AbstractModule() { object DeobfuscatorProcessorModule : AbstractModule() {
override fun configure() { override fun configure() {
install(DeobfuscatorMapModule)
install(YamlModule) install(YamlModule)
} }
} }

Loading…
Cancel
Save