-- Copyright (C) 1986 by Xerox Corporation.  All rights reserved.
-- Stub file  was translated on June 2, 1986 8:34:58 am PDT by Lupine of February 22, 1986 5:15:54 pm PST
-- Source interface LarkOps came from file LarkOps.bcd, which was created on June 2, 1986 8:34:52 am PDT with version stamp 4#302#31434071145 from source of June 2, 1986 8:34:44 am PDT.

-- The RPC stub modules for LarkOps are:
--   LarkOpsRpcControl.mesa;
--   LarkOpsRpcClientImpl.mesa;
--   LarkOpsRpcBinderImpl.mesa;
--   LarkOpsRpcServerImpl.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
  IV,
  Rope,
  Lark,
  LarkOps,
  LarkOpsRpcControl 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]--,
  VM --USING SOME OF [AddressForPageNumber, PageCount, PageNumber,
      -- PageNumberForAddress, PagesForWords]--;


LarkOpsRpcClientImpl: MONITOR
  IMPORTS RpcPrivate: RPCLupine, RpcPrivateExtras: RPCLupineExtras,
      Lupine: LupineRuntime, Atom, PrincOpsUtils, Rope
  EXPORTS LarkOpsRpcControl
  SHARES  LarkOps, LarkOpsRpcControl, Rope
  = BEGIN OPEN LarkOps, RpcControl: LarkOpsRpcControl, 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, clientStubSetParameters: clientStubSetParameters];
    interface.myInterface ← RpcPrivateExtras.ImportInterfaceWithHost
        [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "LarkOps~4#302#31434071145",
        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: Lark.SHHH, rName: Lark.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: Lark.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: Lark.SHHH, queueIt: BOOLEAN, tones: Lark.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: Lark.ToneSpec to pkt.data[pktLength].
        pktLength ← MarshalLarkDotToneSpec[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: Lark.SHHH, on: Lark.Milliseconds, off: Lark.Milliseconds, waveTable:
      CARDINAL, queueIt: BOOLEAN, notify: Lark.CommandEvent, events: Lark.CommandEvents]
    RETURNS [ok: BOOLEAN] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Feep, on (1): Lark.Milliseconds,
        off (2): Lark.Milliseconds, waveTable (3): CARDINAL, queueIt (4):
        BOOLEAN, notify (5): Lark.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: Lark.CommandEvents to pkt.data[pktLength].
        pktLength ← MarshalLarkDotCommandEvents[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: Lark.SHHH, events: Lark.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: Lark.CommandEvents to pkt.data[pktLength].
        pktLength ← MarshalLarkDotCommandEvents[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: Lark.SHHH, specs: Lark.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: Lark.ConnectionSpec to pkt.data[pktLength].
      pktLength ← MarshalLarkDotConnectionSpec[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: Lark.SHHH, buffer: Lark.VoiceBuffer] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Disconnect, buffer
        (1): Lark.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: Lark.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: Lark.SHHH, which: CARDINAL] RETURNS [next: CARDINAL, events:
      Lark.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: Lark.StatusEvents from pkt.data[pktLength].
        [events, pktLength] ← UnmarshalLarkDotStatusEvents[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: Lark.SHHH, which: CARDINAL] RETURNS [next: CARDINAL, specs:
      Lark.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: Lark.ConnectionSpec from pkt.data[pktLength].
      [specs, pktLength] ← UnmarshalLarkDotConnectionSpec[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: Lark.SHHH] RETURNS [anonP1id4136388: BOOLEAN] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← WhatAreTones];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        anonP1id4136388 (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];
    [anonP1id4136388: anonP1id4136388] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[anonP1id4136388];
    END;  -- WhatAreTones.

  clientStubSetKeyTable: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shh: Lark.SHHH, table: Lark.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: Lark.KeyTable to pkt.data[pktLength].
        pktLength ← MarshalLarkDotKeyTable[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: Lark.SHHH, device: Lark.Device, commands: Rope.ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← CommandString, device
        (1): Lark.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: Lark.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: Lark.SHHH, echo: Lark.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: Lark.EchoParameters to pkt.data[pktLength].
      pktLength ← MarshalLarkDotEchoParameters[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: Lark.SHHH, host: Lark.Machine] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetHostNumber, host
        (1): Lark.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.

  clientStubSetParameters: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      shh: Lark.SHHH, parameters: LarkParameters] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetParameters];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: shh];
      argPkt.transferIndex ← SetParameters;
      BEGIN  -- Marshal parameters: LarkParameters to pkt.data[pktLength].
        pktLength ← MarshalLarkParameters[parameters, pkt, pktLength];
        END;  -- Marshal parameters.
      [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;  -- SetParameters.


-- 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.
MarshalLarkDotToneSpec: 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;

MarshalLarkDotConnectionSpec: 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;

UnmarshalLarkDotConnectionSpec: 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;

MarshalLarkDotKeyTable: PROC[value: Lark.KeyTable, pkt: RpcPrivate.RPCPkt,
    pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  BEGIN  -- Marshal value↑: IV.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[IV.KeyTableBody[LENGTH[DESCRIPTOR[value↑]]]],
          alwaysOnePkt: TRUE];
      END;  -- IF value # NIL.
    END;  -- Marshal value↑.
  };END;

MarshalLarkParameters: PROC[value: LarkOps.LarkParameters, pkt: RpcPrivate.RPCPkt,
    pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  BEGIN  -- Marshal value↑: LarkOps.LarkParametersRec to pkt.data[pktLength].
    IF pktLength+3 > RpcPrivate.maxDataLength
      THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: 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[LarkOps.LarkParametersRec[LENGTH[DESCRIPTOR[value↑]]]],
          alwaysOnePkt: FALSE];
      END;  -- IF value # NIL.
    END;  -- Marshal value↑.
  };END;

UnmarshalLarkDotStatusEvents: 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;

MarshalLarkDotCommandEvents: 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;

MarshalLarkDotEchoParameters: 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;



-- No module initialization.

END.  -- LarkOpsRpcClientImpl.