Generate OidList signals for actionscript
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6418 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -46,6 +46,7 @@ import com.threerings.io.Streamable;
|
|||||||
import com.threerings.presents.data.InvocationMarshaller;
|
import com.threerings.presents.data.InvocationMarshaller;
|
||||||
import com.threerings.presents.dobj.DObject;
|
import com.threerings.presents.dobj.DObject;
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
|
import com.threerings.presents.dobj.OidList;
|
||||||
|
|
||||||
public class GenActionScriptStreamableTask extends GenTask
|
public class GenActionScriptStreamableTask extends GenTask
|
||||||
{
|
{
|
||||||
@@ -165,6 +166,7 @@ public class GenActionScriptStreamableTask extends GenTask
|
|||||||
public final String dobjectField;
|
public final String dobjectField;
|
||||||
public boolean dset;
|
public boolean dset;
|
||||||
public boolean array;
|
public boolean array;
|
||||||
|
public boolean oidList;
|
||||||
|
|
||||||
public ASField (Field f, Set<String> imports)
|
public ASField (Field f, Set<String> imports)
|
||||||
{
|
{
|
||||||
@@ -183,6 +185,8 @@ public class GenActionScriptStreamableTask extends GenTask
|
|||||||
} else if (DSet.class.isAssignableFrom(f.getType())) {
|
} else if (DSet.class.isAssignableFrom(f.getType())) {
|
||||||
dset = true;
|
dset = true;
|
||||||
imports.add("com.threerings.presents.dobj.DSet_Entry"); // Used for signals
|
imports.add("com.threerings.presents.dobj.DSet_Entry"); // Used for signals
|
||||||
|
} else if (OidList.class.isAssignableFrom(f.getType())) {
|
||||||
|
oidList = true;
|
||||||
}
|
}
|
||||||
array = f.getType().isArray();
|
array = f.getType().isArray();
|
||||||
reader = ActionScriptUtils.toReadObject(f.getType());
|
reader = ActionScriptUtils.toReadObject(f.getType());
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ public class {{classname}} {{^extends.isEmpty}}extends {{extends}}
|
|||||||
{{#array}}
|
{{#array}}
|
||||||
public var {{name}}ElementUpdated :Signal = new Signal(int, Object, Object);
|
public var {{name}}ElementUpdated :Signal = new Signal(int, Object, Object);
|
||||||
{{/array}}
|
{{/array}}
|
||||||
|
{{#oidList}}
|
||||||
|
public var {{name}}ObjectAdded :Signal = new Signal(int);
|
||||||
|
public var {{name}}ObjectRemoved :Signal = new Signal(int);
|
||||||
|
{{/oidList}}
|
||||||
{{/pubFields}}
|
{{/pubFields}}
|
||||||
public var messageReceived :Signal = new Signal(String, Array);
|
public var messageReceived :Signal = new Signal(String, Array);
|
||||||
public var destroyed :Signal = new Signal();
|
public var destroyed :Signal = new Signal();
|
||||||
@@ -97,15 +101,18 @@ import com.threerings.presents.dobj.EntryRemovedEvent;
|
|||||||
import com.threerings.presents.dobj.EntryUpdatedEvent;
|
import com.threerings.presents.dobj.EntryUpdatedEvent;
|
||||||
import com.threerings.presents.dobj.MessageEvent;
|
import com.threerings.presents.dobj.MessageEvent;
|
||||||
import com.threerings.presents.dobj.MessageListener;
|
import com.threerings.presents.dobj.MessageListener;
|
||||||
|
import com.threerings.presents.dobj.ObjectAddedEvent;
|
||||||
import com.threerings.presents.dobj.ObjectDeathListener;
|
import com.threerings.presents.dobj.ObjectDeathListener;
|
||||||
import com.threerings.presents.dobj.ObjectDestroyedEvent;
|
import com.threerings.presents.dobj.ObjectDestroyedEvent;
|
||||||
|
import com.threerings.presents.dobj.ObjectRemovedEvent;
|
||||||
|
import com.threerings.presents.dobj.OidListListener;
|
||||||
import com.threerings.presents.dobj.SetListener;
|
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, MessageListener,
|
||||||
ObjectDeathListener
|
ObjectDeathListener, OidListListener
|
||||||
{
|
{
|
||||||
public function Signaller (obj :{{classname}})
|
public function Signaller (obj :{{classname}})
|
||||||
{
|
{
|
||||||
@@ -198,6 +205,36 @@ class Signaller
|
|||||||
_obj.destroyed.dispatch();
|
_obj.destroyed.dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function objectAdded (event:ObjectAddedEvent) :void
|
||||||
|
{
|
||||||
|
var signal :Signal;
|
||||||
|
switch (event.getName()) {
|
||||||
|
{{#pubFields}}{{#oidList}}
|
||||||
|
case "{{name}}":
|
||||||
|
signal = _obj.{{name}}ObjectAdded;
|
||||||
|
break;
|
||||||
|
{{/oidList}}{{/pubFields}}
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
signal.dispatch(event.getOid());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function objectRemoved (event :ObjectRemovedEvent) :void
|
||||||
|
{
|
||||||
|
var signal :Signal;
|
||||||
|
switch (event.getName()) {
|
||||||
|
{{#pubFields}}{{#oidList}}
|
||||||
|
case "{{name}}":
|
||||||
|
signal = _obj.{{name}}ObjectRemoved;
|
||||||
|
break;
|
||||||
|
{{/oidList}}{{/pubFields}}
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
signal.dispatch(event.getOid());
|
||||||
|
}
|
||||||
|
|
||||||
protected var _obj :{{classname}};
|
protected var _obj :{{classname}};
|
||||||
}
|
}
|
||||||
// GENERATED SIGNALLER END
|
// GENERATED SIGNALLER END
|
||||||
|
|||||||
Reference in New Issue
Block a user