-- Copyright (C) 1986 by Xerox Corporation.  All rights reserved.
-- Stub file  was translated on May 9, 1986 4:57:11 pm PDT by Lupine of February 22, 1986 5:15:54 pm PST
-- Source interface Lark came from file Lark.bcd, which was created on May 9, 1986 3:47:44 pm PDT with version stamp 111#243#11006740257 from source of May 9, 1986 3:28:51 pm PDT.

-- 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 = 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
  DESFace,
  Pup,
  Rope,
  RPC,
  Lark,
  LarkRpcControl USING [InterfaceRecord, InterMdsCallsOnly, LupineProtocolVersion,
      ProcedureIndex, SignalIndex],
  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]--,
  VM --USING SOME OF [AddressForPageNumber, PageCount, PageNumber,
      -- PageNumberForAddress, PagesForWords]--;


LarkRpcClientImpl: MONITOR
  IMPORTS RpcPrivate: RPCLupine, RpcPrivateExtras: RPCLupineExtras,
      Lupine: LupineRuntime, Atom, PrincOpsUtils, Rope
  EXPORTS LarkRpcControl
  SHARES  Lark, LarkRpcControl, Rope
  = BEGIN OPEN Lark, RpcControl: LarkRpcControl, 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↑ ← [clientStubReset: clientStubReset, clientStubSpecifyTones:
            clientStubSpecifyTones, clientStubFeep: clientStubFeep, clientStubCommands:
            clientStubCommands, clientStubConnect: clientStubConnect, clientStubDisconnect:
            clientStubDisconnect, clientStubPleaseRegister: clientStubPleaseRegister,
            clientStubWhatIsStatus: clientStubWhatIsStatus, clientStubWhatAreConnections:
            clientStubWhatAreConnections, clientStubWhatAreTones: clientStubWhatAreTones,
            clientStubSetKeyTable: clientStubSetKeyTable, clientStubCommandString:
            clientStubCommandString, clientStubPleaseLogin: clientStubPleaseLogin,
            clientStubEchoSupression: clientStubEchoSupression, clientStubSetHostNumber:
            clientStubSetHostNumber];
    interface.myInterface ← RpcPrivateExtras.ImportInterfaceWithHost
        [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "Lark~111#243#11006740257",
        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.

  clientStubReset: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shh: SHHH, rName: ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Reset];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+35]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+35];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: shh];
      argPkt.transferIndex ← Reset;
      BEGIN  -- Marshal rName: ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[rName, pkt, pktLength, TRUE];
        END;  -- Marshal rName.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 0, signalHandler: ClientDispatcher];
      Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+35];
      RETURN[];
      END;  -- UNWIND.
    END;  -- Reset.

  clientStubSpecifyTones: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shh: SHHH, queueIt: BOOLEAN, tones: ToneSpec]
    RETURNS [ok: BOOLEAN] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SpecifyTones, queueIt
        (1): BOOLEAN];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        ok (0): BOOLEAN];
    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 ← 2;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: shh];
      argPkt↑ ← [queueIt: queueIt];
      BEGIN  -- Marshal tones: ToneSpec to pkt.data[pktLength].
        pktLength ← MarshalToneSpec[tones, pkt, pktLength];
        END;  -- Marshal tones.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 1, signalHandler: ClientDispatcher];
      [ok: ok] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[ok];
      END;  -- UNWIND.
    END;  -- SpecifyTones.

  clientStubFeep: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      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];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+42]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 6;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+42];
      RpcPrivate.StartCall[callPkt: pkt, interface: 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];
      [ok: ok] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+42];
      RETURN[ok];
      END;  -- UNWIND.
    END;  -- Feep.

  clientStubCommands: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shh: SHHH, events: CommandEvents] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Commands];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+37]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+37];
      RpcPrivate.StartCall[callPkt: pkt, interface: 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];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+37];
      RETURN[];
      END;  -- UNWIND.
    END;  -- Commands.

  clientStubConnect: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

  clientStubDisconnect: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

  clientStubPleaseRegister: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

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

  clientStubWhatAreConnections: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shh: SHHH, which: CARDINAL] RETURNS [next: CARDINAL, specs: ConnectionSpec]
      =
    TRUSTED BEGIN
    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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
        localConversation: shh];
    argPkt↑ ← [which: which];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 13, signalHandler: ClientDispatcher];
    pktLength ← 1;
    [next: next] ← resPkt↑;
    BEGIN  -- Unmarshal specs: ConnectionSpec from pkt.data[pktLength].
      [specs, pktLength] ← UnmarshalConnectionSpec[interface, pkt,
          pktLength];
      END;  -- Unmarshal specs.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    RETURN[next, specs];
    END;  -- WhatAreConnections.

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

  clientStubSetKeyTable: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shh: SHHH, table: KeyTable] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetKeyTable];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+73]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+73];
      RpcPrivate.StartCall[callPkt: pkt, interface: 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];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+73];
      RETURN[];
      END;  -- UNWIND.
    END;  -- SetKeyTable.

  clientStubCommandString: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shh: SHHH, device: Device, commands: Rope.ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← CommandString, device
        (1): Device];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: shh];
      argPkt↑ ← [device: device];
      BEGIN  -- Marshal commands: Rope.ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[commands, pkt, pktLength, FALSE];
        END;  -- Marshal commands.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 0, signalHandler: ClientDispatcher];
      Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[];
      END;  -- UNWIND.
    END;  -- CommandString.

  clientStubPleaseLogin: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
        localConversation: shh];
    argPkt.transferIndex ← PleaseLogin;
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    [will: will] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[will];
    END;  -- PleaseLogin.

  clientStubEchoSupression: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

  clientStubSetHostNumber: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.
