-- Copyright (C) 1986 by Xerox Corporation.  All rights reserved.
-- Stub file  was translated on June 25, 1986 10:04:34 am PDT by Lupine of February 22, 1986 5:15:54 pm PST
-- Source interface VoiceTemp came from file VoiceTemp.bcd, which was created on June 25, 1986 10:04:23 am PDT with version stamp 332#245#31477705223 from source of June 25, 1986 10:03:13 am PDT.

-- The RPC stub modules for VoiceTemp are:
--   VoiceTempRpcControl.mesa;
--   VoiceTempRpcClientImpl.mesa;
--   VoiceTempRpcBinderImpl.mesa;
--   VoiceTempRpcServerImpl.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,
  Thrush,
  VoiceTemp,
  VoiceTempRpcControl 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, maxDataLength,
      -- maxPrincipalLength, maxShortStringLength, pktOverhead, ReceiveExtraPkt,
      -- SendPrelimPkt, StartCall, StartSignal, StubPkt, UnimportInterface]--,
  RPCLupineExtras --USING SOME OF [ImportInterfaceWithHost, noHost,
      -- RPCHost]--,
  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]--,
  Rope --USING SOME OF [InlineFlatten, Length, NewText, Text]--,
  VM --USING SOME OF [AddressForPageNumber, PageCount, PageNumber,
      -- PageNumberForAddress, PagesForWords]--;


VoiceTempRpcClientImpl: MONITOR
  IMPORTS RpcPrivate: RPCLupine, RpcPrivateExtras: RPCLupineExtras,
      Lupine: LupineRuntime, Atom, PrincOpsUtils, Rope
  EXPORTS VoiceTempRpcControl
  SHARES  VoiceTemp, VoiceTempRpcControl, Rope
  = BEGIN OPEN VoiceTemp, RpcControl: VoiceTempRpcControl, RpcPublic:
      RPC;


