(**************************************************************************

     $RCSfile: Commodities.mod $
  Description: Interface to commodities.library

   Created by: fjc (Frank Copeland)
    $Revision: 1.2 $
      $Author: fjc $
        $Date: 1994/05/12 19:11:02 $

  Copyright © 1994, Frank Copeland.
  This file is part of the Oberon-A Library.
  See Oberon-A.doc for conditions of use and distribution.

  Log entries are at the end of the file.

***************************************************************************)

MODULE Commodities;

(* $P- allow non-portable code *)

IMPORT Types, Exec, IE := InputEvents, KeyMaps, SYS := SYSTEM;

CONST

  cbdNameLen *     = 24;
  cbdTitleLen *    = 40;
  cbdDescrLen *    = 40;

  cbErrOK *        = 0;
  cbErrSysErr *    = 1;
  cbErrDup *       = 2;
  cbErrVersion *   = 3;

  nbVersion *      = 5;

TYPE

  NewBrokerPtr * = CPOINTER TO NewBroker;
  NewBroker * = RECORD
    nbVersion *         : SHORTINT;
    nbName *            : Types.STRPTR;
    nbTitle *           : Types.STRPTR;
    nbDescr *           : Types.STRPTR;
    nbUnique *          : INTEGER;
    nbFlags *           : INTEGER;
    nbPri *             : SHORTINT;
    nbPort *            : Exec.MsgPortPtr;
    nbReservedChannel * : INTEGER;
  END;

CONST

  nbuDuplicate *   = 0;
  nbuUnique *      = 1;
  nbuNotify *      = 2;

  coShowHide *     = 4;

TYPE

  CxObj * = LONGINT;
  CxObjPtr * = CPOINTER TO CxObj;
  CxMsg * = LONGINT;
  CxMsgPtr * = CPOINTER TO CxMsg;

  PFL * = PROCEDURE () : LONGINT;

CONST

  cxInvalid *      = 0;
  cxFilter *       = 1;
  cxTypeFilter *   = 2;
  cxSend *         = 3;
  cxSignal *       = 4;
  cxTranslate *    = 5;
  cxBroker *       = 6;
  cxDebug *        = 7;
  cxCustom *       = 8;
  cxZero *         = 9;

  cxmUnique *   = 4;

  cxmIEvent *   = 5;

  cxmCommand *   = 6;

  cxCmdDisable *   = 15;
  cxCmdEnable *    = 17;
  cxCmdAppear *    = 19;
  cxCmdDisappear * = 21;
  cxCmdKill *      = 23;
  cxCmdUnique *    = 25;
  cxCmdListChg *  =  27;

  cmdeOK *         =  0;
  cmdeNoBroker *   = -1;
  cmdeNoPort *     = -2;
  cmdeNoMem *      = -3;

  coErrIsNull *       = 1;
  coErrNullAttach *   = 2;
  coErrBadFilter *    = 4;
  coErrBadType *      = 8;

  ixVersion *   = 2;

TYPE

  InputXpressionPtr * = CPOINTER TO InputXpression;
  InputXpression * = RECORD
    ixVersion *   : Types.UBYTE;
    ixClass *     : Types.UBYTE;

    ixCode *      : Types.UWORD;
    ixCodeMask *  : Types.WSET;

    ixQualifier * : Types.UWORD;
    ixQualMask *  : Types.WSET;
    ixQualSame *  : Types.WSET;
  END;

  IX * = InputXpression;
  IXPtr * = CPOINTER TO IX;

CONST

  ixSymShift *  = 1;
  ixSymCaps *   = 2;
  ixSymAlt *    = 4;

  ixSymShiftMask * = { IE.ieQualifierLShift, IE.ieQualifierRShift };
  ixSymCapsMask *  = ixSymShiftMask + { IE.ieQualifierCapsLock };
  ixSymAltMask *   = { IE.ieQualifierLAlt, IE.ieQualifierRAlt };

  ixNormalQuals *  = {0 .. 14};

(*-- Library Base variable --------------------------------------------*)

