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
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.threerings.presents.dobj {
|
package com.threerings.presents.dobj {
|
||||||
|
import org.osflash.signals.Signal;
|
||||||
|
|
||||||
import flash.errors.IllegalOperationError;
|
import flash.errors.IllegalOperationError;
|
||||||
|
|
||||||
@@ -38,6 +39,11 @@ public class DObject // extends EventDispatcher
|
|||||||
{
|
{
|
||||||
private static const log :Log = Log.getLog(DObject);
|
private static const log :Log = Log.getLog(DObject);
|
||||||
|
|
||||||
|
public function DObject ()
|
||||||
|
{
|
||||||
|
new Signaller(this);
|
||||||
|
}
|
||||||
|
|
||||||
public function getOid ():int
|
public function getOid ():int
|
||||||
{
|
{
|
||||||
return _oid;
|
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
|
public function setDestroyOnLastSubscriberRemoved (deathWish :Boolean) :void
|
||||||
{
|
{
|
||||||
_deathWish = deathWish;
|
_deathWish = deathWish;
|
||||||
@@ -414,3 +423,33 @@ public class DObject // extends EventDispatcher
|
|||||||
protected var _deathWish :Boolean = false;
|
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);
|
public var {{name}}ObjectRemoved :Signal = new Signal(int);
|
||||||
{{/oidList}}
|
{{/oidList}}
|
||||||
{{/pubFields}}
|
{{/pubFields}}
|
||||||
public var messageReceived :Signal = new Signal(String, Array);
|
|
||||||
public var destroyed :Signal = new Signal();
|
|
||||||
|
|
||||||
{{#pubFields}}
|
{{#pubFields}}
|
||||||
public static const {{dobjectField}} :String = "{{name}}";
|
public static const {{dobjectField}} :String = "{{name}}";
|
||||||
@@ -111,8 +109,7 @@ import com.threerings.presents.dobj.SetListener;
|
|||||||
import {{package}}.{{classname}};
|
import {{package}}.{{classname}};
|
||||||
|
|
||||||
class Signaller
|
class Signaller
|
||||||
implements AttributeChangeListener, SetListener, ElementUpdateListener, MessageListener,
|
implements AttributeChangeListener, SetListener, ElementUpdateListener, OidListListener
|
||||||
ObjectDeathListener, OidListListener
|
|
||||||
{
|
{
|
||||||
public function Signaller (obj :{{classname}})
|
public function Signaller (obj :{{classname}})
|
||||||
{
|
{
|
||||||
@@ -195,16 +192,6 @@ class Signaller
|
|||||||
signal.dispatch(event.getIndex(), event.getValue(), event.getOldValue());
|
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
|
public function objectAdded (event:ObjectAddedEvent) :void
|
||||||
{
|
{
|
||||||
var signal :Signal;
|
var signal :Signal;
|
||||||
|
|||||||
Reference in New Issue
Block a user