-- Stub file  was translated on July 13, 1984 6:26:15 pm PDT by Lupine of July 13, 1984 6:17:44 pm PDT
-- Source interface Lark came from file Lark.bcd, which was created on March 22, 1984 5:24:03 pm PST with version stamp 363#357#6104565341 from source of December 19, 1983 1:34:23 pm PST.

-- The RPC stub modules for Lark are:
--   LarkRpcControl.mesa;
--   LarkRpcClientImpl.mesa;
--   LarkRpcBinderImpl.mesa;
--   LarkRpcServerImpl.mesa.

-- The parameters for this translation are:
--   Target language = Cedar
--   Default parameter passing = VALUE
--   Deallocate server heap arguments = TRUE
--   Inline RpcServerImpl dispatcher stubs = FALSE
--   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
  DESFace,
  PupTypes,
  RPC,
  RPCPkt,
  Lark,
  LarkRpcControl USING [InterMdsCallsOnly, LupineProtocolVersion, ProcedureIndex,
      SignalIndex],
  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]--,
  LupineRuntimeExtras --USING SOME OF [MarshalRope, MarshalAtom, UnmarshalRope,
      -- UnmarshalAtom]--,
  Atom --USING SOME OF [GetPName, MakeAtom]--,
  Rope --USING SOME OF [InlineFlatten, Length, NewText, Text]--;


