-- Stub file  was translated on April 20, 1984 3:37:41 pm PST by Lupine of December 20, 1983 1:22:57 pm PST
-- Source interface TalkerOps came from file TalkerOps.bcd, which was created on April 20, 1984 3:37:28 pm PST with version stamp 234#303#10372337607 from source of April 19, 1984 5:48:02 pm PST.

-- The RPC stub modules for TalkerOps are:
--   TalkerOpsRpcControl.mesa;
--   TalkerOpsRpcClientImpl.mesa;
--   TalkerOpsRpcBinderImpl.mesa;
--   TalkerOpsRpcServerImpl.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].
-- Last Edited by: Greene, April 20, 1984 3:38:13 pm PST


DIRECTORY
  Rope,
  TalkerOps,
  TalkerOpsRpcControl USING [InterMdsCallsOnly, LupineProtocolVersion,
      ProcedureIndex, SignalIndex],
  RPC USING [InterfaceName, standardZones, Zones],
  RPCLupine --USING SOME OF [Call, DataLength, Dispatcher, GetStubPkt,
      -- ImportHandle, ImportInterface, maxDataLength, maxPrincipalLength,
      -- maxShortStringLength, pktOverhead, ReceiveExtraPkt, SendPrelimPkt,
      -- StartCall, StartSignal, StubPkt, UnimportInterface]--,
  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]--;


TalkerOpsRpcClientImpl: MONITOR
  IMPORTS RpcPrivate: RPCLupine, Lupine: LupineRuntime, Atom, Rope
  EXPORTS TalkerOpsRpcControl
  SHARES  TalkerOps, TalkerOpsRpcControl, Rope
  = BEGIN OPEN TalkerOps, RpcControl: TalkerOpsRpcControl, RpcPublic:
      RPC;


-- Standard remote binding routines.

  bound: BOOLEAN ← FALSE;
  myInterface: RpcPrivate.ImportHandle;
  paramZones: RpcPublic.Zones ← RpcPublic.standardZones;

  ImportInterface: PUBLIC ENTRY SAFE PROCEDURE [
        interfaceName: RpcPublic.InterfaceName,
        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.ImportInterface [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "TalkerOps~234#303#10372337607",
        instance: interfaceName.instance,
        version: interfaceName.version ],
      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;

  UnimportInterface: PUBLIC ENTRY SAFE PROCEDURE =
    TRUSTED BEGIN ENABLE UNWIND => NULL;
    IF ~bound THEN Lupine.BindingError;
    myInterface ← RpcPrivate.UnimportInterface[myInterface];
    paramZones ← RpcPublic.standardZones;
    bound ← FALSE;
    END;



-- Remote public procedure stubs.

  PutMyLine: PUBLIC SAFE PROCEDURE [myName: Rope.ROPE, line: Rope.ROPE]
      =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← PutMyLine];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+254] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface];
    argPkt.transferIndex ← PutMyLine;
    BEGIN  -- Marshal myName: Rope.ROPE to pkt.data[pktLength].
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
      pkt.data[pktLength] ← myName=NIL;  pktLength ← pktLength+1;
      IF myName # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: myName];
          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 myName # NIL.
      END;  -- Marshal myName.
    BEGIN  -- Marshal line: Rope.ROPE to pkt.data[pktLength].
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
      pkt.data[pktLength] ← line=NIL;  pktLength ← pktLength+1;
      IF line # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: line];
          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 line # NIL.
      END;  -- Marshal line.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- PutMyLine.

  JoinWith: PUBLIC SAFE PROCEDURE [myName: Rope.ROPE, newConversant:
      Rope.ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← JoinWith];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+254] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface];
    argPkt.transferIndex ← JoinWith;
    BEGIN  -- Marshal myName: Rope.ROPE to pkt.data[pktLength].
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
      pkt.data[pktLength] ← myName=NIL;  pktLength ← pktLength+1;
      IF myName # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: myName];
          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 myName # NIL.
      END;  -- Marshal myName.
    BEGIN  -- Marshal newConversant: Rope.ROPE to pkt.data[pktLength].
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
      pkt.data[pktLength] ← newConversant=NIL;  pktLength ← pktLength+1;
      IF newConversant # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: newConversant];
          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 newConversant # NIL.
      END;  -- Marshal newConversant.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- JoinWith.

  DealMeOut: PUBLIC SAFE PROCEDURE [myName: Rope.ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← DealMeOut];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+254] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface];
    argPkt.transferIndex ← DealMeOut;
    BEGIN  -- Marshal myName: Rope.ROPE to pkt.data[pktLength].
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
      pkt.data[pktLength] ← myName=NIL;  pktLength ← pktLength+1;
      IF myName # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: myName];
          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 myName # NIL.
      END;  -- Marshal myName.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- DealMeOut.


-- 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.


-- No module initialization.

END.  -- TalkerOpsRpcClientImpl.