While working on Streaming arrays in actionscript I realized that
our streaming system should work with multidimensional arrays: in fact it kinda already did, if the element type of the outermost array was something for which we already had a streamer. Thus, int[][] worked, Object[][] worked, etc. One small method change and now arbitrary multidimensional arrays will work. Why bother? Consistency, and the way I'm working on doing even the int[][] arrays in actionscript supports unlimited dimensions, so why not? git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3921 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -56,17 +56,23 @@ public class Streamer
|
|||||||
*/
|
*/
|
||||||
public synchronized static boolean isStreamable (Class target)
|
public synchronized static boolean isStreamable (Class target)
|
||||||
{
|
{
|
||||||
// if we have a streamer registered for this class, then it's
|
do {
|
||||||
// definitely streamable
|
// if we've got a streamer for it, it's good
|
||||||
if (_streamers.containsKey(target)) {
|
if (_streamers.containsKey(target)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if it is a streamable or already registered type,
|
// if it's an array, check the component type
|
||||||
// or an array of same
|
if (target.isArray()) {
|
||||||
Class uclass = target.isArray() ? target.getComponentType() : target;
|
target = target.getComponentType();
|
||||||
return (_streamers.containsKey(uclass) ||
|
// and loop back around for another go
|
||||||
Streamable.class.isAssignableFrom(uclass));
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
|
||||||
|
// it'll be ok if the type (or component type) is Streamable
|
||||||
|
return Streamable.class.isAssignableFrom(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user