Java code formatting, Interface action item block fixed

This commit is contained in:
Honfika
2014-02-25 18:51:10 +01:00
parent 1e3a67ec1c
commit da7ce42746
95 changed files with 1427 additions and 1332 deletions
@@ -2133,7 +2133,7 @@ public final class SWF implements TreeItem {
public static SerializableImage frameToImage(int containerId, int frame, List<Tag> allTags, List<Tag> controlTags, RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation) {
String key = "frame_" + frame + "_" + containerId + "_" + allTags.get(0).getSwf().hashCode();
SerializableImage image = getFromCache(key);
SerializableImage image = getFromCache(key);
if (image != null) {
return image;
}
@@ -2142,11 +2142,11 @@ public final class SWF implements TreeItem {
if (frameInfos.isEmpty()) {
return new SerializableImage(1, 1, SerializableImage.TYPE_INT_ARGB);
}
FrameInfo fi = frameInfos.get(0);
RECT rect = displayRect;
image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
(int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB);
Matrix m = new Matrix();
m.translate(-rect.Xmin, -rect.Ymin);
@@ -2275,15 +2275,15 @@ public final class SWF implements TreeItem {
}
}
}
return ret;
}
public static void framesToImage(int containerId, List<SerializableImage> ret, int startFrame, int stopFrame, List<Tag> allTags, List<Tag> controlTags, RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation) {
List<FrameInfo> frameInfos = getFrameInfo(startFrame, stopFrame, allTags, controlTags, totalFrameCount);
RECT rect = displayRect;
for (FrameInfo fi : frameInfos) {
SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
(int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB);
Matrix m = new Matrix();
m.translate(-rect.Xmin, -rect.Ymin);
@@ -2333,7 +2333,7 @@ public final class SWF implements TreeItem {
// needs the whole size because of the filters
img = new SerializableImage(image.getWidth(), image.getHeight(), SerializableImage.TYPE_INT_ARGB);
} else {
img = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
img = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
(int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB);
m.translate(-rect.xMin, -rect.yMin);
drawMatrix.translate(rect.xMin, rect.yMin);
@@ -2427,7 +2427,7 @@ public final class SWF implements TreeItem {
g.drawLine(r.Xmin / div, r.Ymin / div, r.Xmax / div, r.Ymax / div);
g.drawLine(r.Xmax / div, r.Ymin / div, r.Xmin / div, r.Ymax / div);
g.setComposite(AlphaComposite.Dst);
}
}
}
g.setTransform(AffineTransform.getScaleInstance(1, 1));
}
@@ -29,7 +29,6 @@ public class SourceGeneratorLocalData implements Serializable {
public Integer inFunction;
public Boolean inMethod;
public Integer forInLevel;
public SourceGeneratorLocalData(HashMap<String, Integer> registerVars, Integer inFunction, Boolean inMethod, Integer forInLevel) {
this.registerVars = registerVars;
@@ -188,7 +188,7 @@ public class ScriptPack implements TreeElementItem {
String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + ".as";
File file = new File(fileName);
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(),new FileOutputStream(file))) {
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(file))) {
try {
toSource(writer, abcList, abc.script_info[scriptIndex].traits.traits, exportMode, parallel);
} catch (InterruptedException ex) {
@@ -2247,7 +2247,7 @@ public class AVM2Code implements Serializable {
invalidateCache();
try {
List<Integer> outputMap = new ArrayList<>();
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
toASMSource(constants, trait, info, body, outputMap, ExportMode.PCODE, writer);
String src = writer.toString();
@@ -2289,7 +2289,7 @@ public class AVM2Code implements Serializable {
public void removeIgnored(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body) throws InterruptedException {
try {
List<Integer> outputMap = new ArrayList<>();
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
toASMSource(constants, trait, info, body, outputMap, ExportMode.PCODE, writer);
String src = writer.toString();
AVM2Code acode = ASM3Parser.parse(new StringReader(src), constants, trait, body, info);
@@ -41,7 +41,7 @@ public class NewClassIns extends InstructionDefinition {
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) throws InterruptedException {
int clsIndex = ins.operands[0];
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
stack.pop().toString(writer, LocalData.create(constants, localRegNames, fullyQualifiedNames));
String baseType = writer.toString();
stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.getMultiname(abc.instance_info[clsIndex].name_index).getName(constants, fullyQualifiedNames) + ".class extends " + baseType));
@@ -55,7 +55,7 @@ public class SetSuperIns extends InstructionDefinition implements SetTypeIns {
public String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, MethodBody body, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) throws InterruptedException {
int multinameIndex = ins.operands[0];
String multiname = resolveMultinameNoPop(1, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(writer, LocalData.create(abc.constants, localRegNames, fullyQualifiedNames));
String obj = writer.toString();
return obj + ".super." + multiname;
@@ -2742,6 +2742,7 @@ public final class Flasm3Lexer {
/**
* Closes the input stream.
*
* @throws java.io.IOException
*/
public final void yyclose() throws java.io.IOException {
@@ -2777,7 +2778,8 @@ public final class Flasm3Lexer {
/**
* Returns the current lexical state.
* @return
*
* @return
*/
public final int yystate() {
return zzLexicalState;
@@ -2794,7 +2796,8 @@ public final class Flasm3Lexer {
/**
* Returns the text matched by the current regular expression.
* @return
*
* @return
*/
public final String yytext() {
return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
@@ -2816,7 +2819,8 @@ public final class Flasm3Lexer {
/**
* Returns the length of the matched text region.
* @return
*
* @return
*/
public final int yylength() {
return zzMarkedPos - zzStartRead;
@@ -628,6 +628,7 @@ public final class MethodInfoLexer {
/**
* Closes the input stream.
*
* @throws java.io.IOException
*/
public final void yyclose() throws java.io.IOException {
@@ -663,7 +664,8 @@ public final class MethodInfoLexer {
/**
* Returns the current lexical state.
* @return
*
* @return
*/
public final int yystate() {
return zzLexicalState;
@@ -680,7 +682,8 @@ public final class MethodInfoLexer {
/**
* Returns the text matched by the current regular expression.
* @return
*
* @return
*/
public final String yytext() {
return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
@@ -702,7 +705,8 @@ public final class MethodInfoLexer {
/**
* Returns the length of the matched text region.
* @return
*
* @return
*/
public final int yylength() {
return zzMarkedPos - zzStartRead;
@@ -50,7 +50,7 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
}
((TraitSlotConst) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<String>(), false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
writer.appendNoHilight(super.toString(abcTags, abc) + " ");
if (parentTraitIndex > -1) {
if (isStatic) {
@@ -58,7 +58,7 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage {
((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, nulWriter, new ArrayList<String>(), false);
}
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
writer.appendNoHilight(super.toString(abcTags, abc));
writer.appendNoHilight(" ");
if (isInitializer) {
@@ -1213,7 +1213,7 @@ public class Action implements GraphSourceItem {
}
String s = null;
try {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
Action.actionsToString(new ArrayList<DisassemblyListener>(), address, ret, null, version, ExportMode.PCODE, writer, swfPos, path);
s = writer.toString();
ret = ASMParser.parse(address, swfPos, true, s, SWF.DEFAULT_VERSION, false);
@@ -1268,12 +1268,12 @@ public class Action implements GraphSourceItem {
return 0;
}
public static GraphTargetItem gettoset(GraphTargetItem get, GraphTargetItem value,List<VariableActionItem> variables) {
public static GraphTargetItem gettoset(GraphTargetItem get, GraphTargetItem value, List<VariableActionItem> variables) {
GraphTargetItem ret = get;
boolean boxed = false;
if(get instanceof VariableActionItem){
if (get instanceof VariableActionItem) {
boxed = true;
ret = ((VariableActionItem)ret).getBoxedValue();
ret = ((VariableActionItem) ret).getBoxedValue();
}
if (ret instanceof GetVariableActionItem) {
GetVariableActionItem gv = (GetVariableActionItem) ret;
@@ -1287,12 +1287,12 @@ public class Action implements GraphSourceItem {
GetPropertyActionItem gp = (GetPropertyActionItem) ret;
ret = new SetPropertyActionItem(null, gp.target, gp.propertyIndex, value);
}
if(boxed){
GraphTargetItem b=ret;
ret = new VariableActionItem(((VariableActionItem)get).getVariableName(), value,((VariableActionItem)get).isDefinition());
((VariableActionItem)ret).setBoxedValue((ActionItem)b);
variables.remove((VariableActionItem)get);
variables.add((VariableActionItem)ret);
if (boxed) {
GraphTargetItem b = ret;
ret = new VariableActionItem(((VariableActionItem) get).getVariableName(), value, ((VariableActionItem) get).isDefinition());
((VariableActionItem) ret).setBoxedValue((ActionItem) b);
variables.remove((VariableActionItem) get);
variables.add((VariableActionItem) ret);
}
return ret;
}
@@ -531,7 +531,7 @@ public class ActionListReader {
* @param index
* @param version
* @param removeWhenLast
* @return
* @return
*/
public static boolean removeAction(List<Action> actions, int index, int version, boolean removeWhenLast) {
@@ -100,7 +100,7 @@ public class FunctionActionItem extends ActionItem {
writer.append(")").startBlock();
Graph.graphToString(actions, writer, localData);
return writer.endBlock();
}
@@ -51,8 +51,8 @@ public class InitObjectActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append("{");
for (int i = values.size()-1;i>=0; i--) {
if (i < values.size()-1) {
for (int i = values.size() - 1; i >= 0; i--) {
if (i < values.size() - 1) {
writer.append(",");
}
names.get(i).toStringNoQuotes(writer, localData); //AS1/2 do not allow quotes in name here
@@ -103,7 +103,7 @@ public class NewMethodActionItem extends ActionItem {
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) {
return toSourceMerge(localData, generator, toSourceCall(localData, generator, arguments), scriptObject, methodName, new ActionNewMethod());
}
@Override
public boolean hasReturnValue() {
return true;
@@ -56,7 +56,7 @@ public class UnLoadMovieActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) {
return toSourceMerge(localData, generator, new ActionPush(""), targetString, new ActionGetURL2(0, false,true));
return toSourceMerge(localData, generator, new ActionPush(""), targetString, new ActionGetURL2(0, false, true));
}
@Override
@@ -195,7 +195,6 @@ public class ClassActionItem extends ActionItem implements Block {
f.toString(writer, localData).newLine();
}
return writer.endBlock();
}
@@ -50,7 +50,7 @@ public class IfFrameLoadedActionItem extends ActionItem implements Block {
writer.append("ifFrameLoaded(");
frame.toString(writer, localData);
writer.append(")").startBlock();
Graph.graphToString(actions, writer, localData);
Graph.graphToString(actions, writer, localData);
return writer.endBlock();
}
@@ -59,7 +59,7 @@ public class InterfaceActionItem extends ActionItem {
Action.getWithoutGlobal(ti).toStringNoQuotes(writer, localData);
}
writer.newLine();
return writer.append("{").startBlock();
return writer.startBlock().endBlock();
}
@Override
@@ -632,6 +632,7 @@ public final class FlasmLexer {
/**
* Closes the input stream.
*
* @throws java.io.IOException
*/
public final void yyclose() throws java.io.IOException {
@@ -667,7 +668,8 @@ public final class FlasmLexer {
/**
* Returns the current lexical state.
* @return
*
* @return
*/
public final int yystate() {
return zzLexicalState;
@@ -684,7 +686,8 @@ public final class FlasmLexer {
/**
* Returns the text matched by the current regular expression.
* @return
*
* @return
*/
public final String yytext() {
return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
@@ -706,7 +709,8 @@ public final class FlasmLexer {
/**
* Returns the length of the matched text region.
* @return
*
* @return
*/
public final int yylength() {
return zzMarkedPos - zzStartRead;
@@ -492,8 +492,8 @@ public class ActionSourceGenerator implements SourceGenerator {
}
private String getName(GraphTargetItem item) {
if(item instanceof VariableActionItem){
return ((VariableActionItem)item).getVariableName();
if (item instanceof VariableActionItem) {
return ((VariableActionItem) item).getVariableName();
}
if (item instanceof DirectValueActionItem) {
DirectValueActionItem dv = (DirectValueActionItem) item;
@@ -58,7 +58,7 @@ public class VariableActionItem extends ActionItem {
public void setBoxedValue(ActionItem it) {
this.it = it;
if(it!=null){
if (it != null) {
this.precedence = it.getPrecedence();
}
}
@@ -111,5 +111,5 @@ public class VariableActionItem extends ActionItem {
}
return it.needsSemicolon();
}
}
@@ -50,7 +50,7 @@ public class ActionGetURL2 extends Action {
public boolean loadVariablesFlag;
public int reserved;
public ActionGetURL2(int sendVarsMethod, boolean loadVariablesFlag, boolean loadTargetFlag) {
public ActionGetURL2(int sendVarsMethod, boolean loadVariablesFlag, boolean loadTargetFlag) {
super(0x9A, 1);
this.loadTargetFlag = loadTargetFlag;
this.loadVariablesFlag = loadVariablesFlag;
@@ -88,7 +88,7 @@ public class ActionGetURL2 extends Action {
public ActionGetURL2(FlasmLexer lexer) throws IOException, ParseException {
super(0x9A, -1);
loadVariablesFlag = lexBoolean(lexer);
loadTargetFlag = lexBoolean(lexer);
loadTargetFlag = lexBoolean(lexer);
sendVarsMethod = (int) lexLong(lexer);
}
@@ -298,7 +298,7 @@ public class ActionPush extends Action {
@Override
public String toString() {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
toString(writer);
return writer.toString();
}
@@ -46,12 +46,13 @@ public class RegisterNumber implements Serializable {
return true;
}
public RegisterNumber(int number,String name) {
public RegisterNumber(int number, String name) {
this.number = number;
this.name = name;
}
public RegisterNumber(int number) {
this(number,null);
this(number, null);
}
@Override
@@ -203,7 +203,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
@Override
public void translateContainer(List<List<GraphTargetItem>> content, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, 1,new ArrayList<VariableActionItem>());
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, 1, new ArrayList<VariableActionItem>());
//ActionGraph.translateViaGraph(regNames, variables, functions, code, version)
stack.push(fti);
functions.put(functionName, fti);
@@ -342,7 +342,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
@Override
public void translateContainer(List<List<GraphTargetItem>> content, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, getFirstRegister(),new ArrayList<VariableActionItem>());
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, getFirstRegister(), new ArrayList<VariableActionItem>());
functions.put(functionName, fti);
stack.push(fti);
}
@@ -49,515 +49,516 @@ import javax.swing.JOptionPane;
public class Configuration {
private static final String CONFIG_NAME = "config.bin";
private static final String REPLACEMENTS_NAME = "replacements.cfg";
private static final File unspecifiedFile = new File("unspecified");
private static File directory = unspecifiedFile;
private static final String CONFIG_NAME = "config.bin";
private static final String REPLACEMENTS_NAME = "replacements.cfg";
private static final File unspecifiedFile = new File("unspecified");
private static File directory = unspecifiedFile;
/**
* List of replacements
*/
private static List<Replacement> replacements = new ArrayList<>();
/**
* List of replacements
*/
private static List<Replacement> replacements = new ArrayList<>();
public static final Level logLevel;
public static final Level logLevel;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> openMultipleFiles = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> decompile = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> parallelSpeedUp = null;
@ConfigurationDefaultInt(20)
public static final ConfigurationItem<Integer> parallelThreadCount = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> autoDeobfuscate = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> cacheOnDisk = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> internalFlashViewer = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> gotoMainClassOnStartup = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> autoRenameIdentifiers = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> deobfuscateUsePrevTagOnly = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> offeredAssociation = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> removeNops = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> showHexOnlyButton = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> decimalAddress = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> showAllAddresses = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> useFrameCache = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> useRibbonInterface = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> openFolderAfterFlaExport = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> useDetailedLogging = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> openMultipleFiles = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> decompile = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> parallelSpeedUp = null;
@ConfigurationDefaultInt(20)
public static final ConfigurationItem<Integer> parallelThreadCount = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> autoDeobfuscate = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> cacheOnDisk = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> internalFlashViewer = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> gotoMainClassOnStartup = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> autoRenameIdentifiers = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> deobfuscateUsePrevTagOnly = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> offeredAssociation = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> removeNops = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> showHexOnlyButton = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> decimalAddress = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> showAllAddresses = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> useFrameCache = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> useRibbonInterface = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> openFolderAfterFlaExport = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> useDetailedLogging = null;
/**
* Debug mode = throwing an error when comparing original file and recompiled
*/
@ConfigurationDefaultBoolean(false)
@ConfigurationDescription("Debug mode = throwing an error when comparing original file and recompiled")
public static final ConfigurationItem<Boolean> debugMode = null;
/**
* Turn off reading unsafe tags (tags which can cause problems with
* recompiling)
*/
@ConfigurationDefaultBoolean(false)
@ConfigurationDescription("Turn off reading unsafe tags (tags which can cause problems with recompiling)")
public static final ConfigurationItem<Boolean> disableDangerous = null;
/**
* Turn off resolving constants in ActionScript 2
*/
@ConfigurationDefaultBoolean(true)
@ConfigurationDescription("Turn off resolving constants in ActionScript 2")
public static final ConfigurationItem<Boolean> resolveConstants = null;
/**
* Limit of code subs (for obfuscated code)
*/
@ConfigurationDefaultInt(500)
@ConfigurationDescription("Limit of code subs (for obfuscated code)")
public static final ConfigurationItem<Integer> sublimiter = null;
/**
* Total export timeout in seconds
*/
@ConfigurationDefaultInt(30 * 60)
@ConfigurationDescription("Total export timeout in seconds")
public static final ConfigurationItem<Integer> exportTimeout = null;
/**
* Decompilation timeout in seconds for a single file
*/
@ConfigurationDefaultInt(5 * 60)
@ConfigurationDescription("Decompilation timeout in seconds for a single file")
public static final ConfigurationItem<Integer> decompilationTimeoutFile = null;
/**
* Using parameter names in decompiling may cause problems because official
* programs like Flash CS 5.5 inserts wrong parameter names indices
*/
@ConfigurationDefaultBoolean(false)
@ConfigurationDescription("Using parameter names in decompiling may cause problems because official programs like Flash CS 5.5 inserts wrong parameter names indices")
public static final ConfigurationItem<Boolean> paramNamesEnable = null;
/**
* Debug mode = throwing an error when comparing original file and
* recompiled
*/
@ConfigurationDefaultBoolean(false)
@ConfigurationDescription("Debug mode = throwing an error when comparing original file and recompiled")
public static final ConfigurationItem<Boolean> debugMode = null;
/**
* Turn off reading unsafe tags (tags which can cause problems with
* recompiling)
*/
@ConfigurationDefaultBoolean(false)
@ConfigurationDescription("Turn off reading unsafe tags (tags which can cause problems with recompiling)")
public static final ConfigurationItem<Boolean> disableDangerous = null;
/**
* Turn off resolving constants in ActionScript 2
*/
@ConfigurationDefaultBoolean(true)
@ConfigurationDescription("Turn off resolving constants in ActionScript 2")
public static final ConfigurationItem<Boolean> resolveConstants = null;
/**
* Limit of code subs (for obfuscated code)
*/
@ConfigurationDefaultInt(500)
@ConfigurationDescription("Limit of code subs (for obfuscated code)")
public static final ConfigurationItem<Integer> sublimiter = null;
/**
* Total export timeout in seconds
*/
@ConfigurationDefaultInt(30 * 60)
@ConfigurationDescription("Total export timeout in seconds")
public static final ConfigurationItem<Integer> exportTimeout = null;
/**
* Decompilation timeout in seconds for a single file
*/
@ConfigurationDefaultInt(5 * 60)
@ConfigurationDescription("Decompilation timeout in seconds for a single file")
public static final ConfigurationItem<Integer> decompilationTimeoutFile = null;
/**
* Using parameter names in decompiling may cause problems because official
* programs like Flash CS 5.5 inserts wrong parameter names indices
*/
@ConfigurationDefaultBoolean(false)
@ConfigurationDescription("Using parameter names in decompiling may cause problems because official programs like Flash CS 5.5 inserts wrong parameter names indices")
public static final ConfigurationItem<Boolean> paramNamesEnable = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> displayFileName = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> debugCopy = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> dumpTags = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> displayFileName = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> debugCopy = null;
@ConfigurationDefaultBoolean(false)
public static final ConfigurationItem<Boolean> dumpTags = null;
@ConfigurationDefaultInt(60)
public static final ConfigurationItem<Integer> decompilationTimeoutSingleMethod = null;
@ConfigurationDefaultInt(1)
public static final ConfigurationItem<Integer> lastRenameType = null;
@ConfigurationDefaultInt(60)
public static final ConfigurationItem<Integer> decompilationTimeoutSingleMethod = null;
@ConfigurationDefaultInt(1)
public static final ConfigurationItem<Integer> lastRenameType = null;
@ConfigurationDefaultString(".")
public static final ConfigurationItem<String> lastSaveDir = null;
@ConfigurationDefaultString(".")
public static final ConfigurationItem<String> lastOpenDir = null;
@ConfigurationDefaultString(".")
public static final ConfigurationItem<String> lastExportDir = null;
@ConfigurationDefaultString("en")
public static final ConfigurationItem<String> locale = null;
@ConfigurationDefaultString("_loc%d_")
public static final ConfigurationItem<String> registerNameFormat = null;
@ConfigurationDefaultInt(8)
public static final ConfigurationItem<Integer> maxRecentFileCount = null;
public static final ConfigurationItem<String> recentFiles = null;
public static final ConfigurationItem<String> fontPairing = null;
@ConfigurationDefaultString(".")
public static final ConfigurationItem<String> lastSaveDir = null;
@ConfigurationDefaultString(".")
public static final ConfigurationItem<String> lastOpenDir = null;
@ConfigurationDefaultString(".")
public static final ConfigurationItem<String> lastExportDir = null;
@ConfigurationDefaultString("en")
public static final ConfigurationItem<String> locale = null;
@ConfigurationDefaultString("_loc%d_")
public static final ConfigurationItem<String> registerNameFormat = null;
@ConfigurationDefaultInt(8)
public static final ConfigurationItem<Integer> maxRecentFileCount = null;
public static final ConfigurationItem<String> recentFiles = null;
public static final ConfigurationItem<String> fontPairing = null;
public static final ConfigurationItem<Calendar> lastUpdatesCheckDate = null;
public static final ConfigurationItem<Calendar> lastUpdatesCheckDate = null;
@ConfigurationDefaultInt(1000)
@ConfigurationName("gui.window.width")
public static final ConfigurationItem<Integer> guiWindowWidth = null;
@ConfigurationDefaultInt(700)
@ConfigurationName("gui.window.height")
public static final ConfigurationItem<Integer> guiWindowHeight = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationName("gui.window.maximized.horizontal")
public static final ConfigurationItem<Boolean> guiWindowMaximizedHorizontal = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationName("gui.window.maximized.vertical")
public static final ConfigurationItem<Boolean> guiWindowMaximizedVertical = null;
@ConfigurationName("gui.avm2.splitPane.dividerLocation")
public static final ConfigurationItem<Integer> guiAvm2SplitPaneDividerLocation = null;
@ConfigurationName("guiActionSplitPaneDividerLocation")
public static final ConfigurationItem<Integer> guiActionSplitPaneDividerLocation = null;
@ConfigurationName("guiPreviewSplitPaneDividerLocation")
public static final ConfigurationItem<Integer> guiPreviewSplitPaneDividerLocation = null;
@ConfigurationName("gui.splitPane1.dividerLocation")
public static final ConfigurationItem<Integer> guiSplitPane1DividerLocation = null;
@ConfigurationName("gui.splitPane2.dividerLocation")
public static final ConfigurationItem<Integer> guiSplitPane2DividerLocation = null;
@ConfigurationDefaultInt(3)
public static final ConfigurationItem<Integer> saveAsExeScaleMode = null;
@ConfigurationDefaultInt(1024 * 100/*100KB*/)
public static final ConfigurationItem<Integer> syntaxHighlightLimit = null;
public static final ConfigurationItem<Integer> guiFontPreviewSampleText = null;
@ConfigurationName("gui.fontPreviewWindow.width")
public static final ConfigurationItem<Integer> guiFontPreviewWidth = null;
@ConfigurationName("gui.fontPreviewWindow.height")
public static final ConfigurationItem<Integer> guiFontPreviewHeight = null;
@ConfigurationName("gui.fontPreviewWindow.posX")
public static final ConfigurationItem<Integer> guiFontPreviewPosX = null;
@ConfigurationName("gui.fontPreviewWindow.posY")
public static final ConfigurationItem<Integer> guiFontPreviewPosY = null;
@ConfigurationDefaultInt(1000)
@ConfigurationName("gui.window.width")
public static final ConfigurationItem<Integer> guiWindowWidth = null;
@ConfigurationDefaultInt(700)
@ConfigurationName("gui.window.height")
public static final ConfigurationItem<Integer> guiWindowHeight = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationName("gui.window.maximized.horizontal")
public static final ConfigurationItem<Boolean> guiWindowMaximizedHorizontal = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationName("gui.window.maximized.vertical")
public static final ConfigurationItem<Boolean> guiWindowMaximizedVertical = null;
@ConfigurationName("gui.avm2.splitPane.dividerLocation")
public static final ConfigurationItem<Integer> guiAvm2SplitPaneDividerLocation = null;
@ConfigurationName("guiActionSplitPaneDividerLocation")
public static final ConfigurationItem<Integer> guiActionSplitPaneDividerLocation = null;
@ConfigurationName("guiPreviewSplitPaneDividerLocation")
public static final ConfigurationItem<Integer> guiPreviewSplitPaneDividerLocation = null;
@ConfigurationName("gui.splitPane1.dividerLocation")
public static final ConfigurationItem<Integer> guiSplitPane1DividerLocation = null;
@ConfigurationName("gui.splitPane2.dividerLocation")
public static final ConfigurationItem<Integer> guiSplitPane2DividerLocation = null;
@ConfigurationDefaultInt(3)
public static final ConfigurationItem<Integer> saveAsExeScaleMode = null;
@ConfigurationDefaultInt(1024 * 100/*100KB*/)
public static final ConfigurationItem<Integer> syntaxHighlightLimit = null;
public static final ConfigurationItem<Integer> guiFontPreviewSampleText = null;
@ConfigurationName("gui.fontPreviewWindow.width")
public static final ConfigurationItem<Integer> guiFontPreviewWidth = null;
@ConfigurationName("gui.fontPreviewWindow.height")
public static final ConfigurationItem<Integer> guiFontPreviewHeight = null;
@ConfigurationName("gui.fontPreviewWindow.posX")
public static final ConfigurationItem<Integer> guiFontPreviewPosX = null;
@ConfigurationName("gui.fontPreviewWindow.posY")
public static final ConfigurationItem<Integer> guiFontPreviewPosY = null;
@ConfigurationDefaultInt(3)
@ConfigurationName("formatting.indent.size")
@ConfigurationDescription("Number or spaces(or tabs) for one indentation")
public static final ConfigurationItem<Integer> indentSize = null;
@ConfigurationDefaultInt(3)
@ConfigurationName("formatting.indent.size")
@ConfigurationDescription("Number or spaces(or tabs) for one indentation")
public static final ConfigurationItem<Integer> indentSize = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationName("formatting.indent.useTabs")
@ConfigurationDescription("Use tabs instead of spaces for indentation")
public static final ConfigurationItem<Boolean> indentUseTabs = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationName("formatting.indent.useTabs")
@ConfigurationDescription("Use tabs instead of spaces for indentation")
public static final ConfigurationItem<Boolean> indentUseTabs = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> beginBlockOnNewLine = null;
private enum OSId {
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> beginBlockOnNewLine = null;
WINDOWS, OSX, UNIX
}
private enum OSId {
private static OSId getOSId() {
PrivilegedAction<String> doGetOSName = new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty("os.name");
}
};
OSId id = OSId.UNIX;
String osName = AccessController.doPrivileged(doGetOSName);
if (osName != null) {
if (osName.toLowerCase().startsWith("mac os x")) {
id = OSId.OSX;
} else if (osName.contains("Windows")) {
id = OSId.WINDOWS;
}
}
return id;
}
WINDOWS, OSX, UNIX
}
public static String getFFDecHome() throws IOException {
if (directory == unspecifiedFile) {
directory = null;
String userHome = null;
try {
userHome = System.getProperty("user.home");
} catch (SecurityException ignore) {
}
if (userHome != null) {
String applicationId = ApplicationInfo.SHORT_APPLICATION_NAME;
OSId osId = getOSId();
if (osId == OSId.WINDOWS) {
File appDataDir = null;
try {
String appDataEV = System.getenv("APPDATA");
if ((appDataEV != null) && (appDataEV.length() > 0)) {
appDataDir = new File(appDataEV);
}
} catch (SecurityException ignore) {
}
String vendorId = ApplicationInfo.VENDOR;
if ((appDataDir != null) && appDataDir.isDirectory()) {
// ${APPDATA}\{vendorId}\${applicationId}
String path = vendorId + "\\" + applicationId + "\\";
directory = new File(appDataDir, path);
} else {
// ${userHome}\Application Data\${vendorId}\${applicationId}
String path = "Application Data\\" + vendorId + "\\" + applicationId + "\\";
directory = new File(userHome, path);
}
} else if (osId == OSId.OSX) {
// ${userHome}/Library/Application Support/${applicationId}
String path = "Library/Application Support/" + applicationId + "/";
directory = new File(userHome, path);
} else {
// ${userHome}/.${applicationId}/
String path = "." + applicationId + "/";
directory = new File(userHome, path);
private static OSId getOSId() {
PrivilegedAction<String> doGetOSName = new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty("os.name");
}
}
}
if (!directory.exists()) {
if (!directory.mkdirs()) {
if (!directory.exists()) {
throw new IOException("cannot create directory " + directory);
};
OSId id = OSId.UNIX;
String osName = AccessController.doPrivileged(doGetOSName);
if (osName != null) {
if (osName.toLowerCase().startsWith("mac os x")) {
id = OSId.OSX;
} else if (osName.contains("Windows")) {
id = OSId.WINDOWS;
}
}
}
String ret = directory.getAbsolutePath();
if (!ret.endsWith(File.separator)) {
ret += File.separator;
}
return ret;
}
}
return id;
}
public static List<String> getRecentFiles() {
String files = recentFiles.get();
if (files == null || files.isEmpty()) {
return new ArrayList<>();
}
return Arrays.asList(files.split("::"));
}
public static void addRecentFile(String path) {
List<String> recentFilesArray = new ArrayList<>(getRecentFiles());
int idx = recentFilesArray.indexOf(path);
if (idx != -1) {
recentFilesArray.remove(idx);
}
recentFilesArray.add(path);
while (recentFilesArray.size() >= maxRecentFileCount.get()) {
recentFilesArray.remove(0);
}
recentFiles.set(Helper.joinStrings(recentFilesArray, "::"));
}
public static void removeRecentFile(String path) {
List<String> recentFilesArray = new ArrayList<>(getRecentFiles());
int idx = recentFilesArray.indexOf(path);
if (idx != -1) {
recentFilesArray.remove(idx);
}
recentFiles.set(Helper.joinStrings(recentFilesArray, "::"));
}
public static Map<String, String> getFontPairs() {
String fonts = fontPairing.get();
if (fonts == null) {
return new HashMap<>();
}
Map<String, String> result = new HashMap<>();
for (String pair : fonts.split("::")) {
String[] splittedPair = pair.split("=");
result.put(splittedPair[0], splittedPair[1]);
}
return result;
}
public static void addFontPair(String fileName, int fontId, String fontName, String systemFontName) {
String key = fileName + "_" + fontId + "_" + fontName;
Map<String, String> fontPairs = getFontPairs();
fontPairs.put(key, systemFontName);
fontPairs.put(fontName, systemFontName);
StringBuilder sb = new StringBuilder();
int i = 0;
for (Entry<String, String> pair : fontPairs.entrySet()) {
if (i != 0) {
sb.append("::");
}
sb.append(pair.getKey()).append("=").append(pair.getValue());
i++;
}
fontPairing.set(sb.toString());
}
/**
* Saves replacements to file for future use
*/
private static void saveReplacements(String replacementsFile) {
if (replacements.isEmpty()) {
File rf = new File(replacementsFile);
if (rf.exists()) {
if (!rf.delete()) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, "Cannot delete replacements file");
public static String getFFDecHome() throws IOException {
if (directory == unspecifiedFile) {
directory = null;
String userHome = null;
try {
userHome = System.getProperty("user.home");
} catch (SecurityException ignore) {
}
}
} else {
try (PrintWriter pw = new PrintWriter(new Utf8OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(replacementsFile))))) {
for (Replacement r : replacements) {
pw.println(r.urlPattern);
pw.println(r.targetFile);
if (userHome != null) {
String applicationId = ApplicationInfo.SHORT_APPLICATION_NAME;
OSId osId = getOSId();
if (osId == OSId.WINDOWS) {
File appDataDir = null;
try {
String appDataEV = System.getenv("APPDATA");
if ((appDataEV != null) && (appDataEV.length() > 0)) {
appDataDir = new File(appDataEV);
}
} catch (SecurityException ignore) {
}
String vendorId = ApplicationInfo.VENDOR;
if ((appDataDir != null) && appDataDir.isDirectory()) {
// ${APPDATA}\{vendorId}\${applicationId}
String path = vendorId + "\\" + applicationId + "\\";
directory = new File(appDataDir, path);
} else {
// ${userHome}\Application Data\${vendorId}\${applicationId}
String path = "Application Data\\" + vendorId + "\\" + applicationId + "\\";
directory = new File(userHome, path);
}
} else if (osId == OSId.OSX) {
// ${userHome}/Library/Application Support/${applicationId}
String path = "Library/Application Support/" + applicationId + "/";
directory = new File(userHome, path);
} else {
// ${userHome}/.${applicationId}/
String path = "." + applicationId + "/";
directory = new File(userHome, path);
}
}
} catch (IOException ex) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, "Exception during saving replacements", ex);
}
}
}
/**
* Load replacements from file
*/
private static void loadReplacements(String replacementsFile) {
if (!(new File(replacementsFile)).exists()) {
return;
}
replacements = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new Utf8InputStreamReader(new FileInputStream(replacementsFile)))) {
String s;
while ((s = br.readLine()) != null) {
Replacement r = new Replacement(s, br.readLine());
replacements.add(r);
}
} catch (IOException e) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, "Error during load replacements", e);
}
}
private static String getReplacementsFile() throws IOException {
return getFFDecHome() + REPLACEMENTS_NAME;
}
private static String getConfigFile() throws IOException {
return getFFDecHome() + CONFIG_NAME;
}
private static HashMap<String, Object> loadFromFile(String file, String replacementsFile) {
HashMap<String, Object> config = new HashMap<>();
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) {
@SuppressWarnings("unchecked")
HashMap<String, Object> cfg = (HashMap<String, Object>) ois.readObject();
config = cfg;
} catch (FileNotFoundException ex) {
} catch (ClassNotFoundException cnf) {
} catch (IOException ex) {
}
if (replacementsFile != null) {
loadReplacements(replacementsFile);
}
if (config.containsKey("paralelSpeedUp")) {
config.put("parallelSpeedUp", config.get("paralelSpeedUp"));
config.remove("paralelSpeedUp");
}
return config;
}
private static void saveToFile(String file, String replacementsFile) {
HashMap<String, Object> config = new HashMap<>();
for (Entry<String, Field> entry : getConfigurationFields().entrySet()) {
try {
String name = entry.getKey();
Field field = entry.getValue();
ConfigurationItem item = (ConfigurationItem) field.get(null);
if (item.hasValue) {
config.put(name, item.get());
}
if (!directory.exists()) {
if (!directory.mkdirs()) {
if (!directory.exists()) {
throw new IOException("cannot create directory " + directory);
}
}
} catch (IllegalArgumentException | IllegalAccessException ex) {
}
String ret = directory.getAbsolutePath();
if (!ret.endsWith(File.separator)) {
ret += File.separator;
}
return ret;
}
public static List<String> getRecentFiles() {
String files = recentFiles.get();
if (files == null || files.isEmpty()) {
return new ArrayList<>();
}
return Arrays.asList(files.split("::"));
}
public static void addRecentFile(String path) {
List<String> recentFilesArray = new ArrayList<>(getRecentFiles());
int idx = recentFilesArray.indexOf(path);
if (idx != -1) {
recentFilesArray.remove(idx);
}
recentFilesArray.add(path);
while (recentFilesArray.size() >= maxRecentFileCount.get()) {
recentFilesArray.remove(0);
}
recentFiles.set(Helper.joinStrings(recentFilesArray, "::"));
}
public static void removeRecentFile(String path) {
List<String> recentFilesArray = new ArrayList<>(getRecentFiles());
int idx = recentFilesArray.indexOf(path);
if (idx != -1) {
recentFilesArray.remove(idx);
}
recentFiles.set(Helper.joinStrings(recentFilesArray, "::"));
}
public static Map<String, String> getFontPairs() {
String fonts = fontPairing.get();
if (fonts == null) {
return new HashMap<>();
}
Map<String, String> result = new HashMap<>();
for (String pair : fonts.split("::")) {
String[] splittedPair = pair.split("=");
result.put(splittedPair[0], splittedPair[1]);
}
return result;
}
public static void addFontPair(String fileName, int fontId, String fontName, String systemFontName) {
String key = fileName + "_" + fontId + "_" + fontName;
Map<String, String> fontPairs = getFontPairs();
fontPairs.put(key, systemFontName);
fontPairs.put(fontName, systemFontName);
StringBuilder sb = new StringBuilder();
int i = 0;
for (Entry<String, String> pair : fontPairs.entrySet()) {
if (i != 0) {
sb.append("::");
}
sb.append(pair.getKey()).append("=").append(pair.getValue());
i++;
}
fontPairing.set(sb.toString());
}
/**
* Saves replacements to file for future use
*/
private static void saveReplacements(String replacementsFile) {
if (replacements.isEmpty()) {
File rf = new File(replacementsFile);
if (rf.exists()) {
if (!rf.delete()) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, "Cannot delete replacements file");
}
}
} else {
try (PrintWriter pw = new PrintWriter(new Utf8OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(replacementsFile))))) {
for (Replacement r : replacements) {
pw.println(r.urlPattern);
pw.println(r.targetFile);
}
} catch (IOException ex) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, "Exception during saving replacements", ex);
}
}
}
/**
* Load replacements from file
*/
private static void loadReplacements(String replacementsFile) {
if (!(new File(replacementsFile)).exists()) {
return;
}
replacements = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new Utf8InputStreamReader(new FileInputStream(replacementsFile)))) {
String s;
while ((s = br.readLine()) != null) {
Replacement r = new Replacement(s, br.readLine());
replacements.add(r);
}
} catch (IOException e) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, "Error during load replacements", e);
}
}
private static String getReplacementsFile() throws IOException {
return getFFDecHome() + REPLACEMENTS_NAME;
}
private static String getConfigFile() throws IOException {
return getFFDecHome() + CONFIG_NAME;
}
private static HashMap<String, Object> loadFromFile(String file, String replacementsFile) {
HashMap<String, Object> config = new HashMap<>();
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) {
@SuppressWarnings("unchecked")
HashMap<String, Object> cfg = (HashMap<String, Object>) ois.readObject();
config = cfg;
} catch (FileNotFoundException ex) {
} catch (ClassNotFoundException cnf) {
} catch (IOException ex) {
}
if (replacementsFile != null) {
loadReplacements(replacementsFile);
}
if (config.containsKey("paralelSpeedUp")) {
config.put("parallelSpeedUp", config.get("paralelSpeedUp"));
config.remove("paralelSpeedUp");
}
return config;
}
private static void saveToFile(String file, String replacementsFile) {
HashMap<String, Object> config = new HashMap<>();
for (Entry<String, Field> entry : getConfigurationFields().entrySet()) {
try {
String name = entry.getKey();
Field field = entry.getValue();
ConfigurationItem item = (ConfigurationItem) field.get(null);
if (item.hasValue) {
config.put(name, item.get());
}
} catch (IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
}
}
try (ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)))) {
oos.writeObject(config);
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "Cannot save configuration.", "Error", JOptionPane.ERROR_MESSAGE);
Logger.getLogger(Configuration.class.getName()).severe("Configuration directory is read only.");
}
if (replacementsFile != null) {
saveReplacements(replacementsFile);
}
}
public static List<Replacement> getReplacements() {
return replacements;
}
public static void saveConfig() {
try {
saveToFile(getConfigFile(), getReplacementsFile());
} catch (IOException ex) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
}
}
try (ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)))) {
oos.writeObject(config);
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "Cannot save configuration.", "Error", JOptionPane.ERROR_MESSAGE);
Logger.getLogger(Configuration.class.getName()).severe("Configuration directory is read only.");
}
if (replacementsFile != null) {
saveReplacements(replacementsFile);
}
}
}
}
public static List<Replacement> getReplacements() {
return replacements;
}
static {
setConfigurationFields();
if (useDetailedLogging.get() || debugMode.get()) {
logLevel = Level.CONFIG;
} else {
logLevel = Level.WARNING;
}
}
public static void saveConfig() {
try {
saveToFile(getConfigFile(), getReplacementsFile());
} catch (IOException ex) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
}
}
@SuppressWarnings("unchecked")
public static void setConfigurationFields() {
try {
HashMap<String, Object> config = loadFromFile(getConfigFile(), getReplacementsFile());
for (Entry<String, Field> entry : getConfigurationFields().entrySet()) {
String name = entry.getKey();
Field field = entry.getValue();
// remove final modifier from field
Field modifiersField = field.getClass().getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
static {
setConfigurationFields();
if (useDetailedLogging.get() || debugMode.get()) {
logLevel = Level.CONFIG;
} else {
logLevel = Level.WARNING;
}
}
Object defaultValue = getDefaultValue(field);
Object value = null;
if (config.containsKey(name)) {
value = config.get(name);
}
@SuppressWarnings("unchecked")
public static void setConfigurationFields() {
try {
HashMap<String, Object> config = loadFromFile(getConfigFile(), getReplacementsFile());
for (Entry<String, Field> entry : getConfigurationFields().entrySet()) {
String name = entry.getKey();
Field field = entry.getValue();
// remove final modifier from field
Field modifiersField = field.getClass().getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
Object defaultValue = getDefaultValue(field);
Object value = null;
if (config.containsKey(name)) {
value = config.get(name);
if (value != null) {
field.set(null, new ConfigurationItem(name, defaultValue, value));
} else {
field.set(null, new ConfigurationItem(name, defaultValue));
}
}
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException ex) {
// Reflection exceptions. This should never happen
throw new Error(ex.getMessage());
} catch (IOException ex) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (value != null) {
field.set(null, new ConfigurationItem(name, defaultValue, value));
} else {
field.set(null, new ConfigurationItem(name, defaultValue));
public static Object getDefaultValue(Field field) {
Object defaultValue = null;
ConfigurationDefaultBoolean aBool = field.getAnnotation(ConfigurationDefaultBoolean.class);
if (aBool != null) {
defaultValue = aBool.value();
}
ConfigurationDefaultInt aInt = field.getAnnotation(ConfigurationDefaultInt.class);
if (aInt != null) {
defaultValue = aInt.value();
}
ConfigurationDefaultString aString = field.getAnnotation(ConfigurationDefaultString.class);
if (aString != null) {
defaultValue = aString.value();
}
return defaultValue;
}
public static String getDescription(Field field) {
ConfigurationDescription a = field.getAnnotation(ConfigurationDescription.class);
if (a != null) {
return a.value();
}
return null;
}
public static Map<String, Field> getConfigurationFields() {
Field[] fields = Configuration.class.getFields();
Map<String, Field> result = new HashMap<>();
for (Field field : fields) {
if (ConfigurationItem.class.isAssignableFrom(field.getType())) {
ConfigurationName annotation = field.getAnnotation(ConfigurationName.class);
String name = annotation == null ? field.getName() : annotation.value();
result.put(name, field);
}
}
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException ex) {
// Reflection exceptions. This should never happen
throw new Error(ex.getMessage());
} catch (IOException ex) {
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
return result;
}
public static Object getDefaultValue(Field field) {
Object defaultValue = null;
ConfigurationDefaultBoolean aBool = field.getAnnotation(ConfigurationDefaultBoolean.class);
if (aBool != null) {
defaultValue = aBool.value();
}
ConfigurationDefaultInt aInt = field.getAnnotation(ConfigurationDefaultInt.class);
if (aInt != null) {
defaultValue = aInt.value();
}
ConfigurationDefaultString aString = field.getAnnotation(ConfigurationDefaultString.class);
if (aString != null) {
defaultValue = aString.value();
}
return defaultValue;
}
public static String getDescription(Field field) {
ConfigurationDescription a = field.getAnnotation(ConfigurationDescription.class);
if (a != null) {
return a.value();
}
return null;
}
public static Map<String, Field> getConfigurationFields() {
Field[] fields = Configuration.class.getFields();
Map<String, Field> result = new HashMap<>();
for (Field field : fields) {
if (ConfigurationItem.class.isAssignableFrom(field.getType())) {
ConfigurationName annotation = field.getAnnotation(ConfigurationName.class);
String name = annotation == null ? field.getName() : annotation.value();
result.put(name, field);
}
}
return result;
}
public static CodeFormatting getCodeFormatting() {
CodeFormatting ret = new CodeFormatting();
String indentString = "";
for (int i = 0; i < indentSize.get(); i++) {
indentString += indentUseTabs.get() ? "\t" : " ";
}
ret.indentString = indentString;
ret.beginBlockOnNewLine = beginBlockOnNewLine.get();
return ret;
}
public static CodeFormatting getCodeFormatting() {
CodeFormatting ret = new CodeFormatting();
String indentString = "";
for (int i = 0; i < indentSize.get(); i++) {
indentString += indentUseTabs.get() ? "\t" : " ";
}
ret.indentString = indentString;
ret.beginBlockOnNewLine = beginBlockOnNewLine.get();
return ret;
}
}
@@ -763,7 +763,7 @@ public class CommandLineArgumentParser {
break;
}
}
try {
SWFSourceInfo sourceInfo = new SWFSourceInfo(null, fileName, null);
if (!sourceInfo.isBundle()) {
@@ -791,11 +791,11 @@ public class CommandLineArgumentParser {
break;
}
}
if (mode == ExtractMode.BIGGEST && biggest != null) {
streamsToExtract.add(biggest);
}
for (Map.Entry<String, SeekableInputStream> streamEntry : streamsToExtract) {
InputStream stream = streamEntry.getValue();
stream.reset();
@@ -21,6 +21,6 @@ package com.jpexs.decompiler.flash.console;
* @author JPEXS
*/
public enum ExtractMode {
ALL, BIGGEST
}
@@ -42,15 +42,15 @@ public class ExportRectangle {
this.xMax = rect.Xmax;
this.yMax = rect.Ymax;
}
public double getWidth() {
return xMax - xMin;
}
}
public double getHeight() {
return yMax - yMin;
}
}
@Override
public int hashCode() {
long bits = Double.doubleToLongBits(xMin);
@@ -50,7 +50,7 @@ public class Matrix {
}
public Matrix(MATRIX matrix) {
if(matrix == null){
if (matrix == null) {
matrix = new MATRIX();
}
translateX = matrix.translateX;
@@ -86,11 +86,11 @@ public class Matrix {
rotateSkew0 * x + scaleY * y + translateY);
return result;
}
public Point transform(Point point) {
return transform(point.x, point.y);
}
public ExportRectangle transform(ExportRectangle rect) {
double minX = Double.MAX_VALUE;
double minY = Double.MAX_VALUE;
@@ -98,28 +98,60 @@ public class Matrix {
double maxY = Double.MIN_VALUE;
Point point;
point = transform(rect.xMin, rect.yMin);
if (point.x < minX) minX = point.x;
if (point.x > maxX) maxX = point.x;
if (point.y < minY) minY = point.y;
if (point.y > maxY) maxY = point.y;
if (point.x < minX) {
minX = point.x;
}
if (point.x > maxX) {
maxX = point.x;
}
if (point.y < minY) {
minY = point.y;
}
if (point.y > maxY) {
maxY = point.y;
}
point = transform(rect.xMax, rect.yMin);
if (point.x < minX) minX = point.x;
if (point.x > maxX) maxX = point.x;
if (point.y < minY) minY = point.y;
if (point.y > maxY) maxY = point.y;
if (point.x < minX) {
minX = point.x;
}
if (point.x > maxX) {
maxX = point.x;
}
if (point.y < minY) {
minY = point.y;
}
if (point.y > maxY) {
maxY = point.y;
}
point = transform(rect.xMin, rect.yMax);
if (point.x < minX) minX = point.x;
if (point.x > maxX) maxX = point.x;
if (point.y < minY) minY = point.y;
if (point.y > maxY) maxY = point.y;
if (point.x < minX) {
minX = point.x;
}
if (point.x > maxX) {
maxX = point.x;
}
if (point.y < minY) {
minY = point.y;
}
if (point.y > maxY) {
maxY = point.y;
}
point = transform(rect.xMax, rect.yMax);
if (point.x < minX) minX = point.x;
if (point.x > maxX) maxX = point.x;
if (point.y < minY) minY = point.y;
if (point.y > maxY) maxY = point.y;
if (point.x < minX) {
minX = point.x;
}
if (point.x > maxX) {
maxX = point.x;
}
if (point.y < minY) {
minY = point.y;
}
if (point.y > maxY) {
maxY = point.y;
}
return new ExportRectangle(minX, minY, maxX, maxY);
}
public void translate(double x, double y) {
translateX += x;
translateY += y;
@@ -67,7 +67,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
}
private HilightedText getHilightedText(ExportMode exportMode) {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),true);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
abc.bodies[bodyIndex].code.toASMSource(abc.constants, trait, abc.method_info[abc.bodies[bodyIndex].method_info], abc.bodies[bodyIndex], exportMode, writer);
return new HilightedText(writer);
}
@@ -93,7 +93,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
} else {
setContentType("text/plain");
if (textHexOnly == null) {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),true);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
Helper.byteArrayToHexWithHeader(writer, abc.bodies[bodyIndex].code.getBytes());
textHexOnly = new HilightedText(writer);
}
@@ -446,7 +446,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
}
if (!cache.contains(scriptLeaf)) {
boolean parallel = Configuration.parallelSpeedUp.get();
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),true);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
scriptLeaf.toSource(writer, abcList, script.traits.traits, ExportMode.SOURCE, parallel);
hilightedCode = new HilightedText(writer);
cache.put(scriptLeaf, new CachedDecompilation(hilightedCode));
@@ -93,7 +93,7 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail {
public void load(TraitSlotConst trait, ABC abc, boolean isStatic) {
this.abc = abc;
this.trait = trait;
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),true);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
writer.appendNoHilight("trait ");
writer.hilightSpecial(abc.constants.multinameToString(trait.name_index), "traitname");
writer.appendNoHilight(" ");
@@ -90,12 +90,12 @@ public class TraitsListItem {
try {
if ((type != Type.INITIALIZER) && isStatic) {
abc.class_info[classIndex].static_traits.traits[index].convertHeader(null, "", abcTags, abc, true, ExportMode.SOURCE, scriptIndex, classIndex, new NulWriter(), new ArrayList<String>(), false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
abc.class_info[classIndex].static_traits.traits[index].toStringHeader(null, "", abcTags, abc, true, ExportMode.SOURCE, scriptIndex, classIndex, writer, new ArrayList<String>(), false);
s = writer.toString();
} else if ((type != Type.INITIALIZER) && (!isStatic)) {
abc.instance_info[classIndex].instance_traits.traits[index].convertHeader(null, "", abcTags, abc, false, ExportMode.SOURCE, scriptIndex, classIndex, new NulWriter(), new ArrayList<String>(), false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
abc.instance_info[classIndex].instance_traits.traits[index].toStringHeader(null, "", abcTags, abc, false, ExportMode.SOURCE, scriptIndex, classIndex, writer, new ArrayList<String>(), false);
s = writer.toString();
} else if (!isStatic) {
@@ -189,7 +189,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
if (actions == null) {
actions = src.getActions(SWF.DEFAULT_VERSION);
}
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),true);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
Action.actionsToSource(src, actions, SWF.DEFAULT_VERSION, src.toString()/*FIXME?*/, writer);
List<Highlighting> hilights = writer.instructionHilights;
String srcNoHex = writer.toString();
@@ -309,7 +309,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
ASMSource asm = (ASMSource) src;
DisassemblyListener listener = getDisassemblyListener();
asm.addDisassemblyListener(listener);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),true);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
try {
asm.getASMSource(SWF.DEFAULT_VERSION, exportMode, writer, lastCode);
} catch (InterruptedException ex) {
@@ -334,7 +334,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
}
} else {
if (srcHexOnly == null) {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),true);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
Helper.byteArrayToHexWithHeader(writer, src.getActionBytes());
srcHexOnly = new HilightedText(writer);
}
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.helpers;
/**
@@ -22,7 +21,8 @@ package com.jpexs.decompiler.flash.helpers;
* @author JPEXS
*/
public class CodeFormatting {
public String newLineChars = "\r\n";
public String indentString = " ";
public boolean beginBlockOnNewLine = true;
public String newLineChars = "\r\n";
public String indentString = " ";
public boolean beginBlockOnNewLine = true;
}
@@ -36,7 +36,7 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable {
private int indent;
private int writtenBytes;
public FileTextWriter(CodeFormatting formatting,FileOutputStream fos) {
public FileTextWriter(CodeFormatting formatting, FileOutputStream fos) {
super(formatting);
this.writer = new BufferedWriter(new Utf8OutputStreamWriter(fos));
}
@@ -29,13 +29,13 @@ public class GraphTextWriter {
protected long suspendTime;
protected CodeFormatting formatting;
public CodeFormatting getFormatting() {
return formatting;
}
public CodeFormatting getFormatting() {
return formatting;
}
public GraphTextWriter(CodeFormatting formatting) {
startTime = System.currentTimeMillis();
this.formatting = formatting;
startTime = System.currentTimeMillis();
this.formatting = formatting;
}
public boolean getIsHighlighted() {
@@ -164,24 +164,24 @@ public class GraphTextWriter {
public String toString() {
return "";
}
public GraphTextWriter startBlock(String opening) {
if(formatting.beginBlockOnNewLine){
if (formatting.beginBlockOnNewLine) {
newLine();
}else{
} else {
append(" ");
}
}
return append(opening).newLine().indent();
}
public GraphTextWriter startBlock() {
return startBlock("{");
}
public GraphTextWriter endBlock(String closing) {
return unindent().append(closing);
}
public GraphTextWriter endBlock() {
return endBlock("}");
}
@@ -48,12 +48,12 @@ public class HilightedTextWriter extends GraphTextWriter {
public List<Highlighting> instructionHilights = new ArrayList<>();
public List<Highlighting> specialHilights = new ArrayList<>();
public HilightedTextWriter(CodeFormatting formatting,boolean hilight) {
public HilightedTextWriter(CodeFormatting formatting, boolean hilight) {
super(formatting);
this.hilight = hilight;
}
public HilightedTextWriter(CodeFormatting formatting,boolean hilight, int indent) {
public HilightedTextWriter(CodeFormatting formatting, boolean hilight, int indent) {
super(formatting);
this.hilight = hilight;
this.indent = indent;
@@ -30,7 +30,7 @@ public class NulWriter extends GraphTextWriter {
private boolean stringAdded = false;
public NulWriter() {
super(new CodeFormatting());
super(new CodeFormatting());
}
public void startLoop(long loopId, int loopType) {
@@ -44,7 +44,7 @@ public class CSMTextSettingsTag extends Tag {
public int gridFit;
@Reserved
@SWFType(value = BasicType.UB, count=3)
@SWFType(value = BasicType.UB, count = 3)
public int reserved;
@SWFType(value = BasicType.FLOAT) //F32 = FLOAT
@@ -285,7 +285,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
visited.push(buttonId);
SWF.frameToImage(buttonId, maxDepth, layers, new Color(0, 0, 0, 0), characters, 1, tags, tags, displayRect, visited, image, transformation);
}
@Override
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
RECT r = getRect(characters, visited);
@@ -309,7 +309,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
SWF.frameToImage(buttonId, maxDepth, layers, new Color(0, 0, 0, 0), characters, 1, tags, tags, displayRect, visited, image, transformation);
visited.pop();
}
@Override
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
RECT r = getRect(characters, visited);
@@ -34,7 +34,7 @@ public class DefineFont4Tag extends CharacterTag {
public int fontID;
@Reserved
@SWFType(value = BasicType.UB, count=5)
@SWFType(value = BasicType.UB, count = 5)
public int reserved;
public boolean fontFlagsHasFontData;
public boolean fontFlagsItalic;
@@ -40,7 +40,7 @@ public class DefineFontAlignZonesTag extends Tag {
@Reserved
@SWFType(value = BasicType.UB, count = 6)
public int reserved;
@SWFArray(value="zone",countField = "glyphCount")
@SWFArray(value = "zone", countField = "glyphCount")
public List<ZONERECORD> zoneTable;
public static final int ID = 73;
@@ -67,7 +67,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo
public RECT startEdgeBounds;
public RECT endEdgeBounds;
@Reserved
@SWFType(value = BasicType.UB, count=6)
@SWFType(value = BasicType.UB, count = 6)
public int reserved;
public boolean usesNonScalingStrokes;
public boolean usesScalingStrokes;
@@ -205,10 +205,10 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo
int startPosX = 0, startPosY = 0;
int endPosX = 0, endPosY = 0;
int posX = 0, posY = 0;
for (int startIndex = 0, endIndex = 0;
startIndex < startEdges.shapeRecords.size() &&
endIndex < endEdges.shapeRecords.size(); startIndex++, endIndex++) {
startIndex < startEdges.shapeRecords.size()
&& endIndex < endEdges.shapeRecords.size(); startIndex++, endIndex++) {
SHAPERECORD edge1 = startEdges.shapeRecords.get(startIndex);
SHAPERECORD edge2 = endEdges.shapeRecords.get(endIndex);
@@ -314,7 +314,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo
shape.shapeRecords = finalRecords;
return shape;
}
@Override
public SerializableImage toImage(int frame, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
throw new Error("this overload of toImage call is not supported on BoundedTag");
@@ -329,7 +329,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo
// recreated
BitmapExporter.exportTo(swf, shape, null, image, transformation);
}
@Override
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
return new Point(
@@ -188,10 +188,10 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor
int startPosX = 0, startPosY = 0;
int endPosX = 0, endPosY = 0;
int posX = 0, posY = 0;
for (int startIndex = 0, endIndex = 0;
startIndex < startEdges.shapeRecords.size() &&
endIndex < endEdges.shapeRecords.size(); startIndex++, endIndex++) {
startIndex < startEdges.shapeRecords.size()
&& endIndex < endEdges.shapeRecords.size(); startIndex++, endIndex++) {
SHAPERECORD edge1 = startEdges.shapeRecords.get(startIndex);
SHAPERECORD edge2 = endEdges.shapeRecords.get(endIndex);
@@ -297,7 +297,7 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor
shape.shapeRecords = finalRecords;
return shape;
}
@Override
public SerializableImage toImage(int frame, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, Matrix transformation) {
throw new Error("this overload of toImage call is not supported on BoundedTag");
@@ -312,7 +312,7 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor
// recreated
BitmapExporter.exportTo(swf, shape, null, image, transformation);
}
@Override
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
return new Point(
@@ -34,14 +34,14 @@ import java.io.OutputStream;
*/
public class DefineSceneAndFrameLabelDataTag extends Tag {
@SWFType(value=BasicType.EncodedU32)
@SWFArray(value="offset",countField="sceneCount")
@SWFType(value = BasicType.EncodedU32)
@SWFArray(value = "offset", countField = "sceneCount")
public long[] sceneOffsets;
@SWFArray(value="name",countField="sceneCount")
@SWFArray(value = "name", countField = "sceneCount")
public String[] sceneNames;
@SWFType(value=BasicType.EncodedU32)
@SWFArray(value="frameNum", countField="frameLabelCount")
@SWFType(value = BasicType.EncodedU32)
@SWFArray(value = "frameNum", countField = "frameLabelCount")
public long[] frameNums;
@SWFArray(countField = "frameLabelCount")
@@ -80,7 +80,7 @@ public class DefineShape2Tag extends CharacterTag implements ShapeTag {
public void toImage(int frame, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation);
}
@Override
public int getCharacterId() {
return shapeId;
@@ -85,7 +85,7 @@ public class DefineShape3Tag extends CharacterTag implements ShapeTag {
public void toImage(int frame, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation);
}
@Override
public int getCharacterId() {
return shapeId;
@@ -88,7 +88,7 @@ public class DefineShape4Tag extends CharacterTag implements ShapeTag {
public void toImage(int frame, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation);
}
@Override
public int getCharacterId() {
return shapeId;
@@ -114,7 +114,7 @@ public class DefineShapeTag extends CharacterTag implements ShapeTag {
public void toImage(int frame, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation);
}
@Override
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
return new Point(shapeBounds.Xmin / SWF.unitDivisor, shapeBounds.Ymin / SWF.unitDivisor);
@@ -299,7 +299,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
SWF.frameToImage(spriteId, frame, tags, subTags, rect, frameCount, visited, image, transformation);
visited.pop();
}
@Override
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
//RECT displayRect = getRect(characters, visited); //use visited
@@ -500,7 +500,7 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
public void toImage(int frame, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
staticTextToImage(swf, characters, textRecords, 2, image, getTextMatrix(), transformation);
}
@Override
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
return new Point(textBounds.Xmin / 20, textBounds.Ymin / 20);
@@ -516,7 +516,7 @@ public class DefineTextTag extends TextTag implements DrawableTag {
public void toImage(int frame, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
staticTextToImage(swf, characters, textRecords, 1, image, getTextMatrix(), transformation);
}
@Override
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
return new Point(textBounds.Xmin / SWF.unitDivisor, textBounds.Ymin / SWF.unitDivisor);
@@ -40,17 +40,17 @@ public class ExportAssetsTag extends Tag {
* HashMap with assets
*/
@SWFType(value = BasicType.UI16)
@SWFArray(value="tag",countField = "count")
@SWFArray(value = "tag", countField = "count")
public List<Integer> tags;
@SWFArray(value="name",countField = "count")
@SWFArray(value = "name", countField = "count")
public List<String> names;
public static final int ID = 56;
public ExportAssetsTag() {
super(null, ID, "ExportAssets", new byte[]{}, 0);
tags = new ArrayList<>();
names = new ArrayList<>();
names = new ArrayList<>();
}
/**
@@ -50,10 +50,10 @@ public class ImportAssets2Tag extends Tag implements ImportTag {
/**
* HashMap with assets
*/
@SWFType(value=BasicType.UI16)
@SWFArray(value="tag",countField = "count")
@SWFType(value = BasicType.UI16)
@SWFArray(value = "tag", countField = "count")
public List<Integer> tags;
@SWFArray(value="name",countField = "count")
@SWFArray(value = "name", countField = "count")
public List<String> names;
public static final int ID = 71;
@@ -99,7 +99,7 @@ public class ImportAssets2Tag extends Tag implements ImportTag {
sos.writeUI8(reserved1);
sos.writeUI8(reserved2);
sos.writeUI16(tags.size());
for (int i=0;i<tags.size();i++) {
for (int i = 0; i < tags.size(); i++) {
sos.writeUI16(tags.get(i));
sos.writeString(names.get(i));
}
@@ -43,10 +43,10 @@ public class ImportAssetsTag extends Tag implements ImportTag {
/**
* HashMap with assets
*/
@SWFType(value=BasicType.UI16)
@SWFArray(value="tag",countField = "count")
@SWFType(value = BasicType.UI16)
@SWFArray(value = "tag", countField = "count")
public List<Integer> tags;
@SWFArray(value="name",countField = "count")
@SWFArray(value = "name", countField = "count")
public List<String> names;
public static final int ID = 57;
@@ -71,7 +71,7 @@ public class ProtectTag extends Tag {
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
if (sis.available() > 0) {
passwordHash = sis.readString();
}else{
} else {
passwordHash = "";
}
}
@@ -29,10 +29,10 @@ import java.io.OutputStream;
public class SymbolClassTag extends Tag {
@SWFType(value=BasicType.UI16)
@SWFArray(value="tag",countField = "numSymbols")
@SWFType(value = BasicType.UI16)
@SWFArray(value = "tag", countField = "numSymbols")
public int[] tags;
@SWFArray(value="name",countField = "numSymbols")
@SWFArray(value = "name", countField = "numSymbols")
public String[] names;
public static final int ID = 76;
@@ -62,7 +62,7 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializ
private final long pos;
protected String name;
@Internal
public Tag previousTag;
public Tag previousTag;
@Internal
protected transient SWF swf;
@Internal
@@ -61,10 +61,10 @@ public abstract class CharacterIdTag extends Tag {
if (className != null) {
nameAppend = ": " + className;
}
if(getCharacterId()!=-1) {
if (getCharacterId() != -1) {
return super.getName() + " (" + getCharacterId() + nameAppend + ")";
}
if(!nameAppend.equals("")){
if (!nameAppend.equals("")) {
return super.getName() + " (" + nameAppend + ")";
}
return super.getName();
@@ -252,9 +252,9 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable
@Override
public void toImage(int frame, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation) {
}
@Override
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
return new Point(0, 0);
@@ -25,6 +25,6 @@ import java.util.Map;
public interface ImportTag {
public String getUrl();
public Map<Integer, String> getAssets();
}
@@ -224,7 +224,7 @@ public abstract class TextTag extends CharacterTag implements BoundedTag {
}
double rat = textHeight / 1024.0 / font.getDivider();
for (GLYPHENTRY entry : rec.glyphEntries) {
Matrix mat = transformation.clone();
mat = mat.concatenate(new Matrix(textMatrix));
@@ -371,6 +371,7 @@ public final class TextLexer {
/**
* Closes the input stream.
*
* @throws java.io.IOException
*/
public final void yyclose() throws java.io.IOException {
@@ -406,7 +407,8 @@ public final class TextLexer {
/**
* Returns the current lexical state.
* @return
*
* @return
*/
public final int yystate() {
return zzLexicalState;
@@ -423,7 +425,8 @@ public final class TextLexer {
/**
* Returns the text matched by the current regular expression.
* @return
*
* @return
*/
public final String yytext() {
return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
@@ -445,7 +448,8 @@ public final class TextLexer {
/**
* Returns the length of the matched text region.
* @return
*
* @return
*/
public final int yylength() {
return zzMarkedPos - zzStartRead;
@@ -138,7 +138,7 @@ public class TagNode extends ContainerNode {
File file = new File(f);
ASMSource asm = ((ASMSource) node.item);
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(),new FileOutputStream(f))) {
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(f))) {
if (exportMode == ExportMode.HEX) {
asm.getActionSourcePrefix(writer);
asm.getActionBytesAsHex(writer);
@@ -56,13 +56,15 @@ public class ARGB implements Serializable {
public Color toColor() {
return new Color(red, green, blue, alpha);
}
public ARGB(){
public ARGB() {
}
public ARGB(Color color) {
this.alpha = color.getAlpha();
this.red = color.getRed();
this.green = color.getGreen();
this.blue = color.getBlue();
this.blue = color.getBlue();
}
}
@@ -121,7 +121,7 @@ public class CLIPEVENTFLAGS implements Serializable {
*/
@Conditional(minSwfVersion = 6)
public boolean clipEventDragOut = false;
@Reserved
@SWFType(value = BasicType.UB, count = 8)
@Conditional(minSwfVersion = 6)
@@ -27,7 +27,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class MORPHFILLSTYLE implements NeedsCharacters,Serializable {
public class MORPHFILLSTYLE implements NeedsCharacters, Serializable {
@SWFType(BasicType.UI8)
public int fillStyleType;
@@ -25,7 +25,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class MORPHFILLSTYLEARRAY implements NeedsCharacters,Serializable {
public class MORPHFILLSTYLEARRAY implements NeedsCharacters, Serializable {
public MORPHFILLSTYLE[] fillStyles;
@@ -25,7 +25,7 @@ import java.io.Serializable;
*
* @author JPEXS
*/
public class RGBA extends RGB implements Serializable{
public class RGBA extends RGB implements Serializable {
/**
* Alpha value defining opacity
@@ -28,7 +28,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class SHAPE implements NeedsCharacters,Serializable {
public class SHAPE implements NeedsCharacters, Serializable {
@SWFType(value = BasicType.UB, count = 4)
public int numFillBits;
@@ -24,7 +24,7 @@ import java.io.Serializable;
*
* @author JPEXS
*/
public class ZONEDATA implements Serializable{
public class ZONEDATA implements Serializable {
@SWFType(BasicType.FLOAT16)
public int alignmentCoordinate;
@@ -24,9 +24,9 @@ import java.io.Serializable;
*
* @author JPEXS
*/
public class ZONERECORD implements Serializable{
public class ZONERECORD implements Serializable {
@SWFArray(value="zone",countField = "numZoneData")
@SWFArray(value = "zone", countField = "numZoneData")
public ZONEDATA[] zonedata = new ZONEDATA[0];
public boolean zoneMaskX;
public boolean zoneMaskY;
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.types.annotations;
/**
@@ -23,5 +22,5 @@ package com.jpexs.decompiler.flash.types.annotations;
* @author JPEXS
*/
public @interface Multiline {
}
@@ -101,13 +101,13 @@ public class ConditionEvaluator {
try {
expression(fields, stack, lex);
} catch (IOException | EmptyStackException ex) {
throw new ParseException("Invalid condition:"+prepareCond(), lex.yyline());
throw new ParseException("Invalid condition:" + prepareCond(), lex.yyline());
}
if(prepareCond().equals("")){
if (prepareCond().equals("")) {
return true;
}
if (stack.size() != 1) {
throw new ParseException("Invalid condition:"+prepareCond(), lex.yyline());
throw new ParseException("Invalid condition:" + prepareCond(), lex.yyline());
}
return stack.pop();
@@ -136,7 +136,7 @@ public class ConditionEvaluator {
}
}
} catch (IOException ex) {
throw new ParseException("Invalid condition:"+prepareCond(), lex.yyline());
throw new ParseException("Invalid condition:" + prepareCond(), lex.yyline());
}
return ret;
}
File diff suppressed because it is too large Load Diff
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.types.annotations.parser;
/**
@@ -22,19 +21,18 @@ package com.jpexs.decompiler.flash.types.annotations.parser;
* @author JPEXS
*/
public class ConditionToken {
public String value;
public ConditionTokenType type;
public ConditionToken(ConditionTokenType type,String value) {
public ConditionToken(ConditionTokenType type, String value) {
this.value = value;
this.type = type;
}
@Override
public String toString() {
return type.toString()+(value!=null?"["+value+"]":"");
return type.toString() + (value != null ? "[" + value + "]" : "");
}
}
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.types.annotations.parser;
/**
@@ -22,6 +21,7 @@ package com.jpexs.decompiler.flash.types.annotations.parser;
* @author JPEXS
*/
public enum ConditionTokenType {
FIELD,
OR,
AND,
@@ -93,7 +93,8 @@ public final class BlendComposite implements Composite {
/**
* {@inheritDoc}
* @return
*
* @return
*/
@Override
public int hashCode() {
@@ -39,7 +39,7 @@ public class GRADIENTBEVELFILTER extends FILTER {
/**
* Gradient ratios
*/
@SWFType(value=BasicType.UI8,countField = "numColors")
@SWFType(value = BasicType.UI8, countField = "numColors")
public int[] gradientRatio = new int[0];
/**
* Horizontal blur amount
@@ -39,7 +39,7 @@ public class GRADIENTGLOWFILTER extends FILTER {
/**
* Gradient ratios
*/
@SWFType(value=BasicType.UI8,countField = "numColors")
@SWFType(value = BasicType.UI8, countField = "numColors")
public int[] gradientRatio;
/**
* Horizontal blur amount
@@ -23,7 +23,7 @@ import java.io.Serializable;
*
* @author JPEXS
*/
public class GLYPHIDX implements Serializable {
public class GLYPHIDX implements Serializable {
public int indexInFont;
public int indexInTexture;
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.xfl;
import java.util.HashMap;
@@ -25,43 +24,44 @@ import java.util.Map;
* @author JPEXS
*/
public enum FLAVersion {
CS5("CS5","Flash CS 5","2.0",10),
CS5_5("CS5.5","Flash CS 5.5","2.1",11),
CS6("CS6","Flash CS 6","2.2",17),
CC("CC","Flash CC","2.4",Integer.MAX_VALUE){
@Override
public int minASVersion() {
return 3; //AS 1/2 not supported anymore
}
};
CS5("CS5", "Flash CS 5", "2.0", 10),
CS5_5("CS5.5", "Flash CS 5.5", "2.1", 11),
CS6("CS6", "Flash CS 6", "2.2", 17),
CC("CC", "Flash CC", "2.4", Integer.MAX_VALUE) {
@Override
public int minASVersion() {
return 3; //AS 1/2 not supported anymore
}
};
private final String xflVersion;
private final String shortName;
private final String applicationName;
private final int maxSwfVersion;
private static final Map<Integer,String> versionToPlayerMap=new HashMap<>();
static{
versionToPlayerMap.put(10,"FlashPlayer10.0"); //10 & 10.1
versionToPlayerMap.put(11,"FlashPlayer10.2");
versionToPlayerMap.put(12,"FlashPlayer10.3");
versionToPlayerMap.put(13,"FlashPlayer11.0");
versionToPlayerMap.put(14,"FlashPlayer11.1");
versionToPlayerMap.put(15,"FlashPlayer11.2");
versionToPlayerMap.put(16,"FlashPlayer11.3");
versionToPlayerMap.put(17,"FlashPlayer11.4");
versionToPlayerMap.put(18,"FlashPlayer11.5");
versionToPlayerMap.put(19,"FlashPlayer11.6");
versionToPlayerMap.put(20,"FlashPlayer11.7");
versionToPlayerMap.put(21,"FlashPlayer11.8");
versionToPlayerMap.put(22,"FlashPlayer11.9");
versionToPlayerMap.put(23,"FlashPlayer12.0");
private static final Map<Integer, String> versionToPlayerMap = new HashMap<>();
static {
versionToPlayerMap.put(10, "FlashPlayer10.0"); //10 & 10.1
versionToPlayerMap.put(11, "FlashPlayer10.2");
versionToPlayerMap.put(12, "FlashPlayer10.3");
versionToPlayerMap.put(13, "FlashPlayer11.0");
versionToPlayerMap.put(14, "FlashPlayer11.1");
versionToPlayerMap.put(15, "FlashPlayer11.2");
versionToPlayerMap.put(16, "FlashPlayer11.3");
versionToPlayerMap.put(17, "FlashPlayer11.4");
versionToPlayerMap.put(18, "FlashPlayer11.5");
versionToPlayerMap.put(19, "FlashPlayer11.6");
versionToPlayerMap.put(20, "FlashPlayer11.7");
versionToPlayerMap.put(21, "FlashPlayer11.8");
versionToPlayerMap.put(22, "FlashPlayer11.9");
versionToPlayerMap.put(23, "FlashPlayer12.0");
}
private FLAVersion(String shortName,String applicationName,String xflVersion,int maxSwfVersion){
private FLAVersion(String shortName, String applicationName, String xflVersion, int maxSwfVersion) {
this.xflVersion = xflVersion;
this.shortName = shortName;
this.applicationName = applicationName;
@@ -71,20 +71,20 @@ public enum FLAVersion {
public String xflVersion() {
return xflVersion;
}
public int maxSwfVersion(){
public int maxSwfVersion() {
return maxSwfVersion;
}
public int minASVersion(){
public int minASVersion() {
return 1;
}
public String applicationName(){
public String applicationName() {
return applicationName;
}
public String shortName(){
public String shortName() {
return shortName;
}
@@ -92,23 +92,23 @@ public enum FLAVersion {
public String toString() {
return shortName;
}
public static String swfVersionToPlayer(int version){
if(versionToPlayerMap.containsKey(version)){
public static String swfVersionToPlayer(int version) {
if (versionToPlayerMap.containsKey(version)) {
return versionToPlayerMap.get(version);
}
return "";
}
public static FLAVersion fromString(String s){
if(s == null){
public static FLAVersion fromString(String s) {
if (s == null) {
return null;
}
for(FLAVersion v:FLAVersion.values()){
if(v.shortName.toLowerCase().equals(s.toLowerCase())){
for (FLAVersion v : FLAVersion.values()) {
if (v.shortName.toLowerCase().equals(s.toLowerCase())) {
return v;
}
if(v.xflVersion.equals(s)){
if (v.xflVersion.equals(s)) {
return v;
}
}
@@ -448,13 +448,9 @@ public class XFLConverter {
/**
* Remove bugs in shape:
*
* ...
* straightrecord
* straightrecord
* stylechange
* straightrecord (-2,0) <-- merge this with previous
* stylegchange
*
* ... straightrecord straightrecord stylechange straightrecord (-2,0) <--
* merge this with previous stylegchange
*
* @param shapeRecords
* @return
@@ -497,7 +493,7 @@ public class XFLConverter {
scr2.stateLineStyle = true;
scr2.lineStyle = scr.lineStyle;
}
i-=2;
i -= 2;
}
}
@@ -1157,7 +1153,7 @@ public class XFLConverter {
}
private static String convertActionScript(ASMSource as) {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
try {
Action.actionsToSource(as, as.getActions(SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION, as.toString(), writer);
} catch (InterruptedException ex) {
@@ -1871,7 +1867,7 @@ public class XFLConverter {
if (t instanceof ShowFrameTag) {
elements = "";
if ((character instanceof ShapeTag) && (nonLibraryShapes.contains(characterId)||shapeTweener!=null)) {
if ((character instanceof ShapeTag) && (nonLibraryShapes.contains(characterId) || shapeTweener != null)) {
ShapeTag shape = (ShapeTag) character;
elements += convertShape(characters, matrix, shape.getShapeNum(), shape.getShapes().shapeRecords, shape.getShapes().fillStyles, shape.getShapes().lineStyles, false, false);
shapeTween = false;
@@ -117,7 +117,7 @@ public abstract class GraphTargetItem implements Serializable {
public abstract GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException;
public String toString(LocalData localData) throws InterruptedException {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
toString(writer, localData);
return writer.toString();
}
@@ -90,10 +90,10 @@ public class IfItem extends GraphTargetItem implements Block {
}
writer.endBlock();
if (elseBranch.size() > 0) {
if(writer.getFormatting().beginBlockOnNewLine){
writer.newLine();
}else{
writer.append(" ");
if (writer.getFormatting().beginBlockOnNewLine) {
writer.newLine();
} else {
writer.append(" ");
}
writer.append("else").startBlock();
for (GraphTargetItem ti : elseBranch) {
+4 -4
View File
@@ -706,7 +706,7 @@ public class Helper {
}
public static String byteArrayToHex(byte[] data, int bytesPerRow) {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(),false);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
byteArrayToHex(writer, data, bytesPerRow, 8, true, true);
return writer.toString();
}
@@ -793,11 +793,11 @@ public class Helper {
appendNoHilight(AppStrings.translate("decompilationError.error.description")).
appendNoHilight("\");").newLine();
}
public static String escapeHTML(String text){
public static String escapeHTML(String text) {
String from[] = new String[]{"&", "<", ">", "\"", "'", "/"};
String to[] = new String[]{"&amp;", "&lt;", "&gt;", "&quot;", "&#x27;", "&#x2F;"};
for(int i=0;i<from.length;i++){
for (int i = 0; i < from.length; i++) {
text = text.replace(from[i], to[i]);
}
return text;
@@ -65,8 +65,8 @@ public class SerializableImage implements Serializable {
public BufferedImage getBufferedImage() {
/*try {
ImageIO.write(image, "png", new File("c:\\10\\x\\imageid" + String.format("%03d", imageid++) + ".png"));
} catch (IOException ex) {
}*/
} catch (IOException ex) {
}*/
return image;
}
@@ -308,7 +308,7 @@ public interface Gdi32 extends StdCallLibrary {
* the desired format for the DIB data.
* @param uUsage The format of the bmiColors member of the {@link
* BITMAPINFO} structure.
* @return
* @return
*/
int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
@@ -279,6 +279,7 @@ public interface WinNT extends WinError, WinDef, WinBase, BaseTSD {
/**
* Initialize a TOKEN_PRIVILEGES instance from initialized memory.
*
* @param p
*/
public TOKEN_PRIVILEGES(Pointer p) {
@@ -489,7 +490,8 @@ public interface WinNT extends WinError, WinDef, WinBase, BaseTSD {
/**
* WARNING: this filename may be either the short or long form of the
* filename.
* @return
*
* @return
*/
public String getFilename() {
return new String(FileName, 0, FileNameLength / 2);
@@ -787,9 +789,10 @@ public interface WinNT extends WinError, WinDef, WinBase, BaseTSD {
/**
* Override to the appropriate object for INVALID_HANDLE_VALUE.
*
* @param nativeValue
* @param context
* @return
* @return
*/
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
@@ -195,9 +195,10 @@ public interface WinUser extends StdCallLibrary, WinDef {
/**
* Return whether to continue enumeration.
*
* @param hWnd
* @param data
* @return
* @return
*/
boolean callback(HWND hWnd, Pointer data);
}