Add the messageReceived and destroyed signals to DObject rather than generating them. If they were generated, subclassing would fail on field conflicts.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6470 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.presents.dobj {
|
||||
import org.osflash.signals.Signal;
|
||||
|
||||
import flash.errors.IllegalOperationError;
|
||||
|
||||
@@ -38,6 +39,11 @@ public class DObject // extends EventDispatcher
|
||||
{
|
||||
private static const log :Log = Log.getLog(DObject);
|
||||
|
||||
public function DObject ()
|
||||
{
|
||||
new Signaller(this);
|
||||
}
|
||||
|
||||
public function getOid ():int
|
||||
{
|
||||
return _oid;
|
||||
@@ -72,6 +78,9 @@ public class DObject // extends EventDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
public const messageReceived :Signal = new Signal(String, Array);
|
||||
public const destroyed :Signal = new Signal();
|
||||
|
||||
public function setDestroyOnLastSubscriberRemoved (deathWish :Boolean) :void
|
||||
{
|
||||
_deathWish = deathWish;
|
||||
@@ -414,3 +423,33 @@ public class DObject // extends EventDispatcher
|
||||
protected var _deathWish :Boolean = false;
|
||||
}
|
||||
}
|
||||
|
||||
import com.threerings.presents.dobj.MessageEvent;
|
||||
import com.threerings.presents.dobj.MessageListener;
|
||||
import com.threerings.presents.dobj.ObjectDeathListener;
|
||||
import com.threerings.presents.dobj.ObjectDestroyedEvent;
|
||||
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
|
||||
class Signaller
|
||||
implements MessageListener, ObjectDeathListener
|
||||
{
|
||||
public function Signaller (obj :DObject)
|
||||
{
|
||||
_obj = obj;
|
||||
_obj.addListener(this);
|
||||
}
|
||||
|
||||
public function messageReceived (event :MessageEvent) :void
|
||||
{
|
||||
_obj.messageReceived.dispatch(event.getName(), event.getArgs());
|
||||
}
|
||||
|
||||
public function objectDestroyed (event :ObjectDestroyedEvent) :void
|
||||
{
|
||||
_obj.destroyed.dispatch();
|
||||
}
|
||||
|
||||
protected var _obj :DObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,6 @@ public class {{classname}} {{^extends.isEmpty}}extends {{extends}}
|
||||
public var {{name}}ObjectRemoved :Signal = new Signal(int);
|
||||
{{/oidList}}
|
||||
{{/pubFields}}
|
||||
public var messageReceived :Signal = new Signal(String, Array);
|
||||
public var destroyed :Signal = new Signal();
|
||||
|
||||
{{#pubFields}}
|
||||
public static const {{dobjectField}} :String = "{{name}}";
|
||||
@@ -111,8 +109,7 @@ import com.threerings.presents.dobj.SetListener;
|
||||
import {{package}}.{{classname}};
|
||||
|
||||
class Signaller
|
||||
implements AttributeChangeListener, SetListener, ElementUpdateListener, MessageListener,
|
||||
ObjectDeathListener, OidListListener
|
||||
implements AttributeChangeListener, SetListener, ElementUpdateListener, OidListListener
|
||||
{
|
||||
public function Signaller (obj :{{classname}})
|
||||
{
|
||||
@@ -195,16 +192,6 @@ class Signaller
|
||||
signal.dispatch(event.getIndex(), event.getValue(), event.getOldValue());
|
||||
}
|
||||
|
||||
public function messageReceived (event :MessageEvent) :void
|
||||
{
|
||||
_obj.messageReceived.dispatch(event.getName(), event.getArgs());
|
||||
}
|
||||
|
||||
public function objectDestroyed (event :ObjectDestroyedEvent) :void
|
||||
{
|
||||
_obj.destroyed.dispatch();
|
||||
}
|
||||
|
||||
public function objectAdded (event:ObjectAddedEvent) :void
|
||||
{
|
||||
var signal :Signal;
|
||||
|
||||
Reference in New Issue
Block a user