-- Stub file  was translated on May 1, 1984 9:49:07 pm PDT by Lupine of December 20, 1983 1:22:57 pm PST
-- Source interface FootballMaster came from file FootballMaster.bcd, which was created on May 1, 1984 9:48:45 pm PDT with version stamp 14#16#24677302307 from source of May 1, 1984 9:48:34 pm PDT.

-- The RPC stub modules for FootballMaster are:
--   FootballMasterRpcControl.mesa;
--   FootballMasterRpcClientImpl.mesa;
--   FootballMasterRpcBinderImpl.mesa;
--   FootballMasterRpcServerImpl.mesa.

-- The parameters for this translation are:
--   Target language = Cedar
--   Default parameter passing = VALUE
--   Deallocate server heap arguments = TRUE
--   Inline RpcServerImpl dispatcher stubs = TRUE
--   Declare signals = TRUE
--   Warn about short POINTER ("MDS") allocations = TRUE
--   Maximum number of dynamic heap NEWs = 50, MDS NEWs = 50
--   Acceptable parameter protocols = VersionRange[1..1].


DIRECTORY
  FootballMaster,
  FootballMasterRpcControl 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, defaultZones,
      -- 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]--,
  Rope --USING SOME OF [InlineFlatten, Length, NewText, Text]--;


FootballMasterRpcServerImpl: MONITOR
  IMPORTS FootballMaster, RpcPrivate: RPCLupine, Lupine: LupineRuntime,
      Atom, Rope
  EXPORTS FootballMasterRpcControl
  SHARES  FootballMaster, FootballMasterRpcControl, Rope
  = BEGIN OPEN FootballMaster, RpcControl: FootballMasterRpcControl,
      RpcPublic: RPC;


-- Standard remote binding routines.

  bound: BOOLEAN ← FALSE;
  myInterface: RpcPrivate.ExportHandle;
  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: Rope.ROPE] RETURNS [BOOLEAN] =
      INLINE {RETURN[string.Length[] = 0]};
    IF bound THEN Lupine.BindingError;
    myInterface ← RpcPrivate.ExportInterface [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "FootballMaster~14#16#24677302307",
        instance: interfaceName.instance,
        version: interfaceName.version ],
      user: user,  password: password,
      dispatcher: ServerDispatcher,
      localOnly: RpcControl.InterMdsCallsOnly,
      stubProtocol: RpcControl.LupineProtocolVersion ];
    paramZones ← [
      gc: IF parameterStorage.gc # NIL
        THEN parameterStorage.gc ELSE Lupine.defaultZones.gc,
      heap: IF parameterStorage.heap # NIL
        THEN parameterStorage.heap ELSE Lupine.defaultZones.heap,
      mds: IF parameterStorage.mds # NIL
        THEN parameterStorage.mds ELSE Lupine.defaultZones.mds ];
    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

      StupidFuckingWarnings --SIGNAL [itsGottaHaveAGoddamName: ATOM]--
          =>
        BEGIN
        ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
            transferIndex (0): RpcControl.SignalIndex ← StupidFuckingWarnings];
        argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
        pktLength: RpcPrivate.DataLength ← 1;
        lastPkt: BOOLEAN;
        RpcPrivate.StartSignal[signalPkt: pkt];
        argPkt.transferIndex ← StupidFuckingWarnings;
        BEGIN  -- Marshal itsGottaHaveAGoddamName: ATOM to pkt.data[pktLength].
          pNameOfAtom: Rope.Text = Atom.GetPName[atom: itsGottaHaveAGoddamName];
          IF pktLength+2 > RpcPrivate.maxDataLength
            THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength:
                pktLength];
          pkt.data[pktLength] ← pNameOfAtom=NIL;  pktLength ← pktLength+1;
          IF pNameOfAtom # NIL
            THEN BEGIN
              textRope: Rope.Text = Rope.InlineFlatten[r: pNameOfAtom];
              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 pNameOfAtom # NIL.
          END;  -- Marshal itsGottaHaveAGoddamName.
        [returnLength: , lastPkt: lastPkt] ←
          RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
              maxReturnLength: 0];
        Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
        RESUME[];
        END;  -- StupidFuckingWarnings.

      END;  -- Catch public signals.


    -- Call public procedures (still in dispatcher).

    SELECT LOOPHOLE[pkt.data[0], RpcControl.ProcedureIndex] FROM
      SetCommands => RETURN[
        SetCommandsStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      KickOff => RETURN[
        KickOffStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      SetUp => RETURN[
        SetUpStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      Hike => RETURN[
        HikeStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      TimeOut => RETURN[
        TimeOutStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      PenaltyResponse => RETURN[
        PenaltyResponseStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      DisableDelayOfGame => RETURN[
        DisableDelayOfGameStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      ENDCASE => RETURN[Lupine.DispatchingError[]];

    END;  -- ServerDispatcher


-- Public procedure dispatcher stubs.

  SetCommandsStub: --PROCEDURE [team: Team, c: Commands] RETURNS [anonP1id2290541:
      -- GameRec]-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, team (1): Team, c
        (2): Commands];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        anonP1id2290541 (0): GameRec];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 38];
    [resPkt.anonP1id2290541] ← SetCommands[argPkt.team, argPkt.c];
    pktLength ← 145;
    RETURN[returnLength: pktLength];
    END;  -- SetCommandsStub.

  KickOffStub: --PROCEDURE [team: Team]-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, team (1): Team];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    KickOff[argPkt.team];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- KickOffStub.

  SetUpStub: --PROCEDURE [team: Team]-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, team (1): Team];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    SetUp[argPkt.team];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- SetUpStub.

  HikeStub: --PROCEDURE [team: Team]-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, team (1): Team];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    Hike[argPkt.team];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- HikeStub.

  TimeOutStub: --PROCEDURE [team: Team]-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, team (1): Team];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    TimeOut[argPkt.team];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- TimeOutStub.

  PenaltyResponseStub: --PROCEDURE [team: Team, accepted: BOOLEAN]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, team (1): Team, accepted
        (2): BOOLEAN];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 3];
    PenaltyResponse[argPkt.team, argPkt.accepted];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- PenaltyResponseStub.

  DisableDelayOfGameStub: --PROCEDURE-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    pktLength: RpcPrivate.DataLength;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    DisableDelayOfGame[];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- DisableDelayOfGameStub.


-- No module initialization.

END.  -- FootballMasterRpcServerImpl.