TYPE

  CommoditiesBasePtr * = CPOINTER TO CommoditiesBase;
  CommoditiesBase * = RECORD (Exec.Library) END;

CONST

  Name * = "commodities.library";

VAR

  Base * : CommoditiesBasePtr;
  cleanup : PROCEDURE (rc : LONGINT);

(*-- Library Functions ------------------------------------------------*)

LIBCALL (base : CommoditiesBasePtr) CreateCxObj*
  ( type {0} : Types.ULONG;
    arg1 {8} : SYS.LONGWORD;
    arg2 {9} : SYS.LONGWORD )
  : CxObjPtr;
  -30;
LIBCALL (base : CommoditiesBasePtr) CxBroker*
  ( VAR nb    {8} : NewBroker;
    VAR error {0} : LONGINT )
  : CxObjPtr;
  -36;
LIBCALL (base : CommoditiesBasePtr) ActivateCxObj*
  ( co   {8} : CxObjPtr;
    true {0} : Types.LBOOL )
  : Types.LBOOL;
  -42;
LIBCALL (base : CommoditiesBasePtr) DeleteCxObj*
  ( co {8} : CxObjPtr );
  -48;
LIBCALL (base : CommoditiesBasePtr) DeleteCxObjAll*
  ( co {8} : CxObjPtr );
  -54;
LIBCALL (base : CommoditiesBasePtr) CxObjType*
  ( co {8} : CxObjPtr )
  : Types.ULONG;
  -60;
LIBCALL (base : CommoditiesBasePtr) CxObjError*
  ( co {8} : CxObjPtr )
  : SET;
  -66;
LIBCALL (base : CommoditiesBasePtr) ClearCxObjError*
  ( co {8} : CxObjPtr );
  -72;
LIBCALL (base : CommoditiesBasePtr) SetCxObjPri*
  ( co  {8} : CxObjPtr;
    pri {0} : LONGINT );
  -78;

LIBCALL (base : CommoditiesBasePtr) AttachCxObj*
  ( headObj {8} : CxObjPtr;
    co      {9} : CxObjPtr );
  -84;
LIBCALL (base : CommoditiesBasePtr) EnqueueCxObj*
  ( headObj {8} : CxObjPtr;
    co      {9} : CxObjPtr );
  -90;
LIBCALL (base : CommoditiesBasePtr) InsertCxObj*
  ( headObj {8} : CxObjPtr;
    co      {9} : CxObjPtr;
    pred   {10} : CxObjPtr );
  -96;
LIBCALL (base : CommoditiesBasePtr) RemoveCxObj*
  ( co {8} : CxObjPtr );
  -102;

LIBCALL (base : CommoditiesBasePtr) SetTranslate*
  ( translator {8} : CxObjPtr;
    events     {9} : IE.InputEventPtr );
  -114;
LIBCALL (base : CommoditiesBasePtr) SetFilter*
  ( filter {8} : CxObjPtr;
    text   {9} : ARRAY OF CHAR );
  -120;
LIBCALL (base : CommoditiesBasePtr) SetFilterIX*
  ( filter {8} : CxObjPtr;
    VAR ix {9} : IX );
  -126;
LIBCALL (base : CommoditiesBasePtr) ParseIX*
  ( description {8} : ARRAY OF CHAR;
    VAR ix      {9} : IX )
  : LONGINT;
  -132;

LIBCALL (base : CommoditiesBasePtr) CxMsgType*
  ( cxm {8} : CxMsgPtr )
  : Types.ULONG;
  -138;
LIBCALL (base : CommoditiesBasePtr) CxMsgData*
  ( cxm {8} : CxMsgPtr )
  : Types.APTR;
  -144;
LIBCALL (base : CommoditiesBasePtr) CxMsgID*
  ( cxm {8} : CxMsgPtr )
  : LONGINT;
  -150;

LIBCALL (base : CommoditiesBasePtr) DivertCxMsg*
  ( cxm     {8} : CxMsgPtr;
    headobj {9} : CxObjPtr;
    ret    {10} : CxObjPtr );
  -156;