-- Standard remote binding routines.


  ImportInterface: PUBLIC ENTRY SAFE PROCEDURE [
        interface: RpcControl.InterfaceRecord,
        interfaceName: RpcPublic.InterfaceName,
        parameterStorage: RpcPublic.Zones,
        hostHint: RpcPrivateExtras.RPCHost←RpcPrivateExtras.noHost
            ] =
    TRUSTED BEGIN ENABLE UNWIND => NULL;
    IsNull: PROCEDURE [string: Rope.ROPE] RETURNS [BOOLEAN] =
      INLINE {RETURN[string.Length[] = 0]};
        interface↑ ← [clientStubPlay: clientStubPlay, clientStubRecord:
            clientStubRecord, clientStubStop: clientStubStop, clientStubDescribeInterval:
            clientStubDescribeInterval];
    interface.myInterface ← RpcPrivateExtras.ImportInterfaceWithHost
        [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "VoiceTemp~332#245#31477705223",
        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.

  clientStubPlay: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shhh: Thrush.SHHH, credentials: Thrush.Credentials, serviceID: RefID.ID,
      intervalSpec: IntervalSpec, queueIt: BOOL]
    RETURNS [nb: Thrush.NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Play, credentials
        (1): Thrush.Credentials, serviceID (9): RefID.ID, queueIt (11):
        BOOL];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 12;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: shhh];
      argPkt↑ ← [credentials: credentials, serviceID: serviceID, queueIt:
          queueIt];
      BEGIN  -- Marshal intervalSpec: IntervalSpec to pkt.data[pktLength].
        pktLength ← MarshalIntervalSpec[intervalSpec, pkt, pktLength];
        END;  -- Marshal intervalSpec.
      [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;  -- Play.

  clientStubRecord: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shhh: Thrush.SHHH, credentials: Thrush.Credentials, serviceID: RefID.ID,
      intervalSpec: IntervalSpec, queueIt: BOOL]
    RETURNS [nb: Thrush.NB, tuneID: TuneID] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Record, credentials
        (1): Thrush.Credentials, serviceID (9): RefID.ID, queueIt (11):
        BOOL];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        tuneID (0): TuneID];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 12;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: shhh];
      argPkt↑ ← [credentials: credentials, serviceID: serviceID, queueIt:
          queueIt];
      BEGIN  -- Marshal intervalSpec: IntervalSpec to pkt.data[pktLength].
        pktLength ← MarshalIntervalSpec[intervalSpec, pkt, pktLength];
        END;  -- Marshal intervalSpec.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 254, signalHandler: ClientDispatcher];
      pktLength ← 2;
      BEGIN  -- OnePkt.
        -- Move statics from pkt now.
        [tuneID: tuneID] ← resPkt↑;
      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, tuneID];
      END;  -- OnePkt.
      END;  -- UNWIND.
    END;  -- Record.

  clientStubStop: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shhh: Thrush.SHHH, credentials: Thrush.Credentials, serviceID: RefID.ID]
    RETURNS [nb: Thrush.NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Stop, credentials
        (1): Thrush.Credentials, serviceID (9): RefID.ID];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 11;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: shhh];
      argPkt↑ ← [credentials: credentials, serviceID: serviceID];
      [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;  -- Stop.

  clientStubDescribeInterval: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shhh: Thrush.SHHH, credentials: Thrush.Credentials, serviceID: RefID.ID,
      targetInterval: IntervalSpec, minSilence: VoiceTime]
    RETURNS [nb: Thrush.NB, length: INT, intervals: IntervalSpecs]
        =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← DescribeInterval,
        credentials (1): Thrush.Credentials, serviceID (9): RefID.ID, minSilence
        (11): VoiceTime];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        length (0): INT];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 13;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: shhh];
      argPkt↑ ← [credentials: credentials, serviceID: serviceID, minSilence:
          minSilence];
      BEGIN  -- Marshal targetInterval: IntervalSpec to pkt.data[pktLength].
        pktLength ← MarshalIntervalSpec[targetInterval, pkt, pktLength];
        END;  -- Marshal targetInterval.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 254, signalHandler: ClientDispatcher];
      pktLength ← 2;
      BEGIN  -- OnePkt.
        -- Move statics from pkt now.
        [length: length] ← resPkt↑;
      BEGIN  -- Unmarshal nb: Thrush.NB from pkt.data[pktLength].
        [nb, pktLength] ← Lupine.UnmarshalAtom[pkt, pktLength];
        END;  -- Unmarshal nb.
      BEGIN  -- Unmarshal intervals: IntervalSpecs from pkt.data[pktLength].
        lastNode: IntervalSpecs ← (intervals ← NIL);
        listLength: Lupine.ListHeader;
        IF pktLength+2 > RpcPrivate.maxDataLength
          THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength:
              pktLength];
        listLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑;
        pktLength ← pktLength + 2;
        WHILE listLength > 0 DO
          thisNode1: IntervalSpecs = interface.paramZones.gc.CONS[--DefaultValue--,NIL];
          BEGIN  -- Unmarshal thisNode1.first: IntervalSpec from pkt.data[pktLength].
            [thisNode1.first, pktLength] ← UnmarshalIntervalSpec[interface,
                pkt, pktLength];
            END;  -- Unmarshal thisNode1.first.
          IF lastNode # NIL
            THEN lastNode ← (lastNode.rest ← thisNode1)
            ELSE lastNode ← (intervals ← thisNode1);
          listLength ← listLength - 1;
          ENDLOOP;  -- WHILE listLength > 0.
        END;  -- Unmarshal intervals.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
RETURN[nb, length, intervals];
      END;  -- OnePkt.
      END;  -- UNWIND.
    END;  -- DescribeInterval.


-- 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.
UnmarshalIntervalSpec: PROC[interface: RpcControl.InterfaceRecord,
    pkt: RpcPrivate.RPCPkt, pktLength0: RpcPrivate.DataLength]
  RETURNS[value: VoiceTemp.IntervalSpec, pktLength: RpcPrivate.DataLength]
      = BEGIN
  pktLength ← pktLength0; {
  isNIL: Lupine.NilHeader;
  IF pktLength+1 > RpcPrivate.maxDataLength
    THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
  isNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
  IF isNIL
    THEN value ← NIL
    ELSE BEGIN
      value ← (interface.paramZones.gc.NEW[VoiceTemp.IntervalSpecBody]);
      BEGIN  -- Unmarshal value↑: VoiceTemp.IntervalSpecBody from pkt.data[pktLength].
        pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
            dataAdr: LOOPHOLE[value], dataLength: SIZE[VoiceTemp.IntervalSpecBody],
            alwaysOnePkt: FALSE];
        END;  -- Unmarshal value↑.
      END;  -- IF isNIL.
  };END;

MarshalIntervalSpec: PROC[value: VoiceTemp.IntervalSpec, pkt: RpcPrivate.RPCPkt,
    pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  pkt.data[pktLength] ← value=NIL;  pktLength ← pktLength+1;
  IF value # NIL THEN
    BEGIN  -- Marshal value↑: VoiceTemp.IntervalSpecBody to pkt.data[pktLength].
      pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: LOOPHOLE[value], dataLength: SIZE[VoiceTemp.IntervalSpecBody],
          alwaysOnePkt: TRUE];
      END;  -- Marshal value↑.
  };END;



-- No module initialization.

END.  -- VoiceTempRpcClientImpl.