From 31f527582cb4fb14922973a009774bb750d8a9ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Fri, 20 Sep 2013 20:40:40 +0200 Subject: [PATCH] Issue #391 Native methods/functions keyword support --- .../decompiler/flash/abc/types/traits/TraitFunction.java | 7 +++++-- .../flash/abc/types/traits/TraitMethodGetterSetter.java | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index 511b3c9f8..09641695f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -43,11 +43,14 @@ public class TraitFunction extends Trait implements TraitWithSlot { @Override public String convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List fullyQualifiedNames, boolean parallel) { - String modifier = getModifiers(abcTags, abc, isStatic) + " "; + String modifier = getModifiers(abcTags, abc, isStatic) + " "; + MethodBody body = abc.findBody(method_info); + if (body == null) { + modifier = "native " + modifier; + } if (modifier.equals(" ")) { modifier = ""; } - MethodBody body = abc.findBody(method_info); return modifier + Highlighting.hilighSpecial(highlight, "function ", "traittype") + Highlighting.hilighSpecial(highlight, abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames), "traitname") + "(" + abc.method_info[method_info].getParamStr(highlight, abc.constants, body, abc, fullyQualifiedNames) + ") : " + abc.method_info[method_info].getReturnTypeStr(highlight, abc.constants, fullyQualifiedNames); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index f136a3561..4a89b5b48 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -50,6 +50,11 @@ public class TraitMethodGetterSetter extends Trait { addKind = "set "; } MethodBody body = abc.findBody(method_info); + + if (((classIndex == -1) || (!abc.instance_info[classIndex].isInterface())) && (body == null)) { + modifier = "native " + modifier; + } + return modifier + Highlighting.hilighSpecial(highlight, "function " + addKind, "traittype") + Highlighting.hilighSpecial(highlight, getName(abc).getName(abc.constants, fullyQualifiedNames), "traitname") + "(" + abc.method_info[method_info].getParamStr(highlight, abc.constants, body, abc, fullyQualifiedNames) + ") : " + abc.method_info[method_info].getReturnTypeStr(highlight, abc.constants, fullyQualifiedNames); } @@ -62,7 +67,7 @@ public class TraitMethodGetterSetter extends Trait { if (bodyIndex != -1) { bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack(), false, highlight, true, fullyQualifiedNames, null), 3); } - return Graph.INDENT_STRING + Graph.INDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + Graph.INDENT_STRING + Graph.INDENT_STRING + "}"); + return Graph.INDENT_STRING + Graph.INDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface() || bodyIndex == -1) ? ";" : " {\r\n" + bodyStr + "\r\n" + Graph.INDENT_STRING + Graph.INDENT_STRING + "}"); } @Override