From f3abe8507b6100ae05a7027af3103ee71b252ef7 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 23 Jun 2008 21:09:14 +0000 Subject: [PATCH] Wrapped -> Boxed. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5195 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/client/InvocationDirector.as | 14 +++++++------- .../data/InvocationMarshaller_ResultMarshaller.as | 6 +++--- .../presents/dobj/AttributeChangedEvent.as | 6 +++--- src/as/com/threerings/presents/dobj/DSet.as | 6 ++++++ .../presents/dobj/ElementUpdatedEvent.as | 6 +++--- .../threerings/presents/dobj/EntryRemovedEvent.as | 6 +++--- .../com/threerings/presents/dobj/MessageEvent.as | 6 +++--- .../com/threerings/util/{Wrapped.as => Boxed.as} | 8 ++++---- src/as/com/threerings/util/Byte.as | 6 +++--- src/as/com/threerings/util/Float.as | 6 +++--- src/as/com/threerings/util/Integer.as | 6 +++--- src/as/com/threerings/util/Short.as | 6 +++--- src/as/com/threerings/util/StringUtil.as | 10 +++++++--- src/as/com/threerings/util/langBoolean.as | 6 +++--- 14 files changed, 54 insertions(+), 44 deletions(-) rename src/as/com/threerings/util/{Wrapped.as => Boxed.as} (87%) diff --git a/src/as/com/threerings/presents/client/InvocationDirector.as b/src/as/com/threerings/presents/client/InvocationDirector.as index fff6b0229..26445cd43 100644 --- a/src/as/com/threerings/presents/client/InvocationDirector.as +++ b/src/as/com/threerings/presents/client/InvocationDirector.as @@ -24,9 +24,9 @@ package com.threerings.presents.client { import flash.errors.IllegalOperationError; import flash.utils.getTimer; // function import +import com.threerings.util.Boxed; import com.threerings.util.HashMap; import com.threerings.util.Log; -import com.threerings.util.Wrapped; import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller; @@ -243,7 +243,7 @@ public class InvocationDirector return; } - unwrapArgs(args); + unboxArgs(args); // log.info("Dispatching invocation response [listener=" + listener + // ", methId=" + methodId + ", args=" + StringUtil.toString(args) + "]."); @@ -280,7 +280,7 @@ public class InvocationDirector return; } - unwrapArgs(args); + unboxArgs(args); // log.info("Dispatching invocation notification [receiver=" + decoder.receiver + // ", methodId=" + methodId + ", args=" + StringUtil.toString(args) + "]."); @@ -326,14 +326,14 @@ public class InvocationDirector } /** - * Unwrap any arguments that have arrived from the server in wrapped types. + * Unbox any arguments that have arrived from the server in boxed types. */ - protected function unwrapArgs (args :Array) :void + protected function unboxArgs (args :Array) :void { if (args != null) { for (var ii :int = 0; ii < args.length; ii++) { - if (args[ii] is Wrapped) { - args[ii] = (args[ii] as Wrapped).unwrap(); + if (args[ii] is Boxed) { + args[ii] = (args[ii] as Boxed).unbox(); } } } diff --git a/src/as/com/threerings/presents/data/InvocationMarshaller_ResultMarshaller.as b/src/as/com/threerings/presents/data/InvocationMarshaller_ResultMarshaller.as index 45f936740..7cb475ef9 100644 --- a/src/as/com/threerings/presents/data/InvocationMarshaller_ResultMarshaller.as +++ b/src/as/com/threerings/presents/data/InvocationMarshaller_ResultMarshaller.as @@ -21,7 +21,7 @@ package com.threerings.presents.data { -import com.threerings.util.Wrapped; +import com.threerings.util.Boxed; import com.threerings.presents.client.InvocationService_ResultListener; @@ -36,8 +36,8 @@ public class InvocationMarshaller_ResultMarshaller switch (methodId) { case REQUEST_PROCESSED: var result :Object = args[0]; - if (result is Wrapped) { - result = (result as Wrapped).unwrap(); + if (result is Boxed) { + result = (result as Boxed).unbox(); } (listener as InvocationService_ResultListener).requestProcessed( result); diff --git a/src/as/com/threerings/presents/dobj/AttributeChangedEvent.as b/src/as/com/threerings/presents/dobj/AttributeChangedEvent.as index 970752eec..543ec485f 100644 --- a/src/as/com/threerings/presents/dobj/AttributeChangedEvent.as +++ b/src/as/com/threerings/presents/dobj/AttributeChangedEvent.as @@ -24,8 +24,8 @@ package com.threerings.presents.dobj { import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectOutputStream; +import com.threerings.util.Boxed; import com.threerings.util.StringBuilder; -import com.threerings.util.Wrapped; /** * An attribute changed event is dispatched when a single attribute of a @@ -126,8 +126,8 @@ public class AttributeChangedEvent extends NamedEvent _value = ins.readObject(); // possibly convert the value - if (_value is Wrapped) { - _value = (_value as Wrapped).unwrap(); + if (_value is Boxed) { + _value = (_value as Boxed).unbox(); } } diff --git a/src/as/com/threerings/presents/dobj/DSet.as b/src/as/com/threerings/presents/dobj/DSet.as index 036d80ec4..b4b6eb419 100644 --- a/src/as/com/threerings/presents/dobj/DSet.as +++ b/src/as/com/threerings/presents/dobj/DSet.as @@ -234,6 +234,12 @@ public class DSet // documentation inherited from interface Streamable public function writeObject (out :ObjectOutputStream) :void { + if (_entries.length > 0) { + Log.getLog(this).warning("Error! We can't send DSets back to the server until we " + + "fix up the actionscript implementation!"); + Log.dumpStack(); + } + out.writeInt(_entries.length); for (var ii :int = 0; ii < _entries.length; ii++) { out.writeObject(_entries[ii]); diff --git a/src/as/com/threerings/presents/dobj/ElementUpdatedEvent.as b/src/as/com/threerings/presents/dobj/ElementUpdatedEvent.as index 20b4c91a6..9dc4b9a59 100644 --- a/src/as/com/threerings/presents/dobj/ElementUpdatedEvent.as +++ b/src/as/com/threerings/presents/dobj/ElementUpdatedEvent.as @@ -24,8 +24,8 @@ package com.threerings.presents.dobj { import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectOutputStream; +import com.threerings.util.Boxed; import com.threerings.util.StringBuilder; -import com.threerings.util.Wrapped; /** * An element updated event is dispatched when an element of an array @@ -118,8 +118,8 @@ public class ElementUpdatedEvent extends NamedEvent _value = ins.readObject(); _index = ins.readInt(); - if (_value is Wrapped) { - _value = (_value as Wrapped).unwrap(); + if (_value is Boxed) { + _value = (_value as Boxed).unbox(); } } diff --git a/src/as/com/threerings/presents/dobj/EntryRemovedEvent.as b/src/as/com/threerings/presents/dobj/EntryRemovedEvent.as index 0dcb5a655..8ab6e13a3 100644 --- a/src/as/com/threerings/presents/dobj/EntryRemovedEvent.as +++ b/src/as/com/threerings/presents/dobj/EntryRemovedEvent.as @@ -24,9 +24,9 @@ package com.threerings.presents.dobj { import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectOutputStream; +import com.threerings.util.Boxed; import com.threerings.util.Log; import com.threerings.util.StringBuilder; -import com.threerings.util.Wrapped; /** * An entry removed event is dispatched when an entry is removed from a @@ -125,8 +125,8 @@ public class EntryRemovedEvent extends NamedEvent super.readObject(ins); _key = ins.readObject(); - if (_key is Wrapped) { - _key = (_key as Wrapped).unwrap(); + if (_key is Boxed) { + _key = (_key as Boxed).unbox(); } } diff --git a/src/as/com/threerings/presents/dobj/MessageEvent.as b/src/as/com/threerings/presents/dobj/MessageEvent.as index d20b42fe2..aa84e5a75 100644 --- a/src/as/com/threerings/presents/dobj/MessageEvent.as +++ b/src/as/com/threerings/presents/dobj/MessageEvent.as @@ -25,8 +25,8 @@ import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectOutputStream; import com.threerings.io.TypedArray; +import com.threerings.util.Boxed; import com.threerings.util.StringBuilder; -import com.threerings.util.Wrapped; /** * A message event is used to dispatch a message to all subscribers of a @@ -119,8 +119,8 @@ public class MessageEvent extends NamedEvent if (_args != null) { for (var ii :int = _args.length - 1; ii >= 0; ii--) { - if (_args[ii] is Wrapped) { - _args[ii] = (_args[ii] as Wrapped).unwrap(); + if (_args[ii] is Boxed) { + _args[ii] = (_args[ii] as Boxed).unbox(); } } } diff --git a/src/as/com/threerings/util/Wrapped.as b/src/as/com/threerings/util/Boxed.as similarity index 87% rename from src/as/com/threerings/util/Wrapped.as rename to src/as/com/threerings/util/Boxed.as index 5574c17a0..10b37e711 100644 --- a/src/as/com/threerings/util/Wrapped.as +++ b/src/as/com/threerings/util/Boxed.as @@ -22,13 +22,13 @@ package com.threerings.util { /** - * An interface implemented by our wrapper classes. + * An interface implemented by our "boxed" data classes. */ -public interface Wrapped +public interface Boxed { /** - * Return the wrapped value. + * Return the unboxed value. */ - function unwrap () :Object; + function unbox () :Object; } } diff --git a/src/as/com/threerings/util/Byte.as b/src/as/com/threerings/util/Byte.as index 77ca0234b..b9f17b88f 100644 --- a/src/as/com/threerings/util/Byte.as +++ b/src/as/com/threerings/util/Byte.as @@ -25,7 +25,7 @@ package com.threerings.util { * Equivalent to java.lang.Byte. */ public class Byte - implements Equalable, Wrapped + implements Equalable, Boxed { public var value :int; @@ -45,8 +45,8 @@ public class Byte return (other is Byte) && (value === (other as Byte).value); } - // from Wrapped - public function unwrap () :Object + // from Boxed + public function unbox () :Object { return value; } diff --git a/src/as/com/threerings/util/Float.as b/src/as/com/threerings/util/Float.as index 70cef7d76..44d27efc0 100644 --- a/src/as/com/threerings/util/Float.as +++ b/src/as/com/threerings/util/Float.as @@ -25,7 +25,7 @@ package com.threerings.util { * Equivalent to java.lang.Float. */ public class Float - implements Equalable, Wrapped + implements Equalable, Boxed { public var value :Number; @@ -45,8 +45,8 @@ public class Float return (other is Float) && (value === (other as Float).value); } - // from Wrapped - public function unwrap () :Object + // from Boxed + public function unbox () :Object { return value; } diff --git a/src/as/com/threerings/util/Integer.as b/src/as/com/threerings/util/Integer.as index 5ec321a1c..f77f40d3c 100644 --- a/src/as/com/threerings/util/Integer.as +++ b/src/as/com/threerings/util/Integer.as @@ -30,7 +30,7 @@ package com.threerings.util { // Number <--> java.lang.Double. However, a Number object that refers // to an integer value is actually an int. Yes, it's totally fucked. public class Integer - implements Equalable, Wrapped + implements Equalable, Boxed { public var value :int; @@ -50,8 +50,8 @@ public class Integer return (other is Integer) && (value === (other as Integer).value); } - // from Wrapped - public function unwrap () :Object + // from Boxed + public function unbox () :Object { return value; } diff --git a/src/as/com/threerings/util/Short.as b/src/as/com/threerings/util/Short.as index 3609aacda..e1d17721e 100644 --- a/src/as/com/threerings/util/Short.as +++ b/src/as/com/threerings/util/Short.as @@ -25,7 +25,7 @@ package com.threerings.util { * Equivalent to java.lang.Short. */ public class Short - implements Equalable, Wrapped + implements Equalable, Boxed { /** The minimum possible short value. */ public static const MIN_VALUE :int = -Math.pow(2, 15); @@ -52,8 +52,8 @@ public class Short return (other is Short) && (value === (other as Short).value); } - // from Wrapped - public function unwrap () :Object + // from Boxed + public function unbox () :Object { return value; } diff --git a/src/as/com/threerings/util/StringUtil.as b/src/as/com/threerings/util/StringUtil.as index 597dc0eaf..51f6a2562 100644 --- a/src/as/com/threerings/util/StringUtil.as +++ b/src/as/com/threerings/util/StringUtil.as @@ -417,9 +417,13 @@ public class StringUtil return null; } var ba :ByteArray = new ByteArray(); - for (var ii :int = 0; ii < s.length; ii++) { - ba[ii] = int(s.charCodeAt(ii)) & 0xFF; - } +// if (true) { + for (var ii :int = 0; ii < s.length; ii++) { + ba[ii] = int(s.charCodeAt(ii)) & 0xFF; + } +// } else { +// ba.writeUTFBytes(s); +// } return ba; } diff --git a/src/as/com/threerings/util/langBoolean.as b/src/as/com/threerings/util/langBoolean.as index 50d754772..9f2f247e5 100644 --- a/src/as/com/threerings/util/langBoolean.as +++ b/src/as/com/threerings/util/langBoolean.as @@ -29,7 +29,7 @@ import com.threerings.io.Streamable; * Equivalent to java.lang.Boolean. */ public class langBoolean - implements Equalable, Streamable, Wrapped + implements Equalable, Streamable, Boxed { public var value :Boolean; @@ -62,8 +62,8 @@ public class langBoolean value = ins.readBoolean(); } - // from Wrapped - public function unwrap () :Object + // from Boxed + public function unbox () :Object { return value; }