mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-19 12:01:55 +00:00
Faster AS3 Debugging - export/import ByteArray variable data
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
import flash.utils.ByteArray;
|
||||
import flash.events.Event;
|
||||
import flash.display.Sprite;
|
||||
|
||||
import flash.utils.getTimer;
|
||||
import flash.events.ProgressEvent;
|
||||
|
||||
public class DebugConnection {
|
||||
|
||||
private static var s:Socket;
|
||||
@@ -12,21 +14,30 @@
|
||||
private static var first:Boolean = true;
|
||||
private static var inited:Boolean = false;
|
||||
private static var name:String;
|
||||
private static var failed:Boolean = false;
|
||||
private static var fillByteArrays = [];
|
||||
private static var lenBytes:Array = [
|
||||
-1, -1, -1, -1
|
||||
];
|
||||
private static var lenBytePos:int = 0;
|
||||
private static var len:int = 0;
|
||||
private static var readBa:ByteArray;
|
||||
|
||||
|
||||
public static const DEBUG_VERSION_MAJOR = 1;
|
||||
public static const DEBUG_VERSION_MINOR = 2;
|
||||
public static const DEBUG_VERSION_MINOR = 3;
|
||||
|
||||
public static const MSG_STRING = 0;
|
||||
public static const MSG_LOADER_URL = 1;
|
||||
public static const MSG_LOADER_BYTES = 2;
|
||||
public static const MSG_LONGSTRING = 3;
|
||||
public static const MSG_LOADER_URL_GETBYTES = 4;
|
||||
public static const MSG_LOADER_BYTES_GETBYTES = 5;
|
||||
|
||||
|
||||
public static const MSG_DUMP_BYTEARRAY = 3;
|
||||
public static const MSG_REQUEST_BYTEARRAY = 4;
|
||||
|
||||
|
||||
private static function sendQueue(){
|
||||
var qo = q;
|
||||
q = [];
|
||||
sendHeader();
|
||||
for each(var m in qo){
|
||||
writeMsg(m.data,m.type);
|
||||
}
|
||||
@@ -68,8 +79,7 @@
|
||||
var a3 = s.readUnsignedByte();
|
||||
var a4 = s.readUnsignedByte();
|
||||
var len = (a1<<24)+(a2<<16)+(a3<<8)+a4;
|
||||
|
||||
s.readBytes(b,0,len);
|
||||
s.readBytes(b,0,len);
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -85,24 +95,65 @@
|
||||
private static function readLongString():String {
|
||||
var b:ByteArray = readBytes();
|
||||
return b.readUTFBytes(b.length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function initClient(sname){
|
||||
if(inited){
|
||||
return;
|
||||
}
|
||||
name = sname;
|
||||
inited = true;
|
||||
s = new Socket();
|
||||
s.addEventListener(Event.CONNECT, function(){
|
||||
sendQueue();
|
||||
});
|
||||
var port:int = 0;
|
||||
port = 123456;
|
||||
s.connect("localhost",port);
|
||||
inited = true;
|
||||
try {
|
||||
s = new Socket();
|
||||
s.addEventListener(Event.CONNECT, onSocketConnect);
|
||||
s.addEventListener(ProgressEvent.SOCKET_DATA, onSocketData);
|
||||
var port:int = 0;
|
||||
port = 123456;
|
||||
s.connect("localhost",port);
|
||||
|
||||
inited = true;
|
||||
} catch (e:SecurityError) {
|
||||
trace("Debugger helper failed to connect to localhost");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static function onSocketConnect(event:Event):void {
|
||||
sendQueue();
|
||||
}
|
||||
|
||||
|
||||
private static function onSocketData(event:ProgressEvent):void {
|
||||
while (s.bytesAvailable > 0) {
|
||||
if (lenBytePos < 4) {
|
||||
lenBytes[lenBytePos] = s.readUnsignedByte();
|
||||
lenBytePos++;
|
||||
if (lenBytePos == 4) {
|
||||
len = (lenBytes[0]<<24)+(lenBytes[1]<<16)+(lenBytes[2]<<8)+lenBytes[3];
|
||||
readBa = new ByteArray();
|
||||
}
|
||||
} else {
|
||||
var readLen:int = s.bytesAvailable <= len ? s.bytesAvailable : len;
|
||||
s.readBytes(readBa, readBa.length, readLen);
|
||||
len -= readLen;
|
||||
|
||||
if (len == 0) {
|
||||
lenBytePos = 0;
|
||||
var ba:ByteArray = fillByteArrays.pop();
|
||||
var pos = ba.position;
|
||||
ba.position = 0;
|
||||
ba.length = 0;
|
||||
ba.writeBytes(readBa);
|
||||
if (pos > ba.length) {
|
||||
ba.position = ba.length;
|
||||
} else {
|
||||
ba.position = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function writeLoaderURL(url){
|
||||
writeMsg(url,MSG_LOADER_URL);
|
||||
@@ -113,19 +164,59 @@
|
||||
writeMsg(data,MSG_LOADER_BYTES);
|
||||
}
|
||||
|
||||
public static function writeCommaSeparatedToByteArray(s:String, ba:ByteArray) {
|
||||
var bytes:Array = s.split(",");
|
||||
var pos:uint = ba.position;
|
||||
ba.position = 0;
|
||||
ba.length = 0;
|
||||
for (var i:int = 0; i < bytes.length; i++) {
|
||||
ba.writeByte(bytes[i]);
|
||||
}
|
||||
if (pos > ba.length) {
|
||||
ba.position = ba.length;
|
||||
} else {
|
||||
ba.position = pos;
|
||||
}
|
||||
}
|
||||
|
||||
public static function readCommaSeparatedFromByteArray(ba:ByteArray): String {
|
||||
var s:String = "";
|
||||
var splitter = "";
|
||||
for (var i:int = 0; i < ba.length; i++) {
|
||||
s += splitter;
|
||||
s += ba[i];
|
||||
splitter = ",";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private static function sendHeader() {
|
||||
if (!first) {
|
||||
return;
|
||||
}
|
||||
if (!s.connected) {
|
||||
return;
|
||||
}
|
||||
writeStringNull("debug.version.major="+DEBUG_VERSION_MAJOR+";debug.version.minor="+DEBUG_VERSION_MINOR);
|
||||
writeString(name);
|
||||
first = false;
|
||||
}
|
||||
|
||||
public static function writeMsg(msg,msgType=0){
|
||||
if(!inited){
|
||||
if (failed) {
|
||||
return;
|
||||
}
|
||||
if(!inited) {
|
||||
initClient("");
|
||||
}
|
||||
if(s.connected){
|
||||
if(first){
|
||||
//s.writeByte(0);
|
||||
writeStringNull("debug.version.major="+DEBUG_VERSION_MAJOR+";debug.version.minor="+DEBUG_VERSION_MINOR);
|
||||
writeString(name);
|
||||
first = false;
|
||||
}
|
||||
if ((msg is ByteArray) && msgType == MSG_DUMP_BYTEARRAY) {
|
||||
var ba2:ByteArray = new ByteArray();
|
||||
ba2.writeBytes(msg);
|
||||
msg = ba2;
|
||||
}
|
||||
|
||||
if(s.connected){
|
||||
sendHeader();
|
||||
s.writeByte(msgType);
|
||||
switch(msgType){
|
||||
case MSG_STRING:
|
||||
@@ -137,11 +228,11 @@
|
||||
case MSG_LOADER_BYTES:
|
||||
writeBytes(msg);
|
||||
break;
|
||||
case MSG_LOADER_URL_GETBYTES:
|
||||
writeString(msg);
|
||||
case MSG_DUMP_BYTEARRAY:
|
||||
writeBytes(msg);
|
||||
break;
|
||||
case MSG_LOADER_BYTES_GETBYTES:
|
||||
writeBytes(msg);
|
||||
case MSG_REQUEST_BYTEARRAY:
|
||||
fillByteArrays.push(msg);
|
||||
break;
|
||||
}
|
||||
s.flush();
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
</timelines>
|
||||
<PrinterSettings/>
|
||||
<publishHistory>
|
||||
<PublishItem publishSize="4021" publishTime="1700417069" publishDebug="true"/>
|
||||
<PublishItem publishSize="3974" publishTime="1700415286" publishDebug="true"/>
|
||||
<PublishItem publishSize="4206" publishTime="1700412219" publishDebug="true"/>
|
||||
<PublishItem publishSize="4201" publishTime="1700412018" publishDebug="true"/>
|
||||
<PublishItem publishSize="4206" publishTime="1700411684" publishDebug="true"/>
|
||||
<PublishItem publishSize="3065" publishTime="1700411624"/>
|
||||
<PublishItem publishSize="568" publishTime="1700411559"/>
|
||||
<PublishItem publishSize="4175" publishTime="1700340276" publishDebug="true"/>
|
||||
<PublishItem publishSize="4162" publishTime="1700339789" publishDebug="true"/>
|
||||
<PublishItem publishSize="4121" publishTime="1700339614" publishDebug="true"/>
|
||||
@@ -27,12 +34,5 @@
|
||||
<PublishItem publishSize="1625" publishTime="1414396836"/>
|
||||
<PublishItem publishSize="1620" publishTime="1414395905"/>
|
||||
<PublishItem publishSize="560" publishTime="1414395873"/>
|
||||
<PublishItem publishSize="559" publishTime="1414395847"/>
|
||||
<PublishItem publishSize="559" publishTime="1414395804"/>
|
||||
<PublishItem publishSize="1587" publishTime="1414395524"/>
|
||||
<PublishItem publishSize="1647" publishTime="1414395264"/>
|
||||
<PublishItem publishSize="1668" publishTime="1414394172"/>
|
||||
<PublishItem publishSize="864" publishTime="1414335994"/>
|
||||
<PublishItem publishSize="533" publishTime="1414335971"/>
|
||||
</publishHistory>
|
||||
</DOMDocument>
|
||||
@@ -5,8 +5,8 @@
|
||||
xmlns:xmp="http://ns.adobe.com/xap/1.0/">
|
||||
<xmp:CreatorTool>Adobe Flash Professional CS6 - build 537</xmp:CreatorTool>
|
||||
<xmp:CreateDate>2014-10-26T15:59:21+01:00</xmp:CreateDate>
|
||||
<xmp:MetadataDate>2023-11-18T12:05:50-08:00</xmp:MetadataDate>
|
||||
<xmp:ModifyDate>2023-11-18T12:05:50-08:00</xmp:ModifyDate>
|
||||
<xmp:MetadataDate>2023-11-19T08:32:38-08:00</xmp:MetadataDate>
|
||||
<xmp:ModifyDate>2023-11-19T08:32:38-08:00</xmp:ModifyDate>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about=""
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
@@ -15,7 +15,7 @@
|
||||
<rdf:Description rdf:about=""
|
||||
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
|
||||
xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#">
|
||||
<xmpMM:InstanceID>xmp.iid:CDA31DDF4D86EE11B43B9B2E6D6D7C97</xmpMM:InstanceID>
|
||||
<xmpMM:InstanceID>xmp.iid:D4132A45B886EE11B43B9B2E6D6D7C97</xmpMM:InstanceID>
|
||||
<xmpMM:DocumentID>xmp.did:1476A545885CE411B13FACEEFCD7D43C</xmpMM:DocumentID>
|
||||
<xmpMM:OriginalDocumentID>xmp.did:1476A545885CE411B13FACEEFCD7D43C</xmpMM:OriginalDocumentID>
|
||||
<xmpMM:History>
|
||||
@@ -50,6 +50,12 @@
|
||||
<stEvt:when>2014-10-26T15:59:21+01:00</stEvt:when>
|
||||
<stEvt:softwareAgent>Adobe Flash Professional CS6 - build 481</stEvt:softwareAgent>
|
||||
</rdf:li>
|
||||
<rdf:li rdf:parseType="Resource">
|
||||
<stEvt:action>created</stEvt:action>
|
||||
<stEvt:instanceID>xmp.iid:D4132A45B886EE11B43B9B2E6D6D7C97</stEvt:instanceID>
|
||||
<stEvt:when>2014-10-26T15:59:21+01:00</stEvt:when>
|
||||
<stEvt:softwareAgent>Adobe Flash Professional CS6 - build 481</stEvt:softwareAgent>
|
||||
</rdf:li>
|
||||
</rdf:Seq>
|
||||
</xmpMM:History>
|
||||
</rdf:Description>
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
<PackagePaths></PackagePaths>
|
||||
<AS3PackagePaths>.</AS3PackagePaths>
|
||||
<AS3ConfigConst>CONFIG::FLASH_AUTHORING="true";</AS3ConfigConst>
|
||||
<DebuggingPermitted>0</DebuggingPermitted>
|
||||
<DebuggingPermitted>1</DebuggingPermitted>
|
||||
<DebuggingPassword></DebuggingPassword>
|
||||
<CompressMovie>1</CompressMovie>
|
||||
<CompressionType>0</CompressionType>
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user