Well, it compiles.
It's not functional, there are still large holes in the implementation. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3868 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -14,7 +14,7 @@ public class AttributeChangedEvent extends NamedEvent
|
||||
/**
|
||||
* Returns the new value of the attribute.
|
||||
*/
|
||||
public function getValue () :*
|
||||
public function getValue () :Object
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class AttributeChangedEvent extends NamedEvent
|
||||
* Returns the value of the attribute prior to the application of this
|
||||
* event.
|
||||
*/
|
||||
public function getOldValue () :*
|
||||
public function getOldValue () :Object
|
||||
{
|
||||
return _oldValue;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class AttributeChangedEvent extends NamedEvent
|
||||
* used).
|
||||
*/
|
||||
public function AttributeChangedEvent (
|
||||
targetOid :int, name :String, value :*, oldValue :*)
|
||||
targetOid :int, name :String, value :Object, oldValue :Object)
|
||||
{
|
||||
super(targetOid, name);
|
||||
_value = value;
|
||||
@@ -68,7 +68,7 @@ public class AttributeChangedEvent extends NamedEvent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function notifyListener (listener :*) :void
|
||||
internal override function notifyListener (listener :Object) :void
|
||||
{
|
||||
if (listener is AttributeChangeListener) {
|
||||
listener.attributeChanged(this);
|
||||
@@ -83,7 +83,7 @@ public class AttributeChangedEvent extends NamedEvent
|
||||
buf.append(", value=", _value);
|
||||
}
|
||||
|
||||
protected var _value :*;
|
||||
protected var _oldValue :* = UNSET_OLD_ENTRY;
|
||||
protected var _value :Object;
|
||||
protected var _oldValue :Object = UNSET_OLD_ENTRY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class CompoundEvent extends DEvent
|
||||
case 0: // nothing doing
|
||||
break;
|
||||
case 1: // no point in being compound
|
||||
_omgr.postEvent(_events.getItemAt(0));
|
||||
_omgr.postEvent(_events.getItemAt(0) as DEvent);
|
||||
break;
|
||||
default: // now we're talking
|
||||
_omgr.postEvent(this);
|
||||
@@ -152,7 +152,7 @@ public class CompoundEvent extends DEvent
|
||||
public override function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
_events = ins.readObject();
|
||||
_events = (ins.readObject() as StreamableArrayList);
|
||||
}
|
||||
|
||||
/** The object manager that we'll post ourselves to when we're
|
||||
|
||||
@@ -32,9 +32,10 @@ public class DEvent
|
||||
* return true here and short-circuit the normal proxy event dispatch
|
||||
* mechanism.
|
||||
*/
|
||||
public function applyToObject (target :DObject) :void
|
||||
public function applyToObject (target :DObject) :Boolean
|
||||
{
|
||||
trace("TODO: abstract methods?");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,7 @@ public class DEvent
|
||||
* AttributeChangedEvent} will notify listeners that implement {@link
|
||||
* AttributeChangeListener}.
|
||||
*/
|
||||
protected function notifyListener (listener :*) :void
|
||||
internal function notifyListener (listener :Object) :void
|
||||
{
|
||||
// the default is to do nothing
|
||||
}
|
||||
|
||||
@@ -24,6 +24,29 @@ public class DObject // extends EventDispatcher
|
||||
return _omgr;
|
||||
}
|
||||
|
||||
public function addSubscriber (sub :Subscriber) :void
|
||||
{
|
||||
if (!_subscribers.contains(sub)) {
|
||||
_subscribers.addItem(sub);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeSubscriber (sub :Subscriber) :void
|
||||
{
|
||||
var dex :int = _subscribers.getItemIndex(sub);
|
||||
if (dex != -1) {
|
||||
_subscribers.removeItemAt(dex);
|
||||
if (_subscribers.length == 0) {
|
||||
_omgr.removedLastSubscriber(this, _deathWish);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setDestroyOnLastSubscriberRemoved (deathWish :Boolean) :void
|
||||
{
|
||||
_deathWish = deathWish;
|
||||
}
|
||||
|
||||
public function addListener (listener :ChangeListener) :void
|
||||
{
|
||||
if (_listeners == null) {
|
||||
@@ -53,7 +76,7 @@ public class DObject // extends EventDispatcher
|
||||
}
|
||||
|
||||
for (var ii :int = 0; ii < _listeners.length; ii++) {
|
||||
var listener :* = _listeners.getItemAt(ii);
|
||||
var listener :Object = _listeners.getItemAt(ii);
|
||||
try {
|
||||
event.notifyListener(listener);
|
||||
|
||||
@@ -83,6 +106,31 @@ public class DObject // extends EventDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
public function startTransaction () :void
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public function commitTransaction () :void
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public function inTransaction () :Boolean
|
||||
{
|
||||
return false; // TODO
|
||||
}
|
||||
|
||||
public function cancelTransaction () :void
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
internal function clearTransaction () :void
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public function isActive () :Boolean
|
||||
{
|
||||
return (_omgr != null);
|
||||
@@ -106,7 +154,7 @@ public class DObject // extends EventDispatcher
|
||||
* called.
|
||||
*/
|
||||
protected function requestAttributeChange (
|
||||
name :String, value :*, oldValue :*) :void
|
||||
name :String, value :Object, oldValue :Object) :void
|
||||
{
|
||||
postEvent(new AttributeChangedEvent(_oid, name, value, oldValue));
|
||||
}
|
||||
@@ -116,7 +164,7 @@ public class DObject // extends EventDispatcher
|
||||
* called.
|
||||
*/
|
||||
protected function requestElementUpdate (
|
||||
name :String, index :int, value :*, oldValue :*) :void
|
||||
name :String, index :int, value :Object, oldValue :Object) :void
|
||||
{
|
||||
// dispatch an attribute changed event
|
||||
postEvent(new ElementUpdatedEvent(_oid, name, value, oldValue, index));
|
||||
@@ -186,5 +234,9 @@ public class DObject // extends EventDispatcher
|
||||
|
||||
/** Our event listeners. */
|
||||
protected var _listeners :ArrayCollection;
|
||||
|
||||
protected var _subscribers :ArrayCollection;
|
||||
|
||||
protected var _deathWish :Boolean = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class DSet
|
||||
* @return true if the entry was added, false if it was already in
|
||||
* the set.
|
||||
*/
|
||||
protected function add (elem :DSetEntry) :Boolean
|
||||
internal function add (elem :DSetEntry) :Boolean
|
||||
{
|
||||
if (contains(elem)) {
|
||||
trace("Refusing to add duplicate entry [set=" + this +
|
||||
@@ -179,7 +179,7 @@ public class DSet
|
||||
* @return true if the entry was removed, false if it was not in the
|
||||
* set.
|
||||
*/
|
||||
protected function remove (elem :DSetEntry) :Boolean
|
||||
internal function remove (elem :DSetEntry) :Boolean
|
||||
{
|
||||
return (null != removeKey(elem.getKey()));
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class DSet
|
||||
* @return the old matching entry if found and removed, null if not
|
||||
* found.
|
||||
*/
|
||||
protected function removeKey (key :Comparable) :DSetEntry
|
||||
internal function removeKey (key :Comparable) :DSetEntry
|
||||
{
|
||||
// o(n) for now
|
||||
// TODO
|
||||
@@ -217,7 +217,7 @@ public class DSet
|
||||
* @return the old entry that was replaced, or null if it was not
|
||||
* found (in which case nothing is updated).
|
||||
*/
|
||||
protected function update (elem :DSetEntry) :DSetEntry
|
||||
internal function update (elem :DSetEntry) :DSetEntry
|
||||
{
|
||||
var key :Comparable = elem.getKey();
|
||||
for (var ii :int = 0; ii < _entries.length; ii++) {
|
||||
@@ -250,7 +250,7 @@ public class DSet
|
||||
// documentation inherited from interface Streamable
|
||||
public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
_entries = ins.readField(Array);
|
||||
_entries = (ins.readObject() as Array);
|
||||
_entries.length = ins.readInt(); // then read the length and limit it
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ public class ElementUpdatedEvent extends NamedEvent
|
||||
* @param index the index in the array of the updated element.
|
||||
*/
|
||||
public function ElementUpdatedEvent (
|
||||
targetOid :int, name :String, value :*, oldValue :*, index :int)
|
||||
targetOid :int, name :String, value :Object, oldValue :Object,
|
||||
index :int)
|
||||
{
|
||||
super(targetOid, name);
|
||||
_value = value;
|
||||
@@ -42,7 +43,7 @@ public class ElementUpdatedEvent extends NamedEvent
|
||||
/**
|
||||
* Returns the new value of the element.
|
||||
*/
|
||||
public function getValue () :*
|
||||
public function getValue () :Object
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
@@ -51,7 +52,7 @@ public class ElementUpdatedEvent extends NamedEvent
|
||||
* Returns the value of the element prior to the application of this
|
||||
* event.
|
||||
*/
|
||||
public function getOldValue () :*
|
||||
public function getOldValue () :Object
|
||||
{
|
||||
return _oldValue;
|
||||
}
|
||||
@@ -89,12 +90,12 @@ public class ElementUpdatedEvent extends NamedEvent
|
||||
public override function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
_value = ins.readObjct();
|
||||
_value = ins.readObject();
|
||||
_index = ins.readInt();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function notifyListener (listener :*) :void
|
||||
internal override function notifyListener (listener :Object) :void
|
||||
{
|
||||
if (listener is ElementUpdateListener) {
|
||||
listener.elementUpdated(this);
|
||||
@@ -110,8 +111,8 @@ public class ElementUpdatedEvent extends NamedEvent
|
||||
buf.append(", index=", _index);
|
||||
}
|
||||
|
||||
protected var _value :*;
|
||||
protected var _value :Object;
|
||||
protected var _index :int;
|
||||
protected var _oldValue :* = UNSET_OLD_ENTRY;
|
||||
protected var _oldValue :Object = UNSET_OLD_ENTRY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class EntryAddedEvent extends NamedEvent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function notifyListener (listener :*) :void
|
||||
internal override function notifyListener (listener :Object) :void
|
||||
{
|
||||
if (listener is SetListener) {
|
||||
listener.entryAdded(this);
|
||||
@@ -62,7 +62,7 @@ public class EntryAddedEvent extends NamedEvent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function toStringBuf (buf :StringBuilder)
|
||||
protected override function toStringBuf (buf :StringBuilder) :void
|
||||
{
|
||||
buf.append("ELADD:");
|
||||
super.toStringBuf(buf);
|
||||
@@ -78,7 +78,7 @@ public class EntryAddedEvent extends NamedEvent
|
||||
public override function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
_entry = ins.readObject();
|
||||
_entry = (ins.readObject() as DSetEntry);
|
||||
}
|
||||
|
||||
protected var _entry :DSetEntry;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class EntryRemovedEvent extends NamedEvent
|
||||
if (_oldEntry == null) {
|
||||
// complain if there was actually nothing there
|
||||
trace("No matching entry to remove [key=" + _key +
|
||||
", set=" + set + "].");
|
||||
", set=" + dset + "].");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class EntryRemovedEvent extends NamedEvent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function notifyListener (listener :*) :void
|
||||
internal override function notifyListener (listener :Object) :void
|
||||
{
|
||||
if (listener is SetListener) {
|
||||
listener.entryRemoved(this);
|
||||
@@ -82,7 +82,7 @@ public class EntryRemovedEvent extends NamedEvent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function toStringBuf (buf :StringBuilder)
|
||||
protected override function toStringBuf (buf :StringBuilder) :void
|
||||
{
|
||||
buf.append("ELREM:");
|
||||
super.toStringBuf(buf);
|
||||
@@ -98,7 +98,7 @@ public class EntryRemovedEvent extends NamedEvent
|
||||
public override function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
_key = ins.readObject();
|
||||
_key = (ins.readObject() as Comparable);
|
||||
}
|
||||
|
||||
protected var _key :Comparable;
|
||||
|
||||
@@ -73,7 +73,7 @@ public class EntryUpdatedEvent extends NamedEvent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function notifyListener (listener :*) :void
|
||||
internal override function notifyListener (listener :Object) :void
|
||||
{
|
||||
if (listener is SetListener) {
|
||||
listener.entryUpdated(this);
|
||||
@@ -97,7 +97,7 @@ public class EntryUpdatedEvent extends NamedEvent
|
||||
public override function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
_entry = ins.readObject();
|
||||
_entry = (ins.readObject() as DSetEntry);
|
||||
}
|
||||
|
||||
protected var _entry :DSetEntry;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class MessageEvent extends NamedEvent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function notifyListener (listener :*) :void
|
||||
internal override function notifyListener (listener :Object) :void
|
||||
{
|
||||
if (listener is MessageListener) {
|
||||
listener.messageReceived(this);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class NamedEvent extends DEvent
|
||||
public override function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
_name = ins.readField(String);
|
||||
_name = (ins.readField(String) as String);
|
||||
}
|
||||
|
||||
/** The name of the event. */
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ObjectAddedEvent extends NamedEvent
|
||||
/**
|
||||
* Applies this event to the object.
|
||||
*/
|
||||
public override function applyToObject (target :DObject) :void
|
||||
public override function applyToObject (target :DObject) :Boolean
|
||||
//throws ObjectAccessException
|
||||
{
|
||||
var list :OidList = target[_name];
|
||||
@@ -51,7 +51,7 @@ public class ObjectAddedEvent extends NamedEvent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function notifyListener (listener :*) :void
|
||||
internal override function notifyListener (listener :Object) :void
|
||||
{
|
||||
if (listener is OidListListener) {
|
||||
listener.objectAdded(this);
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ObjectDestroyedEvent extends DEvent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function notifyListener (listener :Object) :void
|
||||
internal override function notifyListener (listener :Object) :void
|
||||
{
|
||||
if (listener is ObjectDeathListener) {
|
||||
listener.objectDestroyed(this);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ObjectRemovedEvent extends NamedEvent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function notifyListener (listener :*) :void
|
||||
internal override function notifyListener (listener :Object) :void
|
||||
{
|
||||
if (listener is OidListListener) {
|
||||
listener.objectRemoved(this);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.threerings.presents.dobj {
|
||||
|
||||
import flash.util.trace;
|
||||
import flash.util.StringBuilder;
|
||||
|
||||
import com.threerings.io.Streamable;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user