mentor/derived/SortIE.m3


 Copyright (C) 1995, Digital Equipment Corporation.       
 All rights reserved.                                     
 See the file COPYRIGHT for a full description.           
                                                          
 Last modified on Thu Feb  9 08:50:48 PST 1995 by kalsow  
      modified on Sun Jun  5 21:59:57 PDT 1994 by mhb     
      modified on Wed Feb 17 16:46:47 PST 1993 by johnh   

********************************************************************

      *  NOTE: This file is generated automatically from the event
      *        definition file Sort.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE SortIE;

<*NOWARN*> IMPORT ZeusClass, Zeus, SortViewClass, Algorithm, Sort;
<*NOWARN*> IMPORT SortAlgClass, View, Thread, AlgorithmClass;

<* FATAL Zeus.Error, Zeus.Locked *>
If you get either of these errors, contact a Zeus implementor.

TYPE
  InitArgs = BRANDED REF RECORD
    N: CARDINAL;
    passes: CARDINAL;
  END;

  SetValArgs = BRANDED REF RECORD
    i: CARDINAL;
    val: Sort.Key;
  END;

  SwapEltsArgs = BRANDED REF RECORD
    i: CARDINAL;
    j: CARDINAL;
  END;

  StartPassArgs = BRANDED REF RECORD
  END;

  UpdateValArgs = BRANDED REF RECORD
    i: CARDINAL;
    val: Sort.Key;
  END;

  ChangeValArgs = BRANDED REF RECORD
    i: CARDINAL;
    new: Sort.Key;
  END;
Zeus calls the following to invoke vbt v's event handler:

<*NOWARN*> PROCEDURE OEDispatcher(v: ZeusClass.T; evt: REFANY) RAISES {Thread.Alerted} =
  <* LL <= VBT.mu *>
  (* LL = {} if event style is output, LL = VBT.mu if event style is update. *)
  BEGIN
    TYPECASE v OF
    | SortViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | InitArgs(varInitArgs) => <*NOWARN*>
          view.oeInit (
              varInitArgs.N
                ,
              varInitArgs.passes
              )
      | SetValArgs(varSetValArgs) => <*NOWARN*>
          view.oeSetVal (
              varSetValArgs.i
                ,
              varSetValArgs.val
              )
      | SwapEltsArgs(varSwapEltsArgs) => <*NOWARN*>
          view.oeSwapElts (
              varSwapEltsArgs.i
                ,
              varSwapEltsArgs.j
              )
      | StartPassArgs(varStartPassArgs) => <*NOWARN*>
          view.oeStartPass (
              )
      | UpdateValArgs(varUpdateValArgs) => <*NOWARN*>
          view.ueUpdateVal (
              varUpdateValArgs.i
                ,
              varUpdateValArgs.val
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a SortViewClass, so just ignore *)
    END
  END OEDispatcher;

<*NOWARN*> PROCEDURE FEDispatcher(v: ZeusClass.T; evt: REFANY) =
  <* LL = VBT.mu *>
  BEGIN
    TYPECASE v OF
    | SortAlgClass.T (alg) => <*NOWARN*>
      TYPECASE evt OF
      | ChangeValArgs(varChangeValArgs) => <*NOWARN*>
          alg.feChangeVal (
              varChangeValArgs.i
                ,
              varChangeValArgs.new
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this alg isn't a SortAlgClass, so just ignore *)
    END
  END FEDispatcher;

PROCEDURE Init (
      initiator: Algorithm.T;
       N: CARDINAL; passes: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(InitArgs
               , N := N
               , passes := passes
      );
      alg := NARROW(initiator, SortAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfInit);
      alg.stopAtEvent := alg.eventDataRec.stopAtInit;
      alg.waitAtEvent := alg.eventDataRec.waitAtInit;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Init", OEDispatcher, zumeArgRec);
    END;
  END Init;

PROCEDURE SetVal (
      initiator: Algorithm.T;
       i: CARDINAL; val: Sort.Key
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetValArgs
               , i := i
               , val := val
      );
      alg := NARROW(initiator, SortAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSetVal);
      alg.stopAtEvent := alg.eventDataRec.stopAtSetVal;
      alg.waitAtEvent := alg.eventDataRec.waitAtSetVal;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "SetVal", OEDispatcher, zumeArgRec);
    END;
  END SetVal;

PROCEDURE SwapElts (
      initiator: Algorithm.T;
       i, j: CARDINAL
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SwapEltsArgs
               , i := i
               , j := j
      );
      alg := NARROW(initiator, SortAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSwapElts);
      alg.stopAtEvent := alg.eventDataRec.stopAtSwapElts;
      alg.waitAtEvent := alg.eventDataRec.waitAtSwapElts;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "SwapElts", OEDispatcher, zumeArgRec);
    END;
  END SwapElts;

PROCEDURE StartPass (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(StartPassArgs
      );
      alg := NARROW(initiator, SortAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfStartPass);
      alg.stopAtEvent := alg.eventDataRec.stopAtStartPass;
      alg.waitAtEvent := alg.eventDataRec.waitAtStartPass;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "StartPass", OEDispatcher, zumeArgRec);
    END;
  END StartPass;

PROCEDURE UpdateVal (
      initiator: Algorithm.T;
       i: CARDINAL; val: Sort.Key
    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(UpdateValArgs
               , i := i
               , val := val
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Update, 1,
                  "UpdateVal", OEDispatcher, zumeArgRec);
  END UpdateVal;

PROCEDURE ChangeVal (
      initiator: View.T;
       i: CARDINAL; new: Sort.Key
    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(ChangeValArgs
               , i := i
               , new := new
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Notify, 1,
                  "ChangeVal", FEDispatcher, zumeArgRec);
  END ChangeVal;

BEGIN
END SortIE.

interface View is in: