Generate receivers and decoders for actionscript
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6507 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package {{package}} {
|
||||
|
||||
{{#imports}}
|
||||
import {{this}};
|
||||
{{/imports}}
|
||||
|
||||
/**
|
||||
* Dispatches calls to a {@link {{name}}Receiver} instance.
|
||||
*/
|
||||
public class {{name}}Decoder extends InvocationDecoder
|
||||
{
|
||||
/** The generated hash code used to identify this receiver class. */
|
||||
public static const RECEIVER_CODE :String = "{{receiver_code}}";
|
||||
|
||||
{{#methods}}
|
||||
/** The method id used to dispatch {@link {{name}}Receiver#{{method.name}}}
|
||||
* notifications. */
|
||||
public static const {{code}} :int = {{-index}};
|
||||
|
||||
{{/methods}}
|
||||
/**
|
||||
* Creates a decoder that may be registered to dispatch invocation
|
||||
* service notifications to the specified receiver.
|
||||
*/
|
||||
public function {{name}}Decoder (receiver :{{name}}Receiver)
|
||||
{
|
||||
this.receiver = receiver;
|
||||
}
|
||||
|
||||
public override function getReceiverCode () :String
|
||||
{
|
||||
return RECEIVER_CODE;
|
||||
}
|
||||
|
||||
public override function dispatchNotification (methodId :int, args :Array) :void
|
||||
{
|
||||
switch (methodId) {
|
||||
{{#methods}}
|
||||
case {{code}}:
|
||||
{{name}}Receiver(receiver).{{method.name}}(
|
||||
{{getASUnwrappedArgList}}
|
||||
);
|
||||
return;
|
||||
|
||||
{{/methods}}
|
||||
default:
|
||||
super.dispatchNotification(methodId, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package {{package}} {
|
||||
|
||||
{{#imports}}
|
||||
import {{this}};
|
||||
{{/imports}}
|
||||
|
||||
public interface {{name}}Receiver extends InvocationReceiver
|
||||
{
|
||||
{{#methods}}
|
||||
{{^-first}}
|
||||
|
||||
{{/-first}}
|
||||
// from Java interface {{name}}Receiver
|
||||
function {{method.name}} ({{getASArgList}}) :void;
|
||||
{{/methods}}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user