Generate a signal for array ElementUpdatedEvents.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6339 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -129,6 +129,7 @@ public class GenActionScriptStreamableTask extends GenTask
|
||||
public final String writer;
|
||||
public final String dobjectField;
|
||||
public boolean dset;
|
||||
public boolean array;
|
||||
|
||||
public ASField (Field f, Set<String> imports)
|
||||
{
|
||||
@@ -147,6 +148,7 @@ public class GenActionScriptStreamableTask extends GenTask
|
||||
dset = true;
|
||||
imports.add("com.threerings.presents.dobj.DSet_Entry"); // Used for signals
|
||||
}
|
||||
array = f.getType().isArray();
|
||||
reader = ActionScriptUtils.toReadObject(f.getType());
|
||||
writer = ActionScriptUtils.toWriteObject(f.getType(), name);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ public class {{classname}} {{^extends.isEmpty}}extends {{extends}}
|
||||
public var {{name}}Removed :Signal = new Signal(DSet_Entry);
|
||||
public var {{name}}Updated :Signal = new Signal(DSet_Entry, DSet_Entry);
|
||||
{{/dset}}
|
||||
{{#array}}
|
||||
public var {{name}}Updated :Signal = new Signal(int, Object, Object);
|
||||
{{/array}}
|
||||
{{/fields}}
|
||||
|
||||
{{#fields}}
|
||||
@@ -76,6 +79,8 @@ import org.osflash.signals.Signal;
|
||||
|
||||
import com.threerings.presents.dobj.AttributeChangedEvent;
|
||||
import com.threerings.presents.dobj.AttributeChangeListener;
|
||||
import com.threerings.presents.dobj.ElementUpdatedEvent;
|
||||
import com.threerings.presents.dobj.ElementUpdateListener;
|
||||
import com.threerings.presents.dobj.EntryAddedEvent;
|
||||
import com.threerings.presents.dobj.EntryRemovedEvent;
|
||||
import com.threerings.presents.dobj.EntryUpdatedEvent;
|
||||
@@ -84,7 +89,7 @@ import com.threerings.presents.dobj.SetListener;
|
||||
import {{package}}.{{classname}};
|
||||
|
||||
class Signaller
|
||||
implements AttributeChangeListener, SetListener
|
||||
implements AttributeChangeListener, SetListener, ElementUpdateListener
|
||||
{
|
||||
public function Signaller (obj :{{classname}})
|
||||
{
|
||||
@@ -152,6 +157,21 @@ class Signaller
|
||||
signal.dispatch(event.getEntry(), event.getOldEntry());
|
||||
}
|
||||
|
||||
public function elementUpdated (event :ElementUpdatedEvent) :void
|
||||
{
|
||||
var signal :Signal;
|
||||
switch (event.getName()) {
|
||||
{{#fields}}{{#array}}
|
||||
case "{{name}}":
|
||||
signal = _obj.{{name}}Updated;
|
||||
break;
|
||||
{{/array}}{{/fields}}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
signal.dispatch(event.getIndex(), event.getValue(), event.getOldValue());
|
||||
}
|
||||
|
||||
protected var _obj :{{classname}};
|
||||
}
|
||||
// GENERATED SIGNALLER END
|
||||
|
||||
Reference in New Issue
Block a user