-- Copyright (C) 1987 by Xerox Corporation.  All rights reserved.
-- Stub file  was translated on April 4, 1987 3:21:16 pm PST by Lupine of January 22, 1987 5:37:32 pm PST
-- Source interface LarkFeep came from file LarkFeep.bcd, which was created on April 4, 1987 3:21:13 pm PST with version stamp 101#214#2235355475 from source of February 6, 1987 11:04:05 am PST.

-- The RPC stub modules for LarkFeep are:
--   LarkFeepRpcControl.mesa;
--   LarkFeepRpcClientImpl.mesa;
--   LarkFeepRpcBinderImpl.mesa;
--   LarkFeepRpcServerImpl.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
  RefID,
  Rope,
  Thrush,
  LarkFeep,
  LarkFeepRpcControl USING [InterfaceRecord, InterMdsCallsOnly, LupineProtocolVersion,
      ProcedureIndex, SignalIndex],
  RPC --USING SOME OF [InterfaceName, standardZones, Zones]--,
  RPCLupine --USING SOME OF [Alloc, Call, DataLength, DeAlloc, Dispatcher,
      -- GetPkt, GetStubPkt, ImportHandle, ImportInterface, ImportInterfaceWithHost,
      -- maxDataLength, maxPrincipalLength, maxShortStringLength, noHost,
      -- pktOverhead, ReceiveExtraPkt, RPCHost, SendPrelimPkt, StartCall,
      -- StartSignal, StubPkt, UnimportInterface]--,
  LupineRuntime --USING SOME OF [BindingError, CheckPktLength, CopyFromPkt,
      -- CopyFromMultiplePkts, CopyToPkt, CopyToMultiplePkts, defaultZones,
      -- DispatchingError, FinishThisPkt, ListHeader, MarshalingError,
      -- MarshalingExprError, MarshalAtom, MarshalRope, NilHeader, ProtocolError,
      -- RopeHeader, RpcPktDoubleWord, RuntimeError, SequenceHeader, SHORT,
      -- StartNextPkt, StringHeader, StubPktDoubleWord, TranslationError,
      -- UnmarshalingError, UnmarshalingExprError, UnmarshalAtom, UnmarshalRope,
      -- WordsForChars]--,
  Atom --USING SOME OF [GetPName, MakeAtom]--,
  PrincOpsUtils --USING SOME OF [Enter, Exit]--,
  VM --USING SOME OF [AddressForPageNumber, PageCount, PageNumber,
      -- PageNumberForAddress, PagesForWords]--;


LarkFeepRpcClientImpl: MONITOR
  IMPORTS RpcPrivate: RPCLupine, Lupine: LupineRuntime, Atom, PrincOpsUtils,
      Rope
  EXPORTS LarkFeepRpcControl
  SHARES  LarkFeep, LarkFeepRpcControl, Rope
  = BEGIN OPEN LarkFeep, RpcControl: LarkFeepRpcControl, RpcPublic:
      RPC;


-- Standard remote binding routines.


  ImportInterface: PUBLIC ENTRY SAFE PROCEDURE [
        interface: RpcControl.InterfaceRecord,
        interfaceName: RpcPublic.InterfaceName,
        parameterStorage: RpcPublic.Zones,
        hostHint: RpcPrivate.RPCHost←RpcPrivate.noHost ] =
    TRUSTED BEGIN ENABLE UNWIND => NULL;
    IsNull: PROCEDURE [string: Rope.ROPE] RETURNS [BOOLEAN] =
      INLINE {RETURN[string.Length[] = 0]};
        interface↑ ← [clientStubFeep: clientStubFeep, clientStubFlash:
            clientStubFlash];
    interface.myInterface ← RpcPrivate.ImportInterfaceWithHost [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "LarkFeep~101#214#2235355475",
        instance: interfaceName.instance,
        version: interfaceName.version ],
      localOnly: RpcControl.InterMdsCallsOnly,
      stubProtocol: RpcControl.LupineProtocolVersion,
      hostHint: hostHint ];
    interface.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 ];
    interface.bound ← TRUE;
    END;



-- Remote public procedure stubs.

  clientStubFeep: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shhh: Thrush.SHHH, serviceID: RefID.ID, convID: Thrush.ConversationID,
      requestingParty: Thrush.PartyID, number: Rope.ROPE, noisy: BOOLEAN,
      on: CARDINAL, off: CARDINAL]
    RETURNS [nb: Thrush.NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Feep, serviceID
        (1): RefID.ID, convID (3): Thrush.ConversationID, requestingParty
        (5): Thrush.PartyID, noisy (7): BOOLEAN, on (8): CARDINAL, off
        (9): CARDINAL];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 10;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: shhh];
      argPkt↑ ← [serviceID: serviceID, convID: convID, requestingParty:
          requestingParty, noisy: noisy, on: on, off: off];
      BEGIN  -- Marshal number: Rope.ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[number, pkt, pktLength, FALSE];
        END;  -- Marshal number.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 254, signalHandler: ClientDispatcher];
      pktLength ← 0;
      BEGIN  -- Unmarshal nb: Thrush.NB from pkt.data[pktLength].
        [nb, pktLength] ← Lupine.UnmarshalAtom[pkt, pktLength];
        END;  -- Unmarshal nb.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[nb];
      END;  -- UNWIND.
    END;  -- Feep.

  clientStubFlash: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shhh: Thrush.SHHH, serviceID: RefID.ID, convID: Thrush.ConversationID,
      requestingParty: Thrush.PartyID, actionID: Thrush.ActionID, extraTime:
      CARDINAL]
    RETURNS [nb: Thrush.NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Flash, serviceID
        (1): RefID.ID, convID (3): Thrush.ConversationID, requestingParty
        (5): Thrush.PartyID, actionID (7): Thrush.ActionID, extraTime (9):
        CARDINAL];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 10;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: shhh];
      argPkt↑ ← [serviceID: serviceID, convID: convID, requestingParty:
          requestingParty, actionID: actionID, extraTime: extraTime];
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 254, signalHandler: ClientDispatcher];
      pktLength ← 0;
      BEGIN  -- Unmarshal nb: Thrush.NB from pkt.data[pktLength].
        [nb, pktLength] ← Lupine.UnmarshalAtom[pkt, pktLength];
        END;  -- Unmarshal nb.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[nb];
      END;  -- UNWIND.
    END;  -- Flash.


-- Remote public signals and errors.


-- Public signal and error dispatcher.

  ClientDispatcher: --PROCEDURE [pkt: RPCPkt, callLength: DataLength,
      -- lastPkt: BOOLEAN, localConversation: Conversation] RETURNS [returnLength:
      -- DataLength]-- RpcPrivate.Dispatcher =
    BEGIN

    SELECT LOOPHOLE[pkt.data[0], RpcControl.SignalIndex] FROM
      ENDCASE => RETURN[Lupine.DispatchingError[]];

    END;  -- ClientDispatcher


-- Public signal and error dispatcher stubs.


-- Marshall/Unmarshal procedures.


-- No module initialization.

END.  -- LarkFeepRpcClientImpl.