LarkRpcClientImpl: MONITOR
  IMPORTS RpcPrivate: RPCLupine, Lupine: LupineRuntime, LupineRuntimeExtras:
      LupineRuntimeExtras, Atom, Rope
  EXPORTS Lark, LarkRpcControl
  SHARES  Lark, LarkRpcControl, Rope
  = BEGIN OPEN Lark, RpcControl: LarkRpcControl, 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 "Lark~363#357#6104565341",
        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.

  Reset: PUBLIC SAFE PROCEDURE [shh: SHHH, rName: ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Reset];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+35] 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, localConversation:
        shh];
    argPkt.transferIndex ← Reset;
    BEGIN  -- Marshal rName: ROPE to pkt.data[pktLength].
      pktLength ← LupineRuntimeExtras.MarshalRope[rName, pkt, pktLength];
      END;  -- Marshal rName.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- Reset.

  GenerateTones: PUBLIC SAFE PROCEDURE [shh: SHHH, f1: Hertz, f2: Hertz,
      modulation: Hertz, on: Milliseconds, off: Milliseconds, repetitions:
      CARDINAL, waveTable: CARDINAL, queueIt: BOOLEAN, notify: CommandEvent]
    RETURNS [--ok:-- BOOLEAN] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GenerateTones, f1
        (1): Hertz, f2 (2): Hertz, modulation (3): Hertz, on (4): Milliseconds,
        off (5): Milliseconds, repetitions (6): CARDINAL, waveTable (7):
        CARDINAL, queueIt (8): BOOLEAN, notify (9): CommandEvent];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        ok (0): BOOLEAN];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+10] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 10;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [f1: f1, f2: f2, modulation: modulation, on: on, off:
        off, repetitions: repetitions, waveTable: waveTable, queueIt: queueIt,
        notify: notify];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.ok];
    END;  -- GenerateTones.

  Feep: PUBLIC SAFE PROCEDURE [shh: SHHH, on: Milliseconds, off: Milliseconds,
      waveTable: CARDINAL, queueIt: BOOLEAN, notify: CommandEvent, events:
      CommandEvents]
    RETURNS [--ok:-- BOOLEAN] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Feep, on (1): Milliseconds,
        off (2): Milliseconds, waveTable (3): CARDINAL, queueIt (4): BOOLEAN,
        notify (5): CommandEvent];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        ok (0): BOOLEAN];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+42] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 6;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [on: on, off: off, waveTable: waveTable, queueIt: queueIt,
        notify: notify];
    BEGIN  -- Marshal events: CommandEvents to pkt.data[pktLength].
      pktLength ← MarshalCommandEvents[events, pkt, pktLength];
      END;  -- Marshal events.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.ok];
    END;  -- Feep.

  Commands: PUBLIC SAFE PROCEDURE [shh: SHHH, events: CommandEvents]
      =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Commands];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+37] 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, localConversation:
        shh];
    argPkt.transferIndex ← Commands;
    BEGIN  -- Marshal events: CommandEvents to pkt.data[pktLength].
      pktLength ← MarshalCommandEvents[events, pkt, pktLength];
      END;  -- Marshal events.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- Commands.

  Connect: PUBLIC SAFE PROCEDURE [shh: SHHH, specs: ConnectionSpec]
      =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Connect];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+13] 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, localConversation:
        shh];
    argPkt.transferIndex ← Connect;
    BEGIN  -- Marshal specs: ConnectionSpec to pkt.data[pktLength].
      pktLength ← MarshalConnectionSpec[specs, pkt, pktLength];
      END;  -- Marshal specs.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- Connect.

  Disconnect: PUBLIC SAFE PROCEDURE [shh: SHHH, buffer: VoiceBuffer]
      =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Disconnect, buffer
        (1): VoiceBuffer];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+2] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [buffer: buffer];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- Disconnect.

  PleaseRegister: PUBLIC SAFE PROCEDURE [shh: SHHH] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← PleaseRegister];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+1] 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, localConversation:
        shh];
    argPkt.transferIndex ← PleaseRegister;
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- PleaseRegister.

  WhatIsStatus: PUBLIC SAFE PROCEDURE [shh: SHHH, which: CARDINAL]
      RETURNS [--next:-- CARDINAL, --events:-- StatusEvents] =
    TRUSTED BEGIN
    events: StatusEvents;
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← WhatIsStatus, which
        (1): CARDINAL];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        next (0): CARDINAL];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+69] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [which: which];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 69, signalHandler: ClientDispatcher];
    pktLength ← 1;
    BEGIN  -- Unmarshal events: StatusEvents from pkt.data[pktLength].
      [events, pktLength] ← UnmarshalStatusEvents[pkt, pktLength];
      END;  -- Unmarshal events.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    RETURN[resPkt.next, events];
    END;  -- WhatIsStatus.

  WhatAreConnections: PUBLIC SAFE PROCEDURE [shh: SHHH, which: CARDINAL]
      RETURNS [--next:-- CARDINAL, --specs:-- ConnectionSpec] =
    TRUSTED BEGIN
    specs: ConnectionSpec;
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← WhatAreConnections,
        which (1): CARDINAL];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        next (0): CARDINAL];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+13] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [which: which];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 13, signalHandler: ClientDispatcher];
    pktLength ← 1;
    BEGIN  -- Unmarshal specs: ConnectionSpec from pkt.data[pktLength].
      [specs, pktLength] ← UnmarshalConnectionSpec[pkt, pktLength];
      END;  -- Unmarshal specs.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    RETURN[resPkt.next, specs];
    END;  -- WhatAreConnections.

  WhatAreTones: PUBLIC SAFE PROCEDURE [shh: SHHH] RETURNS [--anonP1id726574:--
      BOOLEAN] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← WhatAreTones];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        anonP1id726574 (0): BOOLEAN];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+1] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt.transferIndex ← WhatAreTones;
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.anonP1id726574];
    END;  -- WhatAreTones.

  SetKeyTable: PUBLIC SAFE PROCEDURE [shh: SHHH, table: KeyTable] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetKeyTable];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+73] 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, localConversation:
        shh];
    argPkt.transferIndex ← SetKeyTable;
    BEGIN  -- Marshal table: KeyTable to pkt.data[pktLength].
      pktLength ← MarshalKeyTable[table, pkt, pktLength];
      END;  -- Marshal table.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- SetKeyTable.

  CommandString: PUBLIC SAFE PROCEDURE [shh: SHHH, device: Device,
      commands: ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← CommandString, device
        (1): Device];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+36] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [device: device];
    BEGIN  -- Marshal commands: ROPE to pkt.data[pktLength].
      pktLength ← LupineRuntimeExtras.MarshalRope[commands, pkt, pktLength];
      END;  -- Marshal commands.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- CommandString.

  PleaseLogin: PUBLIC SAFE PROCEDURE [shh: SHHH] RETURNS [--will:--
      BOOL] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← PleaseLogin];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        will (0): BOOL];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+1] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt.transferIndex ← PleaseLogin;
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.will];
    END;  -- PleaseLogin.

  EchoSupression: PUBLIC SAFE PROCEDURE [shh: SHHH, echo: EchoParameters]
      =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← EchoSupression];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+10] 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, localConversation:
        shh];
    argPkt.transferIndex ← EchoSupression;
    BEGIN  -- Marshal echo: EchoParameters to pkt.data[pktLength].
      pktLength ← MarshalEchoParameters[echo, pkt, pktLength];
      END;  -- Marshal echo.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- EchoSupression.

  SetHostNumber: PUBLIC SAFE PROCEDURE [shh: SHHH, host: Machine] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetHostNumber, host
        (1): Machine];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+2] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [host: host];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- SetHostNumber.


