refactor: extract input-api into library (#1821)
This commit is contained in:
@@ -3,6 +3,8 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":jadx-plugins:jadx-input-api"))
|
||||
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
|
||||
// TODO: move resources decoding to separate plugin module
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# jadx-input-api
|
||||
|
||||
Base API for code input used in jadx.
|
||||
|
||||
Contains common data structures to support both java and dex bytecode.
|
||||
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id 'jadx-library'
|
||||
}
|
||||
+4
-3
@@ -1,7 +1,8 @@
|
||||
package jadx.api.plugins.input.data.impl;
|
||||
|
||||
import jadx.api.plugins.input.data.ICatch;
|
||||
import jadx.api.plugins.utils.Utils;
|
||||
|
||||
import static jadx.api.plugins.input.data.impl.InputUtils.formatOffset;
|
||||
|
||||
public class CatchData implements ICatch {
|
||||
private final int[] handlers;
|
||||
@@ -34,10 +35,10 @@ public class CatchData implements ICatch {
|
||||
StringBuilder sb = new StringBuilder("Catch:");
|
||||
int size = types.length;
|
||||
for (int i = 0; i < size; i++) {
|
||||
sb.append(' ').append(types[i]).append("->").append(Utils.formatOffset(handlers[i]));
|
||||
sb.append(' ').append(types[i]).append("->").append(formatOffset(handlers[i]));
|
||||
}
|
||||
if (allHandler != -1) {
|
||||
sb.append(" all->").append(Utils.formatOffset(allHandler));
|
||||
sb.append(" all->").append(formatOffset(allHandler));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package jadx.api.plugins.input.data.impl;
|
||||
|
||||
public class InputUtils {
|
||||
public static String formatOffset(int offset) {
|
||||
return String.format("0x%04x", offset);
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -2,7 +2,8 @@ package jadx.api.plugins.input.data.impl;
|
||||
|
||||
import jadx.api.plugins.input.data.ICatch;
|
||||
import jadx.api.plugins.input.data.ITry;
|
||||
import jadx.api.plugins.utils.Utils;
|
||||
|
||||
import static jadx.api.plugins.input.data.impl.InputUtils.formatOffset;
|
||||
|
||||
public class TryData implements ITry {
|
||||
|
||||
@@ -33,6 +34,6 @@ public class TryData implements ITry {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Try{" + Utils.formatOffset(startOffset) + " - " + Utils.formatOffset(endOffset) + ": " + catchHandler + '}';
|
||||
return "Try{" + formatOffset(startOffset) + " - " + formatOffset(endOffset) + ": " + catchHandler + '}';
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ include("jadx-core")
|
||||
include("jadx-cli")
|
||||
include("jadx-gui")
|
||||
|
||||
include("jadx-plugins")
|
||||
include("jadx-plugins:jadx-input-api")
|
||||
include("jadx-plugins:jadx-dex-input")
|
||||
include("jadx-plugins:jadx-java-input")
|
||||
include("jadx-plugins:jadx-raung-input")
|
||||
|
||||
Reference in New Issue
Block a user