Got compiling working under Linux, now correcting various errors.

Checkpoint.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3866 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-02-20 02:38:56 +00:00
parent f8c8f6e983
commit 7a80c5cb43
41 changed files with 453 additions and 141 deletions
@@ -59,7 +59,7 @@ public class AttributeChangedEvent extends NamedEvent
* primitive types, the reflection-defined object-alternative is
* used).
*/
protected function AttributeChangedEvent (
public function AttributeChangedEvent (
targetOid :int, name :String, value :*, oldValue :*)
{
super(targetOid, name);
@@ -76,10 +76,10 @@ public class AttributeChangedEvent extends NamedEvent
}
// documentation inherited
protected override function toString (buf :StringBuilder) :void
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("CHANGE:");
super.toString(buf);
super.toStringBuf(buf);
buf.append(", value=", _value);
}
@@ -41,7 +41,7 @@ public class CompoundEvent extends DEvent
/**
* Constructs a compound event and prepares it for operation.
*/
public CompoundEvent (target :DObject, omgr :DObjectManager)
public function CompoundEvent (target :DObject, omgr :DObjectManager)
{
super(target.getOid());
@@ -112,18 +112,6 @@ public class CompoundEvent extends DEvent
_events.removeAll();
}
/**
* We need to propagate our source oid to our constituent events.
*/
public override function setSourceOid (sourceOid :int) :void
{
super.setSourceOid(sourceOid);
for (var ii :int = 0; ii < _events.length; ii++) {
_events.getItemAt(ii).setSourceOid(sourceOid);
}
}
/**
* Nothing to apply here.
*/
@@ -145,10 +133,10 @@ public class CompoundEvent extends DEvent
}
// documentation inherited
protected override function toString (buf :StringBuilder) :void
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("COMPOUND:");
super.toString(buf);
super.toStringBuf(buf);
for (var ii :int = 0; ii < _events.length; ii++) {
buf.append(", ", _events.getItemAt(ii));
+21 -22
View File
@@ -1,19 +1,18 @@
package com.threerings.presents.dobj {
import flash.util.StringBuilder;
import flash.util.trace;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable;
import com.threerings.util.Comparable;
public class DEvent
implements Streamable
{
public function DEvent ()
{
}
public function DEvent (int targetOid)
public function DEvent (targetOid :int)
{
_toid = targetOid;
}
@@ -50,18 +49,6 @@ public class DEvent
// the default is to do nothing
}
/**
* Constructs and returns a string representation of this event.
*/
public override function toString () :String
{
StringBuilder buf = new StringBuilder();
buf.append("[");
toString(buf);
buf.append("]");
return buf.toString();
}
// documentation inherited from interface Streamable
public function writeObject (out :ObjectOutputStream) :void
{
@@ -74,12 +61,24 @@ public class DEvent
_toid = ins.readInt();
}
/**
* Constructs and returns a string representation of this event.
*/
public function toString () :String
{
var buf :StringBuilder = new StringBuilder();
buf.append("[");
toStringBuf(buf);
buf.append("]");
return buf.toString();
}
/**
* This should be overridden by derived classes (which should be sure
* to call <code>super.toString()</code>) to append the derived class
* specific event information to the string buffer.
*/
protected function toString (buf :StringBuilder) :void
protected function toStringBuf (buf :StringBuilder) :void
{
buf.append("targetOid=", _toid);
}
@@ -91,18 +90,18 @@ public class DEvent
}
}
class DummyEntry implements DSetEntry
class DummyEntry implements com.threerings.presents.dobj.DSetEntry
{
public function getKey () :Comparable
public function getKey () :com.threerings.util.Comparable
{
return null;
}
public function writeObject (out :ObjectOutputStream) :void
public function writeObject (out :com.threerings.io.ObjectOutputStream) :void
{
}
public function readObject (ins :ObjectInputStream) :void
public function readObject (ins :com.threerings.io.ObjectInputStream) :void
{
}
}
@@ -1,9 +1,12 @@
package com.threerings.presents.dobj {
import flash.events.EventDispatcher;
import flash.util.trace;
import mx.collections.ArrayCollection;
import com.threerings.util.Comparable;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable;
@@ -140,7 +143,7 @@ public class DObject // extends EventDispatcher
/**
* Calls by derived instances when a set adder method was called.
*/
protected function requestEntryAdd (name :String, entry :DSet.Entry) :void
protected function requestEntryAdd (name :String, entry :DSetEntry) :void
{
// dispatch an entry added event
postEvent(new EntryAddedEvent(_oid, name, entry, false));
@@ -158,7 +161,7 @@ public class DObject // extends EventDispatcher
/**
* Calls by derived instances when a set updater method was called.
*/
protected function requestEntryUpdate (name :String, entry :DSet.Entry)
protected function requestEntryUpdate (name :String, entry :DSetEntry)
{
// dispatch an entry updated event
postEvent(new EntryUpdatedEvent(_oid, name, entry, null));
+5 -2
View File
@@ -1,11 +1,14 @@
package com.threerings.presents.dobj {
import flash.util.StringBuilder;
import flash.util.trace;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable;
import com.threerings.util.Comparable;
/**
* The distributed set class provides a means by which an unordered set of
@@ -230,9 +233,9 @@ public class DSet
/**
* Generates a string representation of this set instance.
*/
public override function toString () :String
public function toString () :String
{
StringBuilder buf = new StringBuilder("(");
var buf :StringBuilder = new StringBuilder("(");
buf.append(_entries.toString());
buf.append(")");
return buf.toString();
@@ -2,6 +2,8 @@ package com.threerings.presents.dobj {
import com.threerings.io.Streamable;
import com.threerings.util.Comparable;
public interface DSetEntry extends Streamable
{
function getKey () :Comparable;
@@ -30,7 +30,7 @@ public class ElementUpdatedEvent extends NamedEvent
* used).
* @param index the index in the array of the updated element.
*/
public ElementUpdatedEvent (
public function ElementUpdatedEvent (
targetOid :int, name :String, value :*, oldValue :*, index :int)
{
super(targetOid, name);
@@ -102,10 +102,10 @@ public class ElementUpdatedEvent extends NamedEvent
}
// documentation inherited
protected override function toString (buf :StringBuilder) :void
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("UPDATE:");
super.toString(buf);
super.toStringBuf(buf);
buf.append(", value=", _value);
buf.append(", index=", _index);
}
@@ -1,6 +1,7 @@
package com.threerings.presents.dobj {
import flash.util.StringBuilder;
import flash.util.trace;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
@@ -61,10 +62,10 @@ public class EntryAddedEvent extends NamedEvent
}
// documentation inherited
protected override function toString (StringBuilder buf)
protected override function toStringBuf (buf :StringBuilder)
{
buf.append("ELADD:");
super.toString(buf);
super.toStringBuf(buf);
buf.append(", entry=", _entry);
}
@@ -1,10 +1,12 @@
package com.threerings.presents.dobj {
import flash.util.StringBuilder;
import flash.util.trace;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.util.Comparable;
/**
* An entry removed event is dispatched when an entry is removed from a
@@ -80,10 +82,10 @@ public class EntryRemovedEvent extends NamedEvent
}
// documentation inherited
protected override function toString (buf :StringBuilder)
protected override function toStringBuf (buf :StringBuilder)
{
buf.append("ELREM:");
super.toString(buf);
super.toStringBuf(buf);
buf.append(", key=", _key);
}
@@ -1,5 +1,7 @@
package com.threerings.presents.dobj {
import flash.util.trace;
import flash.util.StringBuilder;
import com.threerings.io.ObjectInputStream;
@@ -63,7 +65,7 @@ public class EntryUpdatedEvent extends NamedEvent
if (_oldEntry == null) {
// complain if we didn't update anything
trace("No matching entry to update [entry=" + this +
", set=" + set + "].");
", set=" + dset + "].");
return false;
}
}
@@ -79,10 +81,10 @@ public class EntryUpdatedEvent extends NamedEvent
}
// documentation inherited
protected override function toString (buf :StringBuilder) :void
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("ELUPD:");
super.toString(buf);
super.toStringBuf(buf);
buf.append(", entry=", _entry);
}
@@ -69,10 +69,10 @@ public class MessageEvent extends NamedEvent
}
// documentation inherited
protected override function toString (buf :StringBuilder) :void
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("MSG:");
super.toString(buf);
super.toStringBuf(buf);
buf.append(", args=", _args);
}
@@ -18,7 +18,7 @@ public class NamedEvent extends DEvent
* @param targetOid the object id of the object in question.
* @param name the name associated with this event.
*/
public NamedEvent (targetOid :int, name :String)
public function NamedEvent (targetOid :int, name :String)
{
super(targetOid);
_name = name;
@@ -32,9 +32,9 @@ public class NamedEvent extends DEvent
return _name;
}
protected override function toString (buf :StringBuilder) :void
protected override function toStringBuf (buf :StringBuilder) :void
{
super.toString(buf);
super.toStringBuf(buf);
buf.append(", name=", _name);
}
@@ -71,10 +71,10 @@ public class ObjectAddedEvent extends NamedEvent
}
// documentation inherited
protected override function toString (buf :StringBuilder) :void
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("OBJADD:");
super.toString(buf);
super.toStringBuf(buf);
buf.append(", oid=", _oid);
}
@@ -19,7 +19,9 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.presents.dobj;
package com.threerings.presents.dobj {
import flash.util.StringBuilder;
/**
* An object destroyed event is dispatched when an object has been removed
@@ -36,22 +38,14 @@ public class ObjectDestroyedEvent extends DEvent
*
* @param targetOid the object id of the object that will be destroyed.
*/
public ObjectDestroyedEvent (int targetOid)
public function ObjectDestroyedEvent (targetOid :int)
{
super(targetOid);
}
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public ObjectDestroyedEvent ()
{
}
// documentation inherited
public boolean applyToObject (DObject target)
throws ObjectAccessException
public override function applyToObject (target :DObject) :Boolean
//throws ObjectAccessException
{
// nothing to do in preparation for destruction, the omgr will
// have to recognize this type of event and do the right thing
@@ -59,17 +53,18 @@ public class ObjectDestroyedEvent extends DEvent
}
// documentation inherited
protected void notifyListener (Object listener)
protected override function notifyListener (listener :Object) :void
{
if (listener instanceof ObjectDeathListener) {
((ObjectDeathListener)listener).objectDestroyed(this);
if (listener is ObjectDeathListener) {
listener.objectDestroyed(this);
}
}
// documentation inherited
protected void toString (StringBuffer buf)
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("DESTROY:");
super.toString(buf);
super.toStringBuf(buf);
}
}
}
@@ -94,10 +94,10 @@ public class ObjectRemovedEvent extends NamedEvent
}
// documentation inherited
protected override function toString (buf :StringBuilder) :void
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("OBJREM:");
super.toString(buf);
super.toStringBuf(buf);
buf.append(", oid=", _oid);
}
+15 -18
View File
@@ -1,5 +1,7 @@
package com.threerings.presents.dobj {
import flash.util.trace;
import com.threerings.io.Streamable;
import com.threerings.io.ObjectInputStream;
@@ -27,7 +29,7 @@ public class OidList
*/
public function size () :int
{
return _size;
return _oids.length;
}
/**
@@ -40,19 +42,14 @@ public class OidList
public function add (oid :int) :Boolean
{
// check for existence
for (int i = 0; i < _size; i++) {
if (_oids[i] == oid) {
for (var ii :int = 0; ii < _oids.length; ii++) {
if (_oids[ii] == oid) {
return false;
}
}
// make room if necessary
if (_size+1 >= _oids.length) {
expand();
}
// add the oid
_oids[_size++] = oid;
_oids[_oids.length] = oid;
return true;
}
@@ -62,13 +59,13 @@ public class OidList
* @return true if the oid was in the list and was removed, false
* otherwise.
*/
public boolean remove (int oid)
public function remove (oid :int) :Boolean
{
// scan for the oid in question
for (int i = 0; i < _size; i++) {
if (_oids[i] == oid) {
for (var ii :int = 0; ii < _oids.length; ii++) {
if (_oids[ii] == oid) {
// shift the rest of the list back one
System.arraycopy(_oids, i+1, _oids, i, --_size-i);
_oids.splice(ii, 1);
return true;
}
}
@@ -79,10 +76,10 @@ public class OidList
/**
* Returns true if the specified oid is in the list, false if not.
*/
public boolean contains (int oid)
public function contains (oid :int) :Boolean
{
for (int i = 0; i < _size; i++) {
if (_oids[i] == oid) {
for (var ii :int = 0; ii < _oids.length; ii++) {
if (_oids[ii] == oid) {
return true;
}
}
@@ -118,9 +115,9 @@ public class OidList
}
public override function toString () :String
public function toString () :String
{
StringBuilder buf = new StringBuilder();
var buf :StringBuilder = new StringBuilder();
buf.append("{");
buf.append(_oids.toString());
buf.append("}");
@@ -19,7 +19,7 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.presents.dobj;
package com.threerings.presents.dobj {
/**
* Implemented by entites which wish to hear about changes that occur to
@@ -36,7 +36,7 @@ public interface SetListener extends ChangeListener
*
* @param event The event that was dispatched on the object.
*/
public void entryAdded (EntryAddedEvent event);
function entryAdded (event :EntryAddedEvent) :void;
/**
* Called when an entry updated event has been dispatched on an
@@ -45,7 +45,7 @@ public interface SetListener extends ChangeListener
*
* @param event The event that was dispatched on the object.
*/
public void entryUpdated (EntryUpdatedEvent event);
function entryUpdated (event :EntryUpdatedEvent) :void;
/**
* Called when an entry removed event has been dispatched on an
@@ -54,5 +54,6 @@ public interface SetListener extends ChangeListener
*
* @param event The event that was dispatched on the object.
*/
public void entryRemoved (EntryRemovedEvent event);
function entryRemoved (event :EntryRemovedEvent) :void;
}
}
@@ -0,0 +1,63 @@
//
// $Id: Subscriber.java 3099 2004-08-27 02:21:06Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.presents.dobj {
/**
* A subscriber is an entity that has access to a distributed object. The
* process of obtaining access to a distributed object is an asynchronous
* one, and changes made to an object are delivered asynchronously. By
* registering as a subscriber to an object, an entity can react to
* changes made to an object and ensure that their object is kept up to
* date.
*
* <p> To actually receive callbacks when events are dispatched on a
* distributed object, an entity should register itself as a listener on
* the object once it has received its object reference.
*
* @see EventListener
* @see AttributeChangeListener
* @see SetListener
* @see OidListListener
*/
public interface Subscriber
{
/**
* Called when a subscription request has succeeded and the object is
* available. If the object was requested for subscription, the
* subscriber can subsequently receive notifications by registering
* itself as a listener of some sort (see {@link
* DObject#addListener}).
*
* @see DObjectManager#subscribeToObject
*/
function objectAvailable (obj :DObject) :void;
/**
* Called when a subscription request has failed. The nature of the
* failure will be communicated via the supplied
* <code>ObjectAccessException</code>.
*
* @see DObjectManager#subscribeToObject
*/
function requestFailed (oid :int, cause :ObjectAccessError) :void;
}
}