-- 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.
MarshalKeyTable: PROC[value: Lark.KeyTable, pkt: RpcPrivate.StubPkt,
    pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  BEGIN  -- Marshal value↑: Lark.KeyTableBody to pkt.data[pktLength].
    pkt.data[pktLength] ← value=NIL;  pktLength ← pktLength+1;
    IF value # NIL THEN BEGIN
      -- Record has a sequence, put its length up front.
      Lupine.StubPktDoubleWord[pkt, pktLength]↑ ← LENGTH[DESCRIPTOR[value↑]];
      pktLength ← pktLength + 2;
      pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: LOOPHOLE[value], dataLength: SIZE[Lark.KeyTableBody[LENGTH[DESCRIPTOR[value↑]]]],
          alwaysOnePkt: TRUE];
      END;  -- IF value # NIL.
    END;  -- Marshal value↑.
  };END;

UnmarshalConnectionSpec: PROC[pkt: RpcPrivate.StubPkt, pktLength0:
    RpcPrivate.DataLength]
  RETURNS[value: Lark.ConnectionSpec, pktLength: RpcPrivate.DataLength]
      = BEGIN
  pktLength ← pktLength0; {
  isNIL: Lupine.NilHeader;
  isNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
  IF isNIL
    THEN value ← NIL
    ELSE BEGIN
      value ← (paramZones.gc.NEW[Lark.ConnectionSpecRec]);
      BEGIN  -- Unmarshal value↑: Lark.ConnectionSpecRec from pkt.data[pktLength].
        pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
            dataAdr: LOOPHOLE[value], dataLength: SIZE[Lark.ConnectionSpecRec],
            alwaysOnePkt: TRUE];
        END;  -- Unmarshal value↑.
      END;  -- IF isNIL.
  };END;

UnmarshalStatusEvents: PROC[pkt: RpcPrivate.StubPkt, pktLength0: RpcPrivate.DataLength]
  RETURNS[value: Lark.StatusEvents, pktLength: RpcPrivate.DataLength]
      = BEGIN
  pktLength ← pktLength0; {
  BEGIN  -- Unmarshal value↑: Lark.StatusEventSequence from pkt.data[pktLength].
    recordIsNIL: Lupine.NilHeader;
    recordIsNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
    IF recordIsNIL
      THEN value ← NIL
      ELSE BEGIN
        seqLength: Lupine.SequenceHeader;
        seqLength ← Lupine.StubPktDoubleWord[pkt, pktLength]↑;
        pktLength ← pktLength + 2;
        value ← (paramZones.gc.NEW[Lark.StatusEventSequence[Lupine.SHORT[seqLength]]]);
        pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
            dataAdr: LOOPHOLE[value], dataLength: SIZE[Lark.StatusEventSequence[LENGTH[DESCRIPTOR[value↑]]]],
            alwaysOnePkt: TRUE];
        END;  -- IF recordIsNIL.
    END;  -- Unmarshal value↑.
  };END;

MarshalConnectionSpec: PROC[value: Lark.ConnectionSpec, pkt: RpcPrivate.StubPkt,
    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↑: Lark.ConnectionSpecRec to pkt.data[pktLength].
      pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: LOOPHOLE[value], dataLength: SIZE[Lark.ConnectionSpecRec],
          alwaysOnePkt: TRUE];
      END;  -- Marshal value↑.
  };END;

MarshalCommandEvents: PROC[value: Lark.CommandEvents, pkt: RpcPrivate.StubPkt,
    pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  BEGIN  -- Marshal value↑: Lark.CommandEventSequence to pkt.data[pktLength].
    pkt.data[pktLength] ← value=NIL;  pktLength ← pktLength+1;
    IF value # NIL THEN BEGIN
      -- Record has a sequence, put its length up front.
      Lupine.StubPktDoubleWord[pkt, pktLength]↑ ← LENGTH[DESCRIPTOR[value↑]];
      pktLength ← pktLength + 2;
      pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: LOOPHOLE[value], dataLength: SIZE[Lark.CommandEventSequence[LENGTH[DESCRIPTOR[value↑]]]],
          alwaysOnePkt: TRUE];
      END;  -- IF value # NIL.
    END;  -- Marshal value↑.
  };END;

MarshalEchoParameters: PROC[value: Lark.EchoParameters, pkt: RpcPrivate.StubPkt,
    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↑: Lark.EchoParameterRecord to pkt.data[pktLength].
      pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: LOOPHOLE[value], dataLength: SIZE[Lark.EchoParameterRecord],
          alwaysOnePkt: TRUE];
      END;  -- Marshal value↑.
  };END;



-- No module initialization.

END.  -- LarkRpcClientImpl.