-- RapunzelDescription.mesa
-- Demo	 9-Jan-87 14:02:33 PST

DIRECTORY Courier, RapunzelCourier, Rapunzel;

RapunzelDescription: PROGRAM
  EXPORTS RapunzelCourier = PUBLIC {

  DescribeShort: Courier.Description = {
    p: LONG POINTER TO Rapunzel.Short = notes.noteSize[
      SIZE[Rapunzel.Short]];
    };

  DescribeLong: Courier.Description = {
    p: LONG POINTER TO Rapunzel.Long = notes.noteSize[
      SIZE[Rapunzel.Long]];
    notes.noteLongCardinal[p];
    };

  DescribeSeqShort: Courier.Description = {
    p: LONG POINTER TO Rapunzel.SeqShort = notes.noteSize[
      SIZE[Rapunzel.SeqShort]];
    notes.noteArrayDescriptor[p, SIZE[Rapunzel.Short], CARDINAL.LAST];
    FOR i:Rapunzel.SeqShortIndex IN [0..LENGTH[p↑]) DO 
      notes.noteParameters[@p[i], DescribeShort];
      ENDLOOP;
    };

  DescribeAddress: Courier.Description = {
    p: LONG POINTER TO Rapunzel.Address = notes.noteSize[
      SIZE[Rapunzel.Address]];
    notes.noteLongCardinal[p];
    };

  DescribePeekShortCmd: Courier.Description = {
    p: LONG POINTER TO Rapunzel.PeekShortCmd = notes.noteSize[
      SIZE[Rapunzel.PeekShortCmd]];
    notes.noteParameters[@p.address, DescribeAddress];
    };

  DescribePokeShortCmd: Courier.Description = {
    p: LONG POINTER TO Rapunzel.PokeShortCmd = notes.noteSize[
      SIZE[Rapunzel.PokeShortCmd]];
    notes.noteParameters[@p.address, DescribeAddress];
    notes.noteParameters[@p.value, DescribeShort];
    };

  DescribeShftReadCmd: Courier.Description = {
    p: LONG POINTER TO Rapunzel.ShftReadCmd = notes.noteSize[
      SIZE[Rapunzel.ShftReadCmd]];
    notes.noteParameters[@p.address, DescribeAddress];
    notes.noteParameters[@p.numRepeats, DescribeShort];
    };

  DescribeShftWriteCmd: Courier.Description = {
    p: LONG POINTER TO Rapunzel.ShftWriteCmd = notes.noteSize[
      SIZE[Rapunzel.ShftWriteCmd]];
    notes.noteParameters[@p.address, DescribeAddress];
    notes.noteParameters[@p.numRepeats, DescribeShort];
    };

  DescribeReturnLengthCmd: Courier.Description = {
    p: LONG POINTER TO Rapunzel.ReturnLengthCmd = notes.noteSize[
      SIZE[Rapunzel.ReturnLengthCmd]];
    notes.noteParameters[@p.returnLength, DescribeShort];
    };

  DescribeOpCode: Courier.Description = {
    p: LONG POINTER TO Rapunzel.OpCode = notes.noteSize[
      SIZE[Rapunzel.OpCode]];
    };

  DescribeCmd: Courier.Description = {
    p: LONG POINTER TO Rapunzel.Cmd = notes.noteSize[
      SIZE[Rapunzel.Cmd]];
    sizes: ARRAY [0..5) OF CARDINAL ← [
      SIZE[Rapunzel.PeekShortCmd] + 1, SIZE[Rapunzel.PokeShortCmd] + 1, SIZE[Rapunzel.ShftReadCmd] + 1, SIZE[Rapunzel.ShftWriteCmd] + 1, SIZE[Rapunzel.ReturnLengthCmd] + 1];
    notes.noteChoice[p, SIZE[Rapunzel.Cmd], LONG[DESCRIPTOR[sizes]]];
    WITH variant: p↑ SELECT FROM
      peekShort =>     notes.noteParameters[@variant.peekShort, DescribePeekShortCmd];
      pokeShort =>     notes.noteParameters[@variant.pokeShort, DescribePokeShortCmd];
      shftRead =>     notes.noteParameters[@variant.shftRead, DescribeShftReadCmd];
      shftWrite =>     notes.noteParameters[@variant.shftWrite, DescribeShftWriteCmd];
      returnLength =>     notes.noteParameters[@variant.returnLength, DescribeReturnLengthCmd];
      ENDCASE;
    };

  DescribeSeqCmd: Courier.Description = {
    p: LONG POINTER TO Rapunzel.SeqCmd = notes.noteSize[
      SIZE[Rapunzel.SeqCmd]];
    notes.noteArrayDescriptor[p, SIZE[Rapunzel.Cmd], CARDINAL.LAST];
    FOR i:Rapunzel.SeqCmdIndex IN [0..LENGTH[p↑]) DO 
      notes.noteParameters[@p[i], DescribeCmd];
      ENDLOOP;
    };

  DescribePeekShortResult: Courier.Description = {
    p: LONG POINTER TO Rapunzel.PeekShortResult = notes.noteSize[
      SIZE[Rapunzel.PeekShortResult]];
    notes.noteParameters[@p.value, DescribeShort];
    };

  DescribePokeShortResult: Courier.Description = {
    p: LONG POINTER TO Rapunzel.PokeShortResult = notes.noteSize[
      SIZE[Rapunzel.PokeShortResult]];
    };

  DescribeShftReadResult: Courier.Description = {
    p: LONG POINTER TO Rapunzel.ShftReadResult = notes.noteSize[
      SIZE[Rapunzel.ShftReadResult]];
    notes.noteParameters[@p.numRepeats, DescribeShort];
    };

  DescribeShftWriteResult: Courier.Description = {
    p: LONG POINTER TO Rapunzel.ShftWriteResult = notes.noteSize[
      SIZE[Rapunzel.ShftWriteResult]];
    notes.noteParameters[@p.numRepeats, DescribeShort];
    };

  DescribeReturnLengthResult: Courier.Description = {
    p: LONG POINTER TO Rapunzel.ReturnLengthResult = notes.noteSize[
      SIZE[Rapunzel.ReturnLengthResult]];
    };

  DescribeResult: Courier.Description = {
    p: LONG POINTER TO Rapunzel.Result = notes.noteSize[
      SIZE[Rapunzel.Result]];
    sizes: ARRAY [0..5) OF CARDINAL ← [
      SIZE[Rapunzel.PeekShortResult] + 1, SIZE[Rapunzel.PokeShortResult] + 1, SIZE[Rapunzel.ShftReadResult] + 1, SIZE[Rapunzel.ShftWriteResult] + 1, SIZE[Rapunzel.ReturnLengthResult] + 1];
    notes.noteChoice[p, SIZE[Rapunzel.Result], LONG[DESCRIPTOR[sizes]]];
    WITH variant: p↑ SELECT FROM
      peekShort =>     notes.noteParameters[@variant.peekShort, DescribePeekShortResult];
      pokeShort =>     notes.noteParameters[@variant.pokeShort, NIL];
      shftRead =>     notes.noteParameters[@variant.shftRead, DescribeShftReadResult];
      shftWrite =>     notes.noteParameters[@variant.shftWrite, DescribeShftWriteResult];
      returnLength =>     notes.noteParameters[@variant.returnLength, NIL];
      ENDCASE;
    };

  DescribeSeqResult: Courier.Description = {
    p: LONG POINTER TO Rapunzel.SeqResult = notes.noteSize[
      SIZE[Rapunzel.SeqResult]];
    notes.noteArrayDescriptor[p, SIZE[Rapunzel.Result], CARDINAL.LAST];
    FOR i:Rapunzel.SeqResultIndex IN [0..LENGTH[p↑]) DO 
      notes.noteParameters[@p[i], DescribeResult];
      ENDLOOP;
    };

  DescribeFaultArgs: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.FaultArgs = notes.noteSize[
      SIZE[RapunzelCourier.FaultArgs]];
    notes.noteParameters[@p.code, DescribeFaultCode];
    notes.noteParameters[@p.address, DescribeAddress];
    };

  DescribeFaultCode: Courier.Description = {
    p: LONG POINTER TO Rapunzel.FaultCode = notes.noteSize[
      SIZE[Rapunzel.FaultCode]];
    };

  DescribePeekShortArgs: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.PeekShortArgs = notes.noteSize[
      SIZE[RapunzelCourier.PeekShortArgs]];
    notes.noteParameters[@p.address, DescribeAddress];
    };

  DescribePeekShortRes: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.PeekShortRes = notes.noteSize[
      SIZE[RapunzelCourier.PeekShortRes]];
    notes.noteParameters[@p.result, DescribeShort];
    };

  DescribePokeShortArgs: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.PokeShortArgs = notes.noteSize[
      SIZE[RapunzelCourier.PokeShortArgs]];
    notes.noteParameters[@p.address, DescribeAddress];
    notes.noteParameters[@p.value, DescribeShort];
    };

  DescribePeekSeqShortArgs: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.PeekSeqShortArgs = notes.noteSize[
      SIZE[RapunzelCourier.PeekSeqShortArgs]];
    notes.noteParameters[@p.address, DescribeAddress];
    };

  DescribePeekSeqShortRes: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.PeekSeqShortRes = notes.noteSize[
      SIZE[RapunzelCourier.PeekSeqShortRes]];
    notes.noteDisjointData[@p.resultSeq, DescribeSeqShort];
    };

  DescribePokeSeqShortArgs: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.PokeSeqShortArgs = notes.noteSize[
      SIZE[RapunzelCourier.PokeSeqShortArgs]];
    notes.noteParameters[@p.address, DescribeAddress];
    notes.noteDisjointData[@p.valueSeq, DescribeSeqShort];
    };

  DescribePeekLongArgs: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.PeekLongArgs = notes.noteSize[
      SIZE[RapunzelCourier.PeekLongArgs]];
    notes.noteParameters[@p.address, DescribeAddress];
    };

  DescribePeekLongRes: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.PeekLongRes = notes.noteSize[
      SIZE[RapunzelCourier.PeekLongRes]];
    notes.noteParameters[@p.result, DescribeLong];
    };

  DescribePokeLongArgs: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.PokeLongArgs = notes.noteSize[
      SIZE[RapunzelCourier.PokeLongArgs]];
    notes.noteParameters[@p.address, DescribeAddress];
    notes.noteParameters[@p.value, DescribeLong];
    };

  DescribeDoCmdsArgs: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.DoCmdsArgs = notes.noteSize[
      SIZE[RapunzelCourier.DoCmdsArgs]];
    notes.noteDisjointData[@p.cmdSeq, DescribeSeqCmd];
    };

  DescribeDoCmdsRes: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.DoCmdsRes = notes.noteSize[
      SIZE[RapunzelCourier.DoCmdsRes]];
    notes.noteDisjointData[@p.resultSeq, DescribeSeqResult];
    };

  DescribeSetShftAddrsArgs: Courier.Description = {
    p: LONG POINTER TO RapunzelCourier.SetShftAddrsArgs = notes.noteSize[
      SIZE[RapunzelCourier.SetShftAddrsArgs]];
    notes.noteParameters[@p.shftA, DescribeAddress];
    notes.noteParameters[@p.shftB, DescribeAddress];
    };



  }.