Checkpoint.

Never in my life have I spent so much time debugging so little.
I think the flash player is full of bugs, I've learned to just run
everything two or three times and chase the error that happens the most. Fun!


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3929 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-03-09 02:55:07 +00:00
parent 15cf89770f
commit 04255b383b
15 changed files with 101 additions and 41 deletions
+2 -11
View File
@@ -99,16 +99,7 @@ public class Streamer
public function writeObject (obj :Object, out :ObjectOutputStream) :void public function writeObject (obj :Object, out :ObjectOutputStream) :void
//throws IOError //throws IOError
{ {
trace("TODO"); throw new Error("Abstract");
if (obj is Array) {
trace("Arrays not yet done. Crap!");
/**
var arr :Array = Array(obj); // not strictly necessary
var length :int = arr.length;
out.writeInt(length);
*/
}
} }
public function createObject (ins :ObjectInputStream) :Object public function createObject (ins :ObjectInputStream) :Object
@@ -121,7 +112,7 @@ public class Streamer
public function readObject (obj :Object, ins :ObjectInputStream) :void public function readObject (obj :Object, ins :ObjectInputStream) :void
//throws IOError //throws IOError
{ {
trace("TODO"); throw new Error("Abstract");
} }
/** /**
+5
View File
@@ -1,10 +1,15 @@
package com.threerings.io { package com.threerings.io {
import com.threerings.presents.Log;
public dynamic class TypedArray extends Array public dynamic class TypedArray extends Array
{ {
public function TypedArray (jtype :String) public function TypedArray (jtype :String)
{ {
_jtype = jtype; _jtype = jtype;
if (_jtype == "" || _jtype == null) {
Log.info("Created a typed array with bogus type {" + _jtype + "}");
}
} }
public function getJavaType () :String public function getJavaType () :String
@@ -16,6 +16,7 @@ public class ArrayStreamer extends Streamer
{ {
public function ArrayStreamer (jname :String) public function ArrayStreamer (jname :String)
{ {
Log.debug("Created an array streamer for type: {" + jname + "}");
super(TypedArray, jname); super(TypedArray, jname);
if (jname.charAt(1) === "[") { if (jname.charAt(1) === "[") {
@@ -253,7 +253,7 @@ public class Client extends EventDispatcher
*/ */
public function gotPong (pong :PongResponse) :void public function gotPong (pong :PongResponse) :void
{ {
// TODO: compute time delta bowl-shit // TODO: compute time delta?
} }
/** /**
@@ -78,7 +78,7 @@ public class ClientDObjectMgr
_actionInterval = new Timer(500); //TODO! _actionInterval = new Timer(500); //TODO!
_actionInterval.addEventListener(TimerEvent.TIMER, processNextAction); _actionInterval.addEventListener(TimerEvent.TIMER, processNextAction);
_actionInterval.start(); //_actionInterval.start();
} }
// documentation inherited from interface DObjectManager // documentation inherited from interface DObjectManager
@@ -117,6 +117,7 @@ public class ClientDObjectMgr
{ {
// queue up an action // queue up an action
_actions.push(new ObjectAction(oid, target, subscribe)); _actions.push(new ObjectAction(oid, target, subscribe));
_actionInterval.start();
} }
// inherit documentation from the interface // inherit documentation from the interface
@@ -180,6 +181,7 @@ public class ClientDObjectMgr
{ {
// append it to our queue // append it to our queue
_actions.push(msg); _actions.push(msg);
_actionInterval.start();
} }
/** /**
@@ -190,6 +192,7 @@ public class ClientDObjectMgr
{ {
// process the next event on our queue // process the next event on our queue
if (_actions.length == 0) { if (_actions.length == 0) {
_actionInterval.stop();
return; return;
} }
@@ -411,7 +414,7 @@ public class ClientDObjectMgr
* Called periodically to flush any objects that have been lingering * Called periodically to flush any objects that have been lingering
* due to a previously enacted flush delay. * due to a previously enacted flush delay.
*/ */
protected function flushObjects () :void protected function flushObjects (event :TimerEvent) :void
{ {
var now :Number = new Date().getTime(); var now :Number = new Date().getTime();
for (var oid :String in _flushes.keys()) { for (var oid :String in _flushes.keys()) {
@@ -102,7 +102,7 @@ public class Communicator
// write the message (ends up in _outBuffer) // write the message (ends up in _outBuffer)
_outStream.writeObject(msg); _outStream.writeObject(msg);
Log.debug("outBuffer: " + Util.bytesToString(_outBuffer)); // Log.debug("outBuffer: " + Util.bytesToString(_outBuffer));
// Frame it by writing the length, then the bytes. // Frame it by writing the length, then the bytes.
// We add 4 to the length, because the length is of the entire frame // We add 4 to the length, because the length is of the entire frame
@@ -114,7 +114,9 @@ public class InvocationDirector
{ {
_clobj.startTransaction(); _clobj.startTransaction();
try { try {
for each (var decoder :InvocationDecoder in _reclist) { for (var itr :IViewCursor = _reclist.getCursor(); itr.moveNext(); ) {
var decoder :InvocationDecoder =
(itr.current as InvocationDecoder);
assignReceiverId(decoder); assignReceiverId(decoder);
} }
} finally { } finally {
@@ -17,7 +17,7 @@ public class TestClient extends Client
var g1 :String = null; var g1 :String = null;
var g2 :String = String(g1); var g2 :String = String(g1);
Log.debug("foo: " + (g1 === g2)); Log.debug("foo: " + (g1 === g2) + ", *" + g2 + "*, " + g2.length);
var duckie :Duck = new Goose(); var duckie :Duck = new Goose();
duckie.screw(); duckie.screw();
@@ -92,10 +92,6 @@ public class TestClient extends Client
{ {
var i :int = TimeBaseMarshaller.GET_TIME_OID; var i :int = TimeBaseMarshaller.GET_TIME_OID;
} }
public function b () :void
{
}
} }
} }
@@ -114,7 +110,7 @@ class HelperClass
public function HelperClass (cli :TestClient) public function HelperClass (cli :TestClient)
{ {
_cli = cli; _cli = cli;
_cli.b(); //_cli.b();
} }
public function hype () :void public function hype () :void
@@ -2,6 +2,9 @@ package com.threerings.presents.dobj {
import flash.util.StringBuilder; import flash.util.StringBuilder;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/** /**
* An attribute changed event is dispatched when a single attribute of a * An attribute changed event is dispatched when a single attribute of a
* distributed object has changed. It can also be constructed to request * distributed object has changed. It can also be constructed to request
@@ -60,7 +63,8 @@ public class AttributeChangedEvent extends NamedEvent
* used). * used).
*/ */
public function AttributeChangedEvent ( public function AttributeChangedEvent (
targetOid :int, name :String, value :Object, oldValue :Object) targetOid :int = 0, name :String = null, value :Object = null,
oldValue :Object = null)
{ {
super(targetOid, name); super(targetOid, name);
_value = value; _value = value;
@@ -83,6 +87,18 @@ public class AttributeChangedEvent extends NamedEvent
buf.append(", value=", _value); buf.append(", value=", _value);
} }
public override function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeObject(_value);
}
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
_value = ins.readObject();
}
protected var _value :Object; protected var _value :Object;
protected var _oldValue :Object = UNSET_OLD_ENTRY; protected var _oldValue :Object = UNSET_OLD_ENTRY;
} }
+19 -4
View File
@@ -16,6 +16,8 @@ public /* abstract */ class DEvent
public function DEvent (targetOid :int) public function DEvent (targetOid :int)
{ {
_toid = targetOid; _toid = targetOid;
//Log.debug("unset old = " + UNSET_OLD_ENTRY);
} }
/** /**
@@ -126,18 +128,31 @@ public /* abstract */ class DEvent
} }
} }
class DummyEntry implements com.threerings.presents.dobj.DSetEntry /*
import com.threerings.presents.dobj.DSetEntry;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
class DummyEntry implements DSetEntry
{ {
public function DummyEntry ()
{
}
public function getKey () :Object public function getKey () :Object
{ {
return null; return null; // dummy
} }
public function writeObject (out :com.threerings.io.ObjectOutputStream) :void public function writeObject (out :ObjectOutputStream) :void
{ {
// dummy
} }
public function readObject (ins :com.threerings.io.ObjectInputStream) :void public function readObject (ins :ObjectInputStream) :void
{ {
// dummy
} }
} }
*/
@@ -92,7 +92,7 @@ public class DObject // extends EventDispatcher
event.friendNotifyListener(listener); event.friendNotifyListener(listener);
if (listener is EventListener) { if (listener is EventListener) {
listener.eventReceived(event); (listener as EventListener).eventReceived(event);
} }
} catch (e :Error) { } catch (e :Error) {
Log.warning("Listener choked during notification " + Log.warning("Listener choked during notification " +
@@ -117,7 +117,6 @@ public class DObject // extends EventDispatcher
Log.warning("Unable to post event, object has no omgr " + Log.warning("Unable to post event, object has no omgr " +
"[oid=" + getOid() + ", class=" + ClassUtil.getClassName(this) + "[oid=" + getOid() + ", class=" + ClassUtil.getClassName(this) +
", event=" + event + "]."); ", event=" + event + "].");
} }
} }
+5 -3
View File
@@ -11,6 +11,7 @@ import com.threerings.util.Equalable;
import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream; import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable; import com.threerings.io.Streamable;
import com.threerings.io.TypedArray;
import com.threerings.presents.Log; import com.threerings.presents.Log;
@@ -241,7 +242,7 @@ public class DSet
return (key as Equalable).equals(otherKey); return (key as Equalable).equals(otherKey);
} else { } else {
throw new Error("Element key is neither simple or Equalabe"); throw new Error("Element key is neither simple or Equalable");
} }
} }
@@ -266,11 +267,12 @@ public class DSet
// documentation inherited from interface Streamable // documentation inherited from interface Streamable
public function readObject (ins :ObjectInputStream) :void public function readObject (ins :ObjectInputStream) :void
{ {
_entries = (ins.readObject() as Array); _entries = (ins.readObject() as TypedArray);
_entries.length = ins.readInt(); // then read the length and limit it _entries.length = ins.readInt(); // then read the length and limit it
} }
/** The entries of the set (in a sparse array). */ /** The entries of the set (in a sparse array). */
protected var _entries :Array; protected var _entries :TypedArray =
new TypedArray("[Lcom.threerings.presents.dobj.DSet$Entry;");
} }
} }
@@ -0,0 +1,31 @@
package com.threerings.presents.dobj {
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
public class DummyEntry
implements DSetEntry
{
public function DummyEntry ()
{
}
// documentation inherited from interface DSetEntry
public function getKey () :Object
{
return null; // dummy
}
// documentation inherited from superinterface Streamable
public function writeObject (out :ObjectOutputStream) :void
{
// dummy
}
// documentation inherited from superinterface Streamable
public function readObject (ins :ObjectInputStream) :void
{
// dummy
}
}
}
@@ -59,7 +59,7 @@ public class EntryUpdatedEvent extends NamedEvent
{ {
// only apply the change if we haven't already // only apply the change if we haven't already
if (_oldEntry == UNSET_OLD_ENTRY) { if (_oldEntry == UNSET_OLD_ENTRY) {
var dset :DSet = target[_name]; var dset :DSet = (target[_name] as DSet);
// fetch the previous value for interested callers // fetch the previous value for interested callers
_oldEntry = dset.update(_entry); _oldEntry = dset.update(_entry);
if (_oldEntry == null) { if (_oldEntry == null) {
+7 -8
View File
@@ -1,11 +1,13 @@
package com.threerings.util { package com.threerings.util {
import com.threerings.util.Equalable;
import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream; import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable; import com.threerings.io.Streamable;
public class Name extends Object public class Name extends Object
implements Streamable implements Equalable, Streamable
{ {
public function Name (name :String = "") public function Name (name :String = "")
{ {
@@ -35,16 +37,13 @@ public class Name extends Object
return _name; return _name;
} }
// TODO: needed? I'd think so. Maybe we need to create OOObject // documentation inherited from interface Equalable
// that all our classes can extend that define a reasonable public function equals (other :Object) :Boolean
// equals().
public function equals (other :Name) :Boolean
{ {
return getNormal() === other.getNormal(); return (other is Name) &&
(getNormal() === (other as Name).getNormal());
} }
// TODO: comparable?
// documentation inherited from interface Streamable // documentation inherited from interface Streamable
public function writeObject (out :ObjectOutputStream) :void public function writeObject (out :ObjectOutputStream) :void
//throws IOError //throws IOError