A signed 64-bit integer can be stored as two 32-bit integers in Actionscript, but converting
them to a single number becomes inconvenient for values larger than an single int, and tricky when the value is negative (i.e. in two's complement split into two words, with sign bit only in the high int). Instead of splitting a long into two ints, we store it internally as a byte array that corresponds exactly to Java's serialized version (sequence of eight bytes, high byte first), and we provide accessors to convert to and from Actionscript numbers. This makes Java Long values readable in Actionscript, and vice versa. Unfortunately, Actionscript does not have a native 64-bit integer - the closest equivalent is the Number class. Since this is a double float with a 52-bit mantissa, very large long values will suffer precision loss during conversion. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4811 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -87,8 +87,8 @@ public class ConMgrStats extends SimpleStreamableObject
|
||||
overQueueSize = ins.readInt();
|
||||
connects = ins.readInt();
|
||||
disconnects = ins.readInt();
|
||||
bytesIn = new Long(ins.readInt(), ins.readInt());
|
||||
bytesOut = new Long(ins.readInt(), ins.readInt());
|
||||
bytesIn = ins.readField(Long) as Long;
|
||||
bytesOut = ins.readField(Long) as Long;
|
||||
msgsIn = ins.readInt();
|
||||
msgsOut = ins.readInt();
|
||||
}
|
||||
@@ -103,10 +103,8 @@ public class ConMgrStats extends SimpleStreamableObject
|
||||
out.writeInt(overQueueSize);
|
||||
out.writeInt(connects);
|
||||
out.writeInt(disconnects);
|
||||
out.writeInt(bytesIn == null ? 0 : bytesIn.low);
|
||||
out.writeInt(bytesIn == null ? 0 : bytesIn.high);
|
||||
out.writeInt(bytesOut == null ? 0 : bytesOut.low);
|
||||
out.writeInt(bytesOut == null ? 0 : bytesOut.high);
|
||||
out.writeField(bytesIn);
|
||||
out.writeField(bytesOut);
|
||||
out.writeInt(msgsIn);
|
||||
out.writeInt(msgsOut);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user