From b72ee36b292cb89183c9910652f040d53fdf1829 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 8 Mar 2006 00:56:23 +0000 Subject: [PATCH] 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 --- src/java/com/threerings/io/Streamer.java | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/java/com/threerings/io/Streamer.java b/src/java/com/threerings/io/Streamer.java index 8374331a5..e17347c2b 100644 --- a/src/java/com/threerings/io/Streamer.java +++ b/src/java/com/threerings/io/Streamer.java @@ -56,17 +56,23 @@ public class Streamer */ public synchronized static boolean isStreamable (Class target) { - // if we have a streamer registered for this class, then it's - // definitely streamable - if (_streamers.containsKey(target)) { - return true; - } + do { + // if we've got a streamer for it, it's good + if (_streamers.containsKey(target)) { + return true; + } - // return true if it is a streamable or already registered type, - // or an array of same - Class uclass = target.isArray() ? target.getComponentType() : target; - return (_streamers.containsKey(uclass) || - Streamable.class.isAssignableFrom(uclass)); + // if it's an array, check the component type + if (target.isArray()) { + target = target.getComponentType(); + // and loop back around for another go + } else { + break; + } + } while (true); + + // it'll be ok if the type (or component type) is Streamable + return Streamable.class.isAssignableFrom(target); } /**