mentor/derived/ZPaperIE.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 ZPaper.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE ZPaperIE;

<*NOWARN*> IMPORT ZPaperViewClass, ZeusClass, Zeus, Algorithm;
<*NOWARN*> IMPORT ZPaperAlgClass, 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: INTEGER;
    k: INTEGER;
  END;

  SetArgs = BRANDED REF RECORD
    x: INTEGER;
    y: INTEGER;
    val: INTEGER;
  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
    | ZPaperViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | InitArgs(varInitArgs) => <*NOWARN*>
          view.oeInit (
              varInitArgs.N
                ,
              varInitArgs.k
              )
      | SetArgs(varSetArgs) => <*NOWARN*>
          view.oeSet (
              varSetArgs.x
                ,
              varSetArgs.y
                ,
              varSetArgs.val
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a ZPaperViewClass, so just ignore *)
    END
  END OEDispatcher;

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

PROCEDURE Init (
      initiator: Algorithm.T;
       N, k: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(InitArgs
               , N := N
               , k := k
      );
      alg := NARROW(initiator, ZPaperAlgClass.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 Set (
      initiator: Algorithm.T;
       x, y, val: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetArgs
               , x := x
               , y := y
               , val := val
      );
      alg := NARROW(initiator, ZPaperAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSet);
      alg.stopAtEvent := alg.eventDataRec.stopAtSet;
      alg.waitAtEvent := alg.eventDataRec.waitAtSet;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Set", OEDispatcher, zumeArgRec);
    END;
  END Set;

BEGIN
END ZPaperIE.

interface View is in: