-- Copyright (C) 1986 by Xerox Corporation.  All rights reserved.
-- Stub file  was translated on June 2, 1986 8:35:04 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 [InterMdsCallsOnly, LupineProtocolVersion,
      ProcedureIndex, SignalIndex],
  RPC USING [EncryptionKey, InterfaceName, Principal, standardZones,
      Zones],
  RPCLupine --USING SOME OF [Call, DataLength, Dispatcher, ExportHandle,
      -- ExportInterface, GetStubPkt, maxDataLength, maxPrincipalLength,
      -- maxShortStringLength, pktOverhead, ReceiveExtraPkt, SendPrelimPkt,
      -- StartCall, StartSignal, StubPkt, UnexportInterface]--,
  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]--;


LarkOpsRpcServerImpl: MONITOR
  IMPORTS LarkOps, RpcPrivate: RPCLupine, Lupine: LupineRuntime, Atom,
      Rope
  EXPORTS LarkOpsRpcControl
  SHARES  LarkOps, LarkOpsRpcControl, Rope
  = BEGIN OPEN LarkOps, RpcControl: LarkOpsRpcControl, RpcPublic: RPC;


-- Standard remote binding routines.

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

  ExportInterface: PUBLIC ENTRY SAFE PROCEDURE [
        interfaceName: RpcPublic.InterfaceName,
        user: RpcPublic.Principal,
        password: RpcPublic.EncryptionKey,
        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.ExportInterface [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "LarkOps~4#302#31434071145",
        instance: interfaceName.instance,
        version: interfaceName.version ],
      user: user,  password: password,
      dispatcher: ServerDispatcher,
      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;

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


-- Public procedure dispatcher and public signal and error catcher.

  ServerDispatcher: --PROCEDURE [pkt: RPCPkt, callLength: DataLength,
      -- lastPkt: BOOLEAN, localConversation: Conversation] RETURNS [returnLength:
      -- DataLength]-- RpcPrivate.Dispatcher =
    BEGIN

    -- Catch public signals.

      ENABLE BEGIN

      END;  -- Catch public signals.


    -- Call public procedures (still in dispatcher).

    SELECT LOOPHOLE[pkt.data[0], RpcControl.ProcedureIndex] FROM
      Reset => RETURN[
        ResetStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      SpecifyTones => RETURN[
        SpecifyTonesStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      Feep => RETURN[
        FeepStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      Commands => RETURN[
        CommandsStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      Connect => RETURN[
        ConnectStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      Disconnect => RETURN[
        DisconnectStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      PleaseRegister => RETURN[
        PleaseRegisterStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      WhatIsStatus => RETURN[
        WhatIsStatusStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      WhatAreConnections => RETURN[
        WhatAreConnectionsStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      WhatAreTones => RETURN[
        WhatAreTonesStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      SetKeyTable => RETURN[
        SetKeyTableStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      CommandString => RETURN[
        CommandStringStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      PleaseLogin => RETURN[
        PleaseLoginStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      EchoSupression => RETURN[
        EchoSupressionStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      SetHostNumber => RETURN[
        SetHostNumberStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      SetParameters => RETURN[
        SetParametersStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      ENDCASE => RETURN[Lupine.DispatchingError[]];

    END;  -- ServerDispatcher


-- Public procedure dispatcher stubs.

  ResetStub: --PROCEDURE [shh: Lark.SHHH, rName: Lark.ROPE]-- RpcPrivate.Dispatcher
      =
    INLINE BEGIN
    rName: Lark.ROPE;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal rName: Lark.ROPE from pkt.data[pktLength].
      [rName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength, TRUE];
      END;  -- Unmarshal rName.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    Reset[localConversation, rName];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- ResetStub.

  SpecifyTonesStub: --PROCEDURE [shh: Lark.SHHH, queueIt: BOOLEAN,
      -- tones: Lark.ToneSpec]
    -- RETURNS [ok: BOOLEAN]-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    queueIt: BOOLEAN;
    tones: Lark.ToneSpec;
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, queueIt (1): BOOLEAN];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        ok (0): BOOLEAN];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay;
    pktLength: RpcPrivate.DataLength ← 2;
    BEGIN  -- OnePkt.
    onePkt: BOOLEAN = lastPkt;
    IF ~onePkt THEN BEGIN  -- Must move statics from pkt now.
      [queueIt: queueIt] ← argPkt↑;
      END;
    BEGIN  -- Unmarshal tones: Lark.ToneSpec from pkt.data[pktLength].
      [tones, pktLength] ← UnmarshalLarkDotToneSpec[pkt, pktLength];
      END;  -- Unmarshal tones.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    resPkt ← @pkt.data[0];
    IF onePkt
      THEN [resPkt.ok] ← SpecifyTones[localConversation, argPkt.queueIt,
          tones]
      ELSE [resPkt.ok] ← SpecifyTones[localConversation, queueIt, tones];
    END;  -- OnePkt.
    pktLength ← 1;
    RETURN[returnLength: pktLength];
    END;  -- SpecifyTonesStub.

  FeepStub: --PROCEDURE [shh: Lark.SHHH, on: Lark.Milliseconds, off:
      -- Lark.Milliseconds, waveTable: CARDINAL, queueIt: BOOLEAN, notify:
      -- Lark.CommandEvent, events: Lark.CommandEvents]
    -- RETURNS [ok: BOOLEAN]-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    events: Lark.CommandEvents;
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, 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];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 6;
    BEGIN  -- Unmarshal events: Lark.CommandEvents from pkt.data[pktLength].
      [events, pktLength] ← UnmarshalLarkDotCommandEvents[pkt, pktLength];
      END;  -- Unmarshal events.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    [resPkt.ok] ← Feep[localConversation, argPkt.on, argPkt.off, argPkt.waveTable,
        argPkt.queueIt, argPkt.notify, events];
    pktLength ← 1;
    RETURN[returnLength: pktLength];
    END;  -- FeepStub.

  CommandsStub: --PROCEDURE [shh: Lark.SHHH, events: Lark.CommandEvents]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    events: Lark.CommandEvents;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal events: Lark.CommandEvents from pkt.data[pktLength].
      [events, pktLength] ← UnmarshalLarkDotCommandEvents[pkt, pktLength];
      END;  -- Unmarshal events.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    Commands[localConversation, events];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- CommandsStub.

  ConnectStub: --PROCEDURE [shh: Lark.SHHH, specs: Lark.ConnectionSpec]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    specs: Lark.ConnectionSpec;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal specs: Lark.ConnectionSpec from pkt.data[pktLength].
      [specs, pktLength] ← UnmarshalLarkDotConnectionSpec[pkt, pktLength];
      END;  -- Unmarshal specs.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    Connect[localConversation, specs];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- ConnectStub.

  DisconnectStub: --PROCEDURE [shh: Lark.SHHH, buffer: Lark.VoiceBuffer]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, buffer (1): Lark.VoiceBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    Disconnect[localConversation, argPkt.buffer];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- DisconnectStub.

  PleaseRegisterStub: --PROCEDURE [shh: Lark.SHHH]-- RpcPrivate.Dispatcher
      =
    INLINE BEGIN
    pktLength: RpcPrivate.DataLength ← 1;
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    PleaseRegister[localConversation];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- PleaseRegisterStub.

  WhatIsStatusStub: --PROCEDURE [shh: Lark.SHHH, which: CARDINAL] RETURNS
      -- [next: CARDINAL, events: Lark.StatusEvents]-- RpcPrivate.Dispatcher
      =
    INLINE BEGIN
    events: Lark.StatusEvents;
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, which (1): CARDINAL];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        next (0): CARDINAL];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    [resPkt.next, events] ←
      WhatIsStatus[localConversation, argPkt.which];
    pktLength ← 1;
    BEGIN  -- Marshal events: Lark.StatusEvents to pkt.data[pktLength].
      pktLength ← MarshalLarkDotStatusEvents[events, pkt, pktLength];
      END;  -- Marshal events.
    RETURN[returnLength: pktLength];
    END;  -- WhatIsStatusStub.

  WhatAreConnectionsStub: --PROCEDURE [shh: Lark.SHHH, which: CARDINAL]
      -- RETURNS [next: CARDINAL, specs: Lark.ConnectionSpec]-- RpcPrivate.Dispatcher
      =
    INLINE BEGIN
    specs: Lark.ConnectionSpec;
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, which (1): CARDINAL];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        next (0): CARDINAL];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    [resPkt.next, specs] ←
      WhatAreConnections[localConversation, argPkt.which];
    pktLength ← 1;
    BEGIN  -- Marshal specs: Lark.ConnectionSpec to pkt.data[pktLength].
      pktLength ← MarshalLarkDotConnectionSpec[specs, pkt, pktLength];
      END;  -- Marshal specs.
    RETURN[returnLength: pktLength];
    END;  -- WhatAreConnectionsStub.

  WhatAreTonesStub: --PROCEDURE [shh: Lark.SHHH] RETURNS [anonP1id4136388:
      -- BOOLEAN]-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        anonP1id4136388 (0): BOOLEAN];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    [resPkt.anonP1id4136388] ← WhatAreTones[localConversation];
    pktLength ← 1;
    RETURN[returnLength: pktLength];
    END;  -- WhatAreTonesStub.

  SetKeyTableStub: --PROCEDURE [shh: Lark.SHHH, table: Lark.KeyTable]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    table: Lark.KeyTable;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal table: Lark.KeyTable from pkt.data[pktLength].
      [table, pktLength] ← UnmarshalLarkDotKeyTable[pkt, pktLength];
      END;  -- Unmarshal table.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    SetKeyTable[localConversation, table];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- SetKeyTableStub.

  CommandStringStub: --PROCEDURE [shh: Lark.SHHH, device: Lark.Device,
      -- commands: Rope.ROPE]-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    device: Lark.Device;
    commands: Rope.ROPE;
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, device (1): Lark.Device];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    BEGIN  -- OnePkt.
    onePkt: BOOLEAN = lastPkt;
    IF ~onePkt THEN BEGIN  -- Must move statics from pkt now.
      [device: device] ← argPkt↑;
      END;
    BEGIN  -- Unmarshal commands: Rope.ROPE from pkt.data[pktLength].
      [commands, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          FALSE];
      END;  -- Unmarshal commands.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    IF onePkt
      THEN CommandString[localConversation, argPkt.device, commands]
      ELSE CommandString[localConversation, device, commands];
    END;  -- OnePkt.
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- CommandStringStub.

  PleaseLoginStub: --PROCEDURE [shh: Lark.SHHH] RETURNS [will: BOOL]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        will (0): BOOL];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    [resPkt.will] ← PleaseLogin[localConversation];
    pktLength ← 1;
    RETURN[returnLength: pktLength];
    END;  -- PleaseLoginStub.

  EchoSupressionStub: --PROCEDURE [shh: Lark.SHHH, echo: Lark.EchoParameters]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    echo: Lark.EchoParameters;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal echo: Lark.EchoParameters from pkt.data[pktLength].
      [echo, pktLength] ← UnmarshalLarkDotEchoParameters[pkt, pktLength];
      END;  -- Unmarshal echo.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    EchoSupression[localConversation, echo];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- EchoSupressionStub.

  SetHostNumberStub: --PROCEDURE [shh: Lark.SHHH, host: Lark.Machine]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex, host (1): Lark.Machine];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    SetHostNumber[localConversation, argPkt.host];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- SetHostNumberStub.

  SetParametersStub: --PROCEDURE [shh: Lark.SHHH, parameters: LarkParameters]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    parameters: LarkParameters;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal parameters: LarkParameters from pkt.data[pktLength].
      [parameters, pktLength] ← UnmarshalLarkParameters[pkt, pktLength];
      END;  -- Unmarshal parameters.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    SetParameters[localConversation, parameters];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- SetParametersStub.


-- Marshall/Unmarshal procedures.
MarshalLarkDotStatusEvents: PROC[value: Lark.StatusEvents, pkt: RpcPrivate.RPCPkt,
    pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  BEGIN  -- Marshal value↑: Lark.StatusEventSequence 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.StatusEventSequence[LENGTH[DESCRIPTOR[value↑]]]],
          alwaysOnePkt: TRUE];
      END;  -- IF value # NIL.
    END;  -- Marshal value↑.
  };END;

UnmarshalLarkParameters: PROC[pkt: RpcPrivate.RPCPkt, pktLength0: RpcPrivate.DataLength]
  RETURNS[value: LarkOps.LarkParameters, pktLength: RpcPrivate.DataLength]
      = BEGIN
  pktLength ← pktLength0; {
  BEGIN  -- Unmarshal value↑: LarkOps.LarkParametersRec from pkt.data[pktLength].
    recordIsNIL: Lupine.NilHeader;
    IF pktLength+3 > RpcPrivate.maxDataLength
      THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
    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 ← (paramZones.gc.NEW[LarkOps.LarkParametersRec[Lupine.SHORT[seqLength]]]);
        pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
            dataAdr: LOOPHOLE[value], dataLength: SIZE[LarkOps.LarkParametersRec[LENGTH[DESCRIPTOR[value↑]]]],
            alwaysOnePkt: FALSE];
        END;  -- IF recordIsNIL.
    END;  -- Unmarshal 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[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 ← (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;

UnmarshalLarkDotCommandEvents: PROC[pkt: RpcPrivate.RPCPkt, pktLength0:
    RpcPrivate.DataLength]
  RETURNS[value: Lark.CommandEvents, pktLength: RpcPrivate.DataLength]
      = BEGIN
  pktLength ← pktLength0; {
  BEGIN  -- Unmarshal value↑: Lark.CommandEventSequence 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 ← (paramZones.gc.NEW[Lark.CommandEventSequence[Lupine.SHORT[seqLength]]]);
        pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
            dataAdr: LOOPHOLE[value], dataLength: SIZE[Lark.CommandEventSequence[LENGTH[DESCRIPTOR[value↑]]]],
            alwaysOnePkt: TRUE];
        END;  -- IF recordIsNIL.
    END;  -- Unmarshal value↑.
  };END;

UnmarshalLarkDotToneSpec: PROC[pkt: RpcPrivate.RPCPkt, pktLength0:
    RpcPrivate.DataLength]
  RETURNS[value: Lark.ToneSpec, pktLength: RpcPrivate.DataLength] =
      BEGIN
  pktLength ← pktLength0; {
  isNIL: Lupine.NilHeader;
  IF pktLength+1 > RpcPrivate.maxDataLength
    THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
  isNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
  IF isNIL
    THEN value ← NIL
    ELSE BEGIN
      value ← (paramZones.gc.NEW[Lark.ToneSpecRec]);
      BEGIN  -- Unmarshal value↑: Lark.ToneSpecRec from pkt.data[pktLength].
        pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
            dataAdr: LOOPHOLE[value], dataLength: SIZE[Lark.ToneSpecRec],
            alwaysOnePkt: FALSE];
        -- Restore garbled REFs to NIL following copy.
        BEGIN OPEN record: value↑;
        LOOPHOLE[record.tones, LONG POINTER] ← NIL;
        END;  -- OPEN record: value↑.
        BEGIN OPEN record: value↑;
        BEGIN  -- Unmarshal record.tones: LIST OF Lark.Tone from pkt.data[pktLength].
          lastNode: LIST OF Lark.Tone ← (record.tones ← NIL);
          listLength: Lupine.ListHeader;
          IF pktLength+2 > RpcPrivate.maxDataLength
            THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength:
                pktLength];
          listLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑;
          pktLength ← pktLength + 2;
          WHILE listLength > 0 DO
            thisNode3: LIST OF Lark.Tone = paramZones.gc.CONS[--DefaultValue--,NIL];
            BEGIN  -- Unmarshal thisNode3.first: Lark.Tone from pkt.data[pktLength].
              pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
                  dataAdr: @thisNode3.first, dataLength: SIZE[Lark.Tone],
                  alwaysOnePkt: FALSE];
              END;  -- Unmarshal thisNode3.first.
            IF lastNode # NIL
              THEN lastNode ← (lastNode.rest ← thisNode3)
              ELSE lastNode ← (record.tones ← thisNode3);
            listLength ← listLength - 1;
            ENDLOOP;  -- WHILE listLength > 0.
          END;  -- Unmarshal record.tones.
        END;  -- OPEN record: value↑.
        END;  -- Unmarshal value↑.
      END;  -- IF isNIL.
  };END;

UnmarshalLarkDotEchoParameters: PROC[pkt: RpcPrivate.RPCPkt, pktLength0:
    RpcPrivate.DataLength]
  RETURNS[value: Lark.EchoParameters, 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.EchoParameterRecord]);
      BEGIN  -- Unmarshal value↑: Lark.EchoParameterRecord from pkt.data[pktLength].
        pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
            dataAdr: LOOPHOLE[value], dataLength: SIZE[Lark.EchoParameterRecord],
            alwaysOnePkt: TRUE];
        END;  -- Unmarshal value↑.
      END;  -- IF isNIL.
  };END;

UnmarshalLarkDotKeyTable: PROC[pkt: RpcPrivate.RPCPkt, pktLength0:
    RpcPrivate.DataLength]
  RETURNS[value: Lark.KeyTable, pktLength: RpcPrivate.DataLength] =
      BEGIN
  pktLength ← pktLength0; {
  BEGIN  -- Unmarshal value↑: IV.KeyTableBody 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 ← (paramZones.gc.NEW[IV.KeyTableBody[Lupine.SHORT[seqLength]]]);
        pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
            dataAdr: LOOPHOLE[value], dataLength: SIZE[IV.KeyTableBody[LENGTH[DESCRIPTOR[value↑]]]],
            alwaysOnePkt: TRUE];
        END;  -- IF recordIsNIL.
    END;  -- Unmarshal value↑.
  };END;



-- No module initialization.

END.  -- LarkOpsRpcServerImpl.