Script for generating invocation receiver derived code: decoder and

sender classes.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1637 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-08-11 05:53:13 +00:00
parent 5ff720b586
commit eb186c2675
3 changed files with 436 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
//
// $Id: decoder.tmpl,v 1.1 2002/08/11 05:53:13 mdb Exp $
package [% package %];
[% FOREACH import = imports -%]
import [% import %];
[% END -%]
/**
* Dispatches calls to a {@link [% name %]Receiver} instance.
*/
public class [% name %]Decoder extends InvocationDecoder
{
/** The id used to identify this notification receiver. */
public static final short RECEIVER_ID = [% receiver_id %];
[% FOREACH method = methods -%]
/** The method id used to dispatch {@link [% name %]Receiver#[% method.mname %]}
* notifications. */
public static final int [% method.mcode %] = [% method.mcodeval %];
[% END -%]
/**
* Creates a decoder that may be registered to dispatch invocation
* service notifications to the specified receiver.
*/
public [% name %]Decoder ([% name %]Receiver receiver)
{
this.receiver = receiver;
}
// documentation inherited
public int getReceiverId ()
{
return RECEIVER_ID;
}
// documentation inherited
public void dispatchNotification (int methodId, Object[] args)
{
switch (methodId) {
[% FOREACH method = methods -%]
case [% method.mcode %]:
(([% name %]Receiver)receiver).[% method.mname %](
[% method.unwrapped_args %]
);
return;
[% END -%]
default:
super.dispatchNotification(methodId, args);
}
}
// Generated on [% genstamp %].
}
+31
View File
@@ -0,0 +1,31 @@
//
// $Id: sender.tmpl,v 1.1 2002/08/11 05:53:13 mdb Exp $
package [% package %];
[% FOREACH import = imports -%]
import [% import %];
[% END -%]
/**
* Used to issue notifications to a {@link [% name %]Receiver} instance on a
* client.
*/
public class [% name %]Sender extends InvocationSender
{
[% FOREACH m = methods -%]
/**
* Issues a notification that will result in a call to {@link
* [% name %]Receiver#[% m.mname %]} on a client.
*/
public static void [% m.sname %] (
ClientObject target, [% m.arglist %])
{
sendNotification(
target, [% name %]Decoder.RECEIVER_ID, [% name %]Decoder.[% m.mcode %],
new Object[] { [% m.wrapped_args %] });
}
[% END -%]
// Generated on [% genstamp %].
}