Wrapped -> Boxed.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5195 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2008-06-23 21:09:14 +00:00
parent 0d93214e22
commit f3abe8507b
14 changed files with 54 additions and 44 deletions
@@ -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();
}
}
}
@@ -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);
@@ -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();
}
}
@@ -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]);
@@ -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();
}
}
@@ -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();
}
}
@@ -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();
}
}
}
@@ -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;
}
}
+3 -3
View File
@@ -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;
}
+3 -3
View File
@@ -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;
}
+3 -3
View File
@@ -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;
}
+3 -3
View File
@@ -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;
}
+7 -3
View File
@@ -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;
}
+3 -3
View File
@@ -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;
}