LIBCALL (base : CommoditiesBasePtr) RouteCxMsg*
  ( cxm {8} : CxMsgPtr;
    co  {9} : CxObjPtr );
  -162;
LIBCALL (base : CommoditiesBasePtr) DisposeCxMsg*
  ( cxm {8} : CxMsgPtr );
  -168;

LIBCALL (base : CommoditiesBasePtr) InvertKeyMap*
  ( ansicode  {0} : Types.ULONG;
    VAR event {8} : IE.InputEvent;
    km        {9} : KeyMaps.KeyMapPtr )
  : BOOLEAN;
  -174;
LIBCALL (base : CommoditiesBasePtr) AddIEvents*
  ( VAR events {8} : IE.InputEvent );
  -180;

(*-- C Macros defined as procedures -----------------------------------*)
(* $L+ Absolute long addressing for globals *)

(*-----------------------------------*)
PROCEDURE CxFilter *
  (base : CommoditiesBasePtr; d : Types.STRPTR)
  : CxObjPtr;
BEGIN
  RETURN base.CreateCxObj (cxFilter, d, 0)
END CxFilter;

(*-----------------------------------*)
PROCEDURE CxTypeFilter *
  (base : CommoditiesBasePtr; type : LONGINT)
  : CxObjPtr;
BEGIN
  RETURN base.CreateCxObj (cxTypeFilter, type, 0)
END CxTypeFilter;

(*-----------------------------------*)
PROCEDURE CxSender *
  (base : CommoditiesBasePtr; port : Exec.MsgPortPtr; id : LONGINT)
  : CxObjPtr;
BEGIN
  RETURN base.CreateCxObj (cxSend, port, id)
END CxSender;

(*-----------------------------------*)
PROCEDURE CxSignal *
  (base : CommoditiesBasePtr; task : Exec.TaskPtr; sig : LONGINT)
  : CxObjPtr;
BEGIN
  RETURN base.CreateCxObj (cxSignal, task, sig)
END CxSignal;

(*-----------------------------------*)
PROCEDURE CxTranslate *
  (base : CommoditiesBasePtr; VAR ie : IE.InputEvent)
  : CxObjPtr;
BEGIN
  RETURN base.CreateCxObj (cxTranslate, SYS.ADR (ie), 0)
END CxTranslate;

(*-----------------------------------*)
PROCEDURE CxDebug *
  (base : CommoditiesBasePtr; id : LONGINT)
  : CxObjPtr;
BEGIN
  RETURN base.CreateCxObj (cxDebug, id, 0)
END CxDebug;

(*-----------------------------------*)
PROCEDURE CxCustom *
  (base : CommoditiesBasePtr; action : PROCEDURE; id : LONGINT)
  : CxObjPtr;
BEGIN
  RETURN base.CreateCxObj (cxCustom, action, id)
END CxCustom;

(*-- Library Base variable --------------------------------------------*)
(* $L- Address globals through A4 *)

(*-----------------------------------*)
PROCEDURE* CloseLib (rc : LONGINT);

BEGIN
  IF Base # NIL THEN Exec.Base.CloseLibrary (Base) END;
  IF cleanup # NIL THEN cleanup (rc) END
END CloseLib;

(*-----------------------------------*)
PROCEDURE OpenLib * ();

BEGIN
  IF Base = NIL THEN
    Base := Exec.Base.OpenLibrary (Name, Exec.libraryMinimum);
    IF Base = NIL THEN HALT (100) END;
    SYS.SETCLEANUP (CloseLib, cleanup)
  END;
END OpenLib;

BEGIN
  Base := NIL; cleanup := NIL
END Commodities.

(**************************************************************************

  $Log: Commodities.mod $
  Revision 1.2  1994/05/12  19:11:02  fjc
  - Prepared for release

  Revision 1.1  1994/01/15  21:04:12  fjc
  - Start of revision control

***************************************************************************)

 

(* Comments stripped by StripComments 1.0 *)
