mentor/derived/MatchIE.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 Match.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE MatchIE;

<*NOWARN*> IMPORT Match, MatchAlgClass, ZeusClass, Zeus;
<*NOWARN*> IMPORT MatchViewClass, Algorithm, VBT, View, Thread;
<*NOWARN*> IMPORT AlgorithmClass;

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

TYPE
  InitArgs = BRANDED REF RECORD
    clues: Match.Clues;
  END;

  SetStateArgs = BRANDED REF RECORD
    i: INTEGER;
    j: INTEGER;
    state: Match.State;
  END;

  SelectedArgs = BRANDED REF RECORD
    key: INTEGER;
    cd: VBT.MouseRec;
  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
    | MatchViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | InitArgs(varInitArgs) => <*NOWARN*>
          view.oeInit (
              varInitArgs.clues
              )
      | SetStateArgs(varSetStateArgs) => <*NOWARN*>
          view.oeSetState (
              varSetStateArgs.i
                ,
              varSetStateArgs.j
                ,
              varSetStateArgs.state
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a MatchViewClass, so just ignore *)
    END
  END OEDispatcher;

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

PROCEDURE Init (
      initiator: Algorithm.T;
       READONLY clues: Match.Clues
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(InitArgs
               , clues := clues
      );
      alg := NARROW(initiator, MatchAlgClass.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 SetState (
      initiator: Algorithm.T;
       i, j: INTEGER; state: Match.State
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetStateArgs
               , i := i
               , j := j
               , state := state
      );
      alg := NARROW(initiator, MatchAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSetState);
      alg.stopAtEvent := alg.eventDataRec.stopAtSetState;
      alg.waitAtEvent := alg.eventDataRec.waitAtSetState;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "SetState", OEDispatcher, zumeArgRec);
    END;
  END SetState;

PROCEDURE Selected (
      initiator: View.T;
       key: INTEGER; READONLY cd: VBT.MouseRec
    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(SelectedArgs
               , key := key
               , cd := cd
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Notify, 1,
                  "Selected", FEDispatcher, zumeArgRec);
  END Selected;

BEGIN
END MatchIE.

interface View is in: