CrRPCLoopbackImpl.mesa
Copyright Ó 1988, 1991 by Xerox Corporation. All rights reserved.
Doug Terry, November 16, 1988 2:57:12 pm PST
Wes Irish, May 1, 1989 4:34:05 pm PDT
Willie-Sue, November 17, 1989 12:06:10 pm PST
Demers, April 26, 1990 3:35 pm PDT
A Courier RPC transport that simply pipes its arguments into its results, i.e. acts as an RPC echo server. This allows one to use Sirocco-generated stubs to convert between opaque types (word sequences) and actual Cedar types.
DIRECTORY
Rope,
CrRPC USING [Handle, Object, ProcsObject, CallProc, DestroyProc, SetParametersProc, GetBulkDataXferProcProc, PutBulkDataXferProcProc, ReadBulkDataStreamProc, WriteBulkDataSegmentProc, CallContinuationProc, SetContinuationProc],
CrRPCBackdoor USING [CreateClientHandleProc, RegisterCreateClientHandleProc],
IO;
~
BEGIN
class: ATOM = $Loopback;
count: INT ¬ 0;
Loopback: CrRPC.CallProc = {
[h: CrRPC.Handle, remotePgm: CrRPC.CARD32, remotePgmVersion: CrRPC.CARD16, remoteProc: CrRPC.CARD16, putArgs: CrRPC.PutArgsProc, getResults: CrRPC.GetResultsProc, getError: CrRPC.GetErrorProc]
push, pull: IO.STREAM;
interim: Rope.ROPE;
push ¬ IO.ROS[];
putArgs[h, push];
interim ¬ IO.RopeFromROS[push];
pull ¬ IO.RIS[interim];
getResults[h, pull];
IO.Close[pull];
};
Destroy: CrRPC.DestroyProc = {
[h: CrRPC.Handle]
NULL;
};
SetParameters: CrRPC.SetParametersProc = {
[h: CrRPC.Handle, op: ATOM, argument: REF ANY] RETURNS [hNew: CrRPC.Handle, result: REF ANY]
RETURN[h, NIL];
};
GetBulkDataXferProc: CrRPC.GetBulkDataXferProcProc = {
[h: CrRPC.Handle, s: STREAM] RETURNS [CrRPC.BulkDataXferProc]
RETURN[NIL];
};
PutBulkDataXferProc: CrRPC.PutBulkDataXferProcProc = {
[h: CrRPC.Handle, s: STREAM, proc: CrRPC.BulkDataXferProc]
NULL;
};
ReadBulkDataStream: CrRPC.ReadBulkDataStreamProc = {
[h: CrRPC.Handle, s: STREAM, checkAbort: CrRPC.BulkDataCheckAbortProc, readValue: CrRPC.BulkDataValueProc] RETURNS [abort: BOOL]
RETURN[FALSE];
};
WriteBulkDataSegment: CrRPC.WriteBulkDataSegmentProc = {
[h: CrRPC.Handle, s: STREAM, checkAbort: CrRPC.BulkDataCheckAbortProc, writeValue: CrRPC.BulkDataValueProc, n: CARDINAL ← 1B (1)] RETURNS [abort: BOOL, heAborted: BOOL]
RETURN[FALSE, FALSE];
};
CallContinuation: CrRPC.CallContinuationProc = {
[h: CrRPC.Handle, proc: CrRPC.ContinuationProc, clientData: REF ANY]
NULL;
};
SetContinuation: CrRPC.SetContinuationProc = {
[h: CrRPC.Handle, proc: CrRPC.ContinuationProc, clientData: REF ANY]
NULL;
};
Finalize:
PROC [CrRPC.Handle]
RETURNS[renewHandle:
BOOL] = {
RETURN[FALSE];
};
CreateLoopbackHandle: CrRPCBackdoor.CreateClientHandleProc = {
[remote: CrRPC.RefAddress] RETURNS [CrRPC.Handle]
handle: CrRPC.Handle ¬ NEW[CrRPC.Object];
handle.class ¬ class;
handle.kind ¬ client;
handle.data ¬ NIL;
handle.clientData ¬ NIL;
handle.procs ¬ NEW[CrRPC.ProcsObject];
handle.procs.call ¬ Loopback;
handle.procs ¬ [
destroy: Destroy,
setParameters: SetParameters,
call: Loopback,
getBulkDataSource: GetBulkDataXferProc,
getBulkDataSink: GetBulkDataXferProc,
putBulkDataSource: PutBulkDataXferProc,
putBulkDataSink: PutBulkDataXferProc,
readBulkDataStream: ReadBulkDataStream,
writeBulkDataSegment: WriteBulkDataSegment,
callContinuation: CallContinuation,
setContinuation: SetContinuation,
finalize: Finalize
];
RETURN[handle];
};
CrRPCBackdoor.RegisterCreateClientHandleProc[class: $Loopback, proc: CreateLoopbackHandle];