export "pcode with hex" and "only hex" options added

This commit is contained in:
Honfika
2013-10-15 21:50:00 +02:00
parent dbd1232df2
commit 3be09601c3
50 changed files with 401 additions and 237 deletions

View File

@@ -17,6 +17,7 @@
package com.jpexs.helpers;
import com.jpexs.decompiler.flash.gui.Freed;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.awt.Component;
@@ -548,6 +549,37 @@ public class Helper {
return timeStr;
}
public static HilightedTextWriter byteArrayToHex(HilightedTextWriter writer, byte[] data) {
writer.appendNoHilight("#hexdata").newLine();
/* // hex data from decompiled actions
Scanner scanner = new Scanner(srcWithHex);
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim();
if (line.startsWith(";")) {
result.append(line.substring(1).trim()).append(nl);
} else {
result.append(";").append(line).append(nl);
}
}*/
for (int i = 0; i < data.length; i++) {
if (i % 8 == 0) {
writer.newLine();
}
writer.appendNoHilight(String.format("%02x ", data[i]));
}
writer.newLine();
return writer;
}
public static String byteArrayToHex(byte[] data) {
HilightedTextWriter writer = new HilightedTextWriter(false);
byteArrayToHex(writer, data);
return writer.toString();
}
public static <T> T timedCall(Callable<T> c, long timeout, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
FutureTask<T> task = new FutureTask<>(c);
THREAD_POOL.execute(task);