From 3dcf91cfefd29f62757b53bdeb6e61a4973af034 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 9 May 2020 21:59:13 +0100 Subject: [PATCH] Move MemberRefKeyDeserializer to the asm module I'm going to use it in multiple places, so I think it makes sense to share it (at the expense of the asm module depending on the yaml module). Signed-off-by: Graham --- asm/build.gradle.kts | 2 ++ .../main/java/dev/openrs2/asm/AsmJacksonModule.kt | 5 ++--- asm/src/main/java/dev/openrs2/asm/AsmModule.kt | 15 +++++++++++++++ .../dev/openrs2/asm}/MemberRefKeyDeserializer.kt | 3 +-- deob-map/build.gradle.kts | 1 - .../dev/openrs2/deob/map/DeobfuscatorMapModule.kt | 9 ++------- 6 files changed, 22 insertions(+), 13 deletions(-) rename deob-map/src/main/java/dev/openrs2/deob/map/DeobfuscatorMapJacksonModule.kt => asm/src/main/java/dev/openrs2/asm/AsmJacksonModule.kt (62%) create mode 100644 asm/src/main/java/dev/openrs2/asm/AsmModule.kt rename {deob-map/src/main/java/dev/openrs2/deob/map => asm/src/main/java/dev/openrs2/asm}/MemberRefKeyDeserializer.kt (82%) diff --git a/asm/build.gradle.kts b/asm/build.gradle.kts index 03b920cb69..32e6c06012 100644 --- a/asm/build.gradle.kts +++ b/asm/build.gradle.kts @@ -5,6 +5,8 @@ plugins { dependencies { api(project(":util")) + api(project(":yaml")) + api("com.google.inject:guice:${Versions.guice}") api("org.ow2.asm:asm:${Versions.asm}") api("org.ow2.asm:asm-commons:${Versions.asm}") api("org.ow2.asm:asm-tree:${Versions.asm}") diff --git a/deob-map/src/main/java/dev/openrs2/deob/map/DeobfuscatorMapJacksonModule.kt b/asm/src/main/java/dev/openrs2/asm/AsmJacksonModule.kt similarity index 62% rename from deob-map/src/main/java/dev/openrs2/deob/map/DeobfuscatorMapJacksonModule.kt rename to asm/src/main/java/dev/openrs2/asm/AsmJacksonModule.kt index 955f319fec..8910dd1707 100644 --- a/deob-map/src/main/java/dev/openrs2/deob/map/DeobfuscatorMapJacksonModule.kt +++ b/asm/src/main/java/dev/openrs2/asm/AsmJacksonModule.kt @@ -1,11 +1,10 @@ -package dev.openrs2.deob.map +package dev.openrs2.asm import com.fasterxml.jackson.databind.module.SimpleModule -import dev.openrs2.asm.MemberRef import javax.inject.Singleton @Singleton -class DeobfuscatorMapJacksonModule : SimpleModule() { +class AsmJacksonModule : SimpleModule() { init { addKeyDeserializer(MemberRef::class.java, MemberRefKeyDeserializer) } diff --git a/asm/src/main/java/dev/openrs2/asm/AsmModule.kt b/asm/src/main/java/dev/openrs2/asm/AsmModule.kt new file mode 100644 index 0000000000..f28b730988 --- /dev/null +++ b/asm/src/main/java/dev/openrs2/asm/AsmModule.kt @@ -0,0 +1,15 @@ +package dev.openrs2.asm + +import com.fasterxml.jackson.databind.Module +import com.google.inject.AbstractModule +import com.google.inject.multibindings.Multibinder +import dev.openrs2.yaml.YamlModule + +object AsmModule : AbstractModule() { + override fun configure() { + install(YamlModule) + + Multibinder.newSetBinder(binder(), Module::class.java) + .addBinding().to(AsmJacksonModule::class.java) + } +} diff --git a/deob-map/src/main/java/dev/openrs2/deob/map/MemberRefKeyDeserializer.kt b/asm/src/main/java/dev/openrs2/asm/MemberRefKeyDeserializer.kt similarity index 82% rename from deob-map/src/main/java/dev/openrs2/deob/map/MemberRefKeyDeserializer.kt rename to asm/src/main/java/dev/openrs2/asm/MemberRefKeyDeserializer.kt index 5457d35b51..8561d27fa6 100644 --- a/deob-map/src/main/java/dev/openrs2/deob/map/MemberRefKeyDeserializer.kt +++ b/asm/src/main/java/dev/openrs2/asm/MemberRefKeyDeserializer.kt @@ -1,8 +1,7 @@ -package dev.openrs2.deob.map +package dev.openrs2.asm 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 { diff --git a/deob-map/build.gradle.kts b/deob-map/build.gradle.kts index 3192edb5eb..d531cb4a64 100644 --- a/deob-map/build.gradle.kts +++ b/deob-map/build.gradle.kts @@ -5,7 +5,6 @@ plugins { dependencies { api(project(":asm")) - api(project(":yaml")) } publishing { diff --git a/deob-map/src/main/java/dev/openrs2/deob/map/DeobfuscatorMapModule.kt b/deob-map/src/main/java/dev/openrs2/deob/map/DeobfuscatorMapModule.kt index 1c69d9c01b..91117d2e7b 100644 --- a/deob-map/src/main/java/dev/openrs2/deob/map/DeobfuscatorMapModule.kt +++ b/deob-map/src/main/java/dev/openrs2/deob/map/DeobfuscatorMapModule.kt @@ -1,17 +1,12 @@ package dev.openrs2.deob.map -import com.fasterxml.jackson.databind.Module import com.google.inject.AbstractModule import com.google.inject.Scopes -import com.google.inject.multibindings.Multibinder -import dev.openrs2.yaml.YamlModule +import dev.openrs2.asm.AsmModule object DeobfuscatorMapModule : AbstractModule() { override fun configure() { - install(YamlModule) - - Multibinder.newSetBinder(binder(), Module::class.java) - .addBinding().to(DeobfuscatorMapJacksonModule::class.java) + install(AsmModule) bind(NameMap::class.java) .toProvider(NameMapProvider::class.java)