Handle short[]'s on the actionscript side of streaming. This gets a little ugly given the lack of a primitive short on the actionscript side...
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6071 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -52,6 +52,12 @@ public dynamic class TypedArray extends Array
|
|||||||
return "[L" + cname + ";";
|
return "[L" + cname + ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Because we have no actionscript type to check, we'll just handle this one manually. */
|
||||||
|
public static function getJavaShortType () :String
|
||||||
|
{
|
||||||
|
return "[S";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory method to create a TypedArray for holding objects of the specified type.
|
* A factory method to create a TypedArray for holding objects of the specified type.
|
||||||
*/
|
*/
|
||||||
@@ -64,6 +70,18 @@ public dynamic class TypedArray extends Array
|
|||||||
return ta;
|
return ta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A factory method to create a TypedArray for holding data meant as java shorts.
|
||||||
|
*/
|
||||||
|
public static function createShort (initialValues :Array = null) :TypedArray
|
||||||
|
{
|
||||||
|
var ta :TypedArray = new TypedArray(getJavaShortType());
|
||||||
|
if (initialValues != null) {
|
||||||
|
ta.addAll(initialValues);
|
||||||
|
}
|
||||||
|
return ta;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a TypedArray
|
* Create a TypedArray
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ public class ArrayStreamer extends Streamer
|
|||||||
} else if (secondChar === "Z") {
|
} else if (secondChar === "Z") {
|
||||||
_elementType = Boolean;
|
_elementType = Boolean;
|
||||||
|
|
||||||
|
} else if (secondChar === "S") {
|
||||||
|
_elementType = PrimitiveShort;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.getLog(this).warning("Other array types are not yet handled", "jname", jname);
|
Log.getLog(this).warning("Other array types are not yet handled", "jname", jname);
|
||||||
throw new Error("Don't know how to stream '" + jname + "' instances.");
|
throw new Error("Don't know how to stream '" + jname + "' instances.");
|
||||||
@@ -87,7 +90,11 @@ public class ArrayStreamer extends Streamer
|
|||||||
for (ii = 0; ii < arr.length; ii++) {
|
for (ii = 0; ii < arr.length; ii++) {
|
||||||
out.writeInt(int(arr[ii]));
|
out.writeInt(int(arr[ii]));
|
||||||
}
|
}
|
||||||
|
} else if (_elementType == PrimitiveShort) {
|
||||||
|
for (ii = 0; ii < arr.length; ii++) {
|
||||||
|
out.writeShort(int(arr[ii]));
|
||||||
|
}
|
||||||
|
|
||||||
} else if (_elementType == Boolean) {
|
} else if (_elementType == Boolean) {
|
||||||
for (ii = 0; ii < arr.length; ii++) {
|
for (ii = 0; ii < arr.length; ii++) {
|
||||||
out.writeBoolean(Boolean(arr[ii]));
|
out.writeBoolean(Boolean(arr[ii]));
|
||||||
@@ -125,6 +132,11 @@ public class ArrayStreamer extends Streamer
|
|||||||
arr[ii] = ins.readInt();
|
arr[ii] = ins.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (_elementType == PrimitiveShort) {
|
||||||
|
for (ii = 0; ii < arr.length; ii++) {
|
||||||
|
arr[ii] = ins.readShort();
|
||||||
|
}
|
||||||
|
|
||||||
} else if (_elementType == Boolean) {
|
} else if (_elementType == Boolean) {
|
||||||
for (ii = 0; ii < arr.length; ii++) {
|
for (ii = 0; ii < arr.length; ii++) {
|
||||||
arr[ii] = ins.readBoolean();
|
arr[ii] = ins.readBoolean();
|
||||||
@@ -182,3 +194,8 @@ public class ArrayStreamer extends Streamer
|
|||||||
protected var _isFinal :Boolean;
|
protected var _isFinal :Boolean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A class to represent that the data in question should be handled as a java primitive short. */
|
||||||
|
class PrimitiveShort
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user