From 84855f8fe01ac999a62836c45238c3989962a7db Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 9 May 2007 01:17:13 +0000 Subject: [PATCH] Enhanced debuggery, reenabled new streaming bits because now they should really really work. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4705 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/io/ObjectInputStream.as | 8 ++--- .../com/threerings/io/ObjectOutputStream.as | 4 +++ .../com/threerings/io/FieldMarshaller.java | 9 +++--- .../com/threerings/io/ObjectInputStream.java | 2 +- .../com/threerings/io/ObjectOutputStream.java | 29 +++++-------------- src/java/com/threerings/io/Streamer.java | 3 +- 6 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/as/com/threerings/io/ObjectInputStream.as b/src/as/com/threerings/io/ObjectInputStream.as index 7488a0e0a..818b69c36 100644 --- a/src/as/com/threerings/io/ObjectInputStream.as +++ b/src/as/com/threerings/io/ObjectInputStream.as @@ -87,8 +87,7 @@ public class ObjectInputStream var cname :String = Translations.getFromServer(jname); cmap = new ClassMapping(code, cname, streamer); _classMap[code] = cmap; - if (DEBUG) log.debug(DEBUG_ID + - "Created mapping: (" + code + "): " + cname); + if (DEBUG) log.debug(DEBUG_ID + "Created mapping: (" + code + "): " + cname); } else { cmap = (_classMap[code] as ClassMapping); @@ -96,8 +95,9 @@ public class ObjectInputStream throw new IOError("Read object for which we have no " + "registered class metadata [code=" + code + "]."); } - if (DEBUG) log.debug(DEBUG_ID + "Read known code: (" + - code + ": " + cmap.classname + ")"); + if (DEBUG) { + log.debug(DEBUG_ID + "Read known code: (" + code + ": " + cmap.classname + ")"); + } } // log.debug("Creating object sleeve..."); diff --git a/src/as/com/threerings/io/ObjectOutputStream.as b/src/as/com/threerings/io/ObjectOutputStream.as index c7b2b476b..d7b47f93e 100644 --- a/src/as/com/threerings/io/ObjectOutputStream.as +++ b/src/as/com/threerings/io/ObjectOutputStream.as @@ -70,6 +70,10 @@ public class ObjectOutputStream throw new Error("Too many unique classes written to ObjectOutputStream"); } + if (ObjectInputStream.DEBUG) { + log.debug("Assigning class code [code=" + cmap.code + ", class=" + cname + "]."); + } + writeShort(-cmap.code); writeUTF((streamer == null) ? Translations.getToServer(cname) : streamer.getJavaClassName()); diff --git a/src/java/com/threerings/io/FieldMarshaller.java b/src/java/com/threerings/io/FieldMarshaller.java index a3c4e4641..1ec49b2b1 100644 --- a/src/java/com/threerings/io/FieldMarshaller.java +++ b/src/java/com/threerings/io/FieldMarshaller.java @@ -57,8 +57,6 @@ public abstract class FieldMarshaller createMarshallers(); } - if (false) { // TEMP DISABLE - // first look to see if this field has custom reader/writer methods Method reader = null, writer = null; try { @@ -78,8 +76,6 @@ public abstract class FieldMarshaller // fall through to using reflection on the fields... } - } // END TEMP DISABLE - Class ftype = field.getType(); if (ftype.isInterface()) { // if the class is a pure interface, use Object. @@ -151,6 +147,11 @@ public abstract class FieldMarshaller } } + public String toString () + { + return "StreamerMarshaller:" + _streamer.toString(); + } + /** The streamer we use to read and write our field. */ protected Streamer _streamer; } diff --git a/src/java/com/threerings/io/ObjectInputStream.java b/src/java/com/threerings/io/ObjectInputStream.java index 833bc408c..66a6e3f36 100644 --- a/src/java/com/threerings/io/ObjectInputStream.java +++ b/src/java/com/threerings/io/ObjectInputStream.java @@ -118,7 +118,7 @@ public class ObjectInputStream extends DataInputStream Class sclass = Class.forName(cname, true, _loader); Streamer streamer = Streamer.getStreamer(sclass); if (STREAM_DEBUG) { - log.info(hashCode() + ": New class '" + cname + "'."); + log.info(hashCode() + ": New class '" + cname + "' [code=" + code + "]."); } // sanity check diff --git a/src/java/com/threerings/io/ObjectOutputStream.java b/src/java/com/threerings/io/ObjectOutputStream.java index 9decbaa4f..4042db190 100644 --- a/src/java/com/threerings/io/ObjectOutputStream.java +++ b/src/java/com/threerings/io/ObjectOutputStream.java @@ -26,29 +26,12 @@ import java.io.DataOutputStream; import java.io.IOException; import java.util.HashMap; +import static com.threerings.NaryaLog.log; + /** * Used to write {@link Streamable} objects to an {@link OutputStream}. Other common object types - * are supported as well: - * - *
- * Boolean
- * Byte
- * Character
- * Short
- * Integer
- * Long
- * Float
- * Double
- * boolean[]
- * byte[]
- * char[]
- * short[]
- * int[]
- * long[]
- * float[]
- * double[]
- * Object[]
- * 
+ * are supported as well: Boolean, Byte, Character, Short, Integer, Long, Float, Double, + * boolean[], byte[], char[], short[], int[], long[], float[], double[], Object[]. * * @see Streamable */ @@ -102,6 +85,10 @@ public class ObjectOutputStream extends DataOutputStream // we specifically do not inline the getStreamer() call into the ClassMapping // constructor because we want to be sure not to call _nextCode++ if getStreamer() // throws an exception + if (ObjectInputStream.STREAM_DEBUG) { + log.info(hashCode() + ": Creating class mapping [code=" + _nextCode + + ", class=" + sclass.getName() + "]."); + } cmap = new ClassMapping(_nextCode++, sclass, streamer); _classmap.put(sclass, cmap); diff --git a/src/java/com/threerings/io/Streamer.java b/src/java/com/threerings/io/Streamer.java index 9b97a28ff..db265cafe 100644 --- a/src/java/com/threerings/io/Streamer.java +++ b/src/java/com/threerings/io/Streamer.java @@ -372,7 +372,8 @@ public class Streamer } try { if (ObjectInputStream.STREAM_DEBUG) { - log.info(in.hashCode() + ": Reading field '" + field.getName() + "'."); + log.info(in.hashCode() + ": Reading field '" + field.getName() + "' " + + "with " + fm + "."); } // gracefully deal with objects that have had new fields added to their class // definition