-- Stub file TankMasterRpcServerImpl.mesa was translated on 16-Mar-83
-- 9:07:33 PST by Lupine of 18-Feb-83 11:25:52 PST.
-- Source interface TankMaster came from file TankMaster.bcd, which
-- was created on 16-Mar-83 9:07:11 PST with version stamp 176#227#36526563207
-- from source of 16-Mar-83 9:06:51 PST.
-- The RPC stub modules for TankMaster are:
-- TankMasterRpcControl.mesa;
-- TankMasterRpcClientImpl.mesa;
-- TankMasterRpcBinderImpl.mesa;
-- TankMasterRpcServerImpl.mesa.
-- The parameters for this translation are:
-- Target language = Cedar;
-- Default parameter passing = VALUE;
-- Deallocate server heap arguments = TRUE;
-- Inline RpcServerImpl dispatcher stubs = TRUE;
-- Maximum number of dynamic heap NEWs = 50, MDS NEWs = 50;
-- Acceptable parameter protocols = VersionRange[1,1].
DIRECTORY
PupTypes,
Rope,
TankMaster,
TankMasterRpcControl USING [InterMdsCallsOnly, LupineProtocolVersion,
ProcedureIndex, SignalIndex],
RPC USING [EncryptionKey, InterfaceName, Principal, standardZones,
Zones],
RPCLupine --USING SOME OF [Call, DataLength, Dispatcher, ExportHandle,
-- ExportInterface, GetStubPkt, maxDataLength, maxPrincipalLength,
-- maxShortStringLength, pktOverhead, ReceiveExtraPkt, SendPrelimPkt,
-- StartCall, StartSignal, StubPkt, UnexportInterface]--,
LupineRuntime --USING SOME OF [BindingError, CheckPktLength, CopyFromPkt,
-- CopyFromMultiplePkts, CopyToPkt, CopyToMultiplePkts, DispatchingError,
-- FinishThisPkt, ListHeader, MarshalingError, MarshalingExprError,
-- NilHeader, ProtocolError, RopeHeader, RpcPktDoubleWord, RuntimeError,
-- SequenceHeader, SHORT, StartNextPkt, StringHeader, StubPktDoubleWord,
-- TranslationError, UnmarshalingError, UnmarshalingExprError, WordsForChars]--,
Atom --USING SOME OF [GetPName, MakeAtom]--,
ConvertUnsafe USING [AppendRope],
Heap USING [systemMDSZone],
RopeInline --USING SOME OF [InlineFlatten, NewText]--,
SafeStorage USING [GetSystemZone],
UnsafeStorage USING [GetSystemUZone];
TankMasterRpcServerImpl: MONITOR
IMPORTS TankMaster, RpcPrivate: RPCLupine, Lupine: LupineRuntime,
Atom, ConvertUnsafe, Heap, RopeInline, SafeStorage, UnsafeStorage
EXPORTS TankMasterRpcControl
SHARES TankMaster, TankMasterRpcControl, Rope
= BEGIN OPEN TankMaster, RpcControl: TankMasterRpcControl, RpcPublic:
RPC;
-- Standard remote binding routines.
bound: BOOLEAN ← FALSE;
myInterface: RpcPrivate.ExportHandle ← NULL;
paramZones: RpcPublic.Zones ← RpcPublic.standardZones;
ExportInterface: PUBLIC ENTRY SAFE PROCEDURE [
interfaceName: RpcPublic.InterfaceName,
user: RpcPublic.Principal,
password: RpcPublic.EncryptionKey,
parameterStorage: RpcPublic.Zones ] =
TRUSTED BEGIN ENABLE UNWIND => NULL;
IsNull: PROCEDURE [string: LONG STRING] RETURNS [BOOLEAN] =
INLINE {RETURN[ string=NIL OR string.length=0 ]};
IF bound THEN Lupine.BindingError;
BEGIN
type: STRING = [RpcPrivate.maxShortStringLength];
instance: STRING = [RpcPrivate.maxShortStringLength];
userString: STRING = [RpcPrivate.maxPrincipalLength];
ConvertUnsafe.AppendRope[to: type, from: interfaceName.type];
ConvertUnsafe.AppendRope[to: instance, from: interfaceName.instance];
ConvertUnsafe.AppendRope[to: userString, from: user];
myInterface ← RpcPrivate.ExportInterface [
interface: [
type: IF ~IsNull[type]
THEN type ELSE "TankMaster~176#227#36526563207"L,
instance: instance,
version: interfaceName.version ],
user: userString, password: password,
dispatcher: ServerDispatcher,
localOnly: RpcControl.InterMdsCallsOnly,
stubProtocol: RpcControl.LupineProtocolVersion ];
END;
paramZones ← [
gc: IF parameterStorage.gc # NIL
THEN parameterStorage.gc ELSE SafeStorage.GetSystemZone[],
heap: IF parameterStorage.heap # NIL
THEN parameterStorage.heap ELSE UnsafeStorage.GetSystemUZone[],
mds: IF parameterStorage.mds # NIL
THEN parameterStorage.mds ELSE Heap.systemMDSZone ];
bound ← TRUE;
END;
UnexportInterface: PUBLIC ENTRY SAFE PROCEDURE =
TRUSTED BEGIN ENABLE UNWIND => NULL;
IF ~bound THEN Lupine.BindingError;
myInterface ← RpcPrivate.UnexportInterface[myInterface];
paramZones ← RpcPublic.standardZones;
bound ← FALSE;
END;
-- Public procedure dispatcher and public signal and error catcher.
ServerDispatcher: --PROCEDURE [pkt: RPCPkt, callLength: DataLength,
-- lastPkt: BOOLEAN, localConversation: Conversation] RETURNS [returnLength:
-- DataLength]-- RpcPrivate.Dispatcher =
BEGIN
-- Catch public signals.
ENABLE BEGIN
END; -- Catch public signals.
-- Call public procedures (still in dispatcher).
SELECT LOOPHOLE[pkt.data[0], RpcControl.ProcedureIndex] FROM
AddPlayer => RETURN[
AddPlayerStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
localConversation: localConversation]];
RemovePlayer => RETURN[
RemovePlayerStub[pkt: pkt, callLength: callLength, lastPkt:
lastPkt, localConversation: localConversation]];
GetPlayer => RETURN[
GetPlayerStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
localConversation: localConversation]];
Update => RETURN[
UpdateStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
localConversation: localConversation]];
ScoreHit => RETURN[
ScoreHitStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
localConversation: localConversation]];
ENDCASE => RETURN[Lupine.DispatchingError[]];
END; -- ServerDispatcher
-- Public procedure dispatcher stubs.
AddPlayerStub: --PROCEDURE [name: Rope.ROPE, address: Machine] RETURNS
-- [ok: BOOLEAN, id: CARDINAL]-- RpcPrivate.Dispatcher =
INLINE BEGIN
name: Rope.ROPE;
address: Machine;
ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
transferIndex (0): RpcControl.ProcedureIndex, address (1): Machine];
ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
ok (0): BOOLEAN, id (1): CARDINAL];
argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
resPkt: LONG POINTER TO ResultOverlay;
pktLength: RpcPrivate.DataLength ← 2;
BEGIN -- OnePkt.
onePkt: BOOLEAN = lastPkt;
IF ~onePkt THEN BEGIN -- Must move statics from pkt now.
[address: address] ← argPkt↑;
END;
BEGIN -- Unmarshal name: Rope.ROPE from pkt.data[pktLength].
ropeIsNIL: Lupine.NilHeader;
IF pktLength+2 > RpcPrivate.maxDataLength
THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength:
pktLength];
ropeIsNIL ← pkt.data[pktLength]; pktLength ← pktLength+1;
IF ropeIsNIL
THEN name ← NIL
ELSE BEGIN
ropeLength: Lupine.RopeHeader;
textRope: Rope.Text;
ropeLength ← pkt.data[pktLength]; pktLength ← pktLength+1;
IF ropeLength > LAST[NAT]
THEN Lupine.UnmarshalingError;
name ← textRope ← RopeInline.NewText[size: ropeLength];
pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[ropeLength],
alwaysOnePkt: FALSE];
END; -- IF ropeIsNIL.
END; -- Unmarshal name.
Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
resPkt ← @pkt.data[0];
IF onePkt
THEN [resPkt.ok, resPkt.id] ←
AddPlayer[name, argPkt.address]
ELSE [resPkt.ok, resPkt.id] ←
AddPlayer[name, address];
END; -- OnePkt.
pktLength ← 2;
RETURN[returnLength: pktLength];
END; -- AddPlayerStub.
RemovePlayerStub: --PROCEDURE [id: CARDINAL]-- RpcPrivate.Dispatcher
=
INLINE BEGIN
ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
transferIndex (0): RpcControl.ProcedureIndex, id (1): CARDINAL];
argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
pktLength: RpcPrivate.DataLength;
Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
RemovePlayer[argPkt.id];
pktLength ← 0;
RETURN[returnLength: pktLength];
END; -- RemovePlayerStub.
GetPlayerStub: --PROCEDURE [id: CARDINAL] RETURNS [name: Rope.ROPE,
-- address: Machine, score: INTEGER]-- RpcPrivate.Dispatcher =
INLINE BEGIN
name: Rope.ROPE;
ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
transferIndex (0): RpcControl.ProcedureIndex, id (1): CARDINAL];
ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
address (0): Machine, score (1): INTEGER];
argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
pktLength: RpcPrivate.DataLength;
Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
[name, resPkt.address, resPkt.score] ←
GetPlayer[argPkt.id];
pktLength ← 2;
BEGIN -- Marshal name: Rope.ROPE to pkt.data[pktLength].
IF pktLength+2 > RpcPrivate.maxDataLength
THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
pkt.data[pktLength] ← name=NIL; pktLength ← pktLength+1;
IF name # NIL
THEN BEGIN
textRope: Rope.Text = RopeInline.InlineFlatten[r: name];
pkt.data[pktLength] ← textRope.length; pktLength ← pktLength+1;
pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[textRope.length],
alwaysOnePkt: FALSE];
END; -- IF name # NIL.
END; -- Marshal name.
RETURN[returnLength: pktLength];
END; -- GetPlayerStub.
UpdateStub: --PROCEDURE [id: CARDINAL, tank: Tank, torp: Torp]
-- RETURNS [anonP1id2562562: WorldStateRec]-- RpcPrivate.Dispatcher
=
INLINE BEGIN
ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
transferIndex (0): RpcControl.ProcedureIndex, id (1): CARDINAL,
tank (2): Tank, torp (5): Torp];
ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
anonP1id2562562 (0): WorldStateRec];
argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
pktLength: RpcPrivate.DataLength;
Lupine.CheckPktLength[pkt: pkt, pktLength: 8];
[resPkt.anonP1id2562562] ← Update[argPkt.id, argPkt.tank, argPkt.torp];
pktLength ← 57;
RETURN[returnLength: pktLength];
END; -- UpdateStub.
ScoreHitStub: --PROCEDURE [torp: CARDINAL, target: CARDINAL]-- RpcPrivate.Dispatcher
=
INLINE BEGIN
ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
transferIndex (0): RpcControl.ProcedureIndex, torp (1): CARDINAL,
target (2): CARDINAL];
argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
pktLength: RpcPrivate.DataLength;
Lupine.CheckPktLength[pkt: pkt, pktLength: 3];
ScoreHit[argPkt.torp, argPkt.target];
pktLength ← 0;
RETURN[returnLength: pktLength];
END; -- ScoreHitStub.
-- No module initialization.
END. -- TankMasterRpcServerImpl.