MarshalToneSpec: PROC[value: Lark.ToneSpec, pkt: RpcPrivate.RPCPkt,
    pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  IF pktLength+1 > RpcPrivate.maxDataLength
    THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
  pkt.data[pktLength] ← value=NIL;  pktLength ← pktLength+1;
  IF value # NIL THEN
    BEGIN  -- Marshal value↑: Lark.ToneSpecRec to pkt.data[pktLength].
      pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: LOOPHOLE[value], dataLength: SIZE[Lark.ToneSpecRec],
          alwaysOnePkt: FALSE];
      BEGIN OPEN record: value↑;
      BEGIN  -- Marshal record.tones: LIST OF Lark.Tone to pkt.data[pktLength].
        thisNode3: LIST OF Lark.Tone;
        listLength: Lupine.ListHeader ← 0;
        FOR thisNode3 ← record.tones, thisNode3.rest UNTIL thisNode3
            = NIL DO
          listLength ← listLength + 1;  ENDLOOP;
        IF pktLength+2 > RpcPrivate.maxDataLength
          THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength:
              pktLength];
        Lupine.RpcPktDoubleWord[pkt, pktLength]↑ ← listLength;
        pktLength ← pktLength + 2;
        FOR thisNode3 ← record.tones, thisNode3.rest UNTIL thisNode3
            = NIL DO
          BEGIN  -- Marshal thisNode3.first: Lark.Tone to pkt.data[pktLength].
            pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
                dataAdr: @thisNode3.first, dataLength: SIZE[Lark.Tone],
                alwaysOnePkt: FALSE];
            END;  -- Marshal thisNode3.first.
          ENDLOOP;  -- FOR thisNode3.
        END;  -- Marshal record.tones.
      END;  -- OPEN record: value↑.
      END;  -- Marshal value↑.
  };END;

MarshalConnectionSpec: PROC[value: Lark.ConnectionSpec, 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↑: 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;

UnmarshalConnectionSpec: PROC[interface: RpcControl.InterfaceRecord,
    pkt: RpcPrivate.RPCPkt, 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 ← (interface.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;

MarshalEchoParameters: PROC[value: Lark.EchoParameters, 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↑: 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;

MarshalCommandEvents: PROC[value: Lark.CommandEvents, pkt: RpcPrivate.RPCPkt,
    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.RpcPktDoubleWord[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;

UnmarshalStatusEvents: PROC[interface: RpcControl.InterfaceRecord,
    pkt: RpcPrivate.RPCPkt, 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.RpcPktDoubleWord[pkt, pktLength]↑;
        pktLength ← pktLength + 2;
        value ← (interface.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;

MarshalKeyTable: PROC[value: Lark.KeyTable, pkt: RpcPrivate.RPCPkt,
    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.RpcPktDoubleWord[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;



-- No module initialization.

END.  -- LarkRpcClientImpl.