home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / h / grttin.h < prev    next >
C/C++ Source or Header  |  2002-01-18  |  11KB  |  337 lines

  1. /*
  2.  * Group of include files for input to rtt.
  3.  *   rtt reads these files for preprocessor directives and typedefs, but
  4.  *   does not output any code from them.
  5.  */
  6. #include "../h/define.h"
  7. #include "../h/arch.h"
  8. #include "../h/config.h"
  9. #include "../h/version.h"
  10.  
  11. #ifndef NoTypeDefs
  12.    #include "../h/typedefs.h"
  13. #endif                    /* NoTypeDefs */
  14.  
  15. /*
  16.  * Macros that must be expanded by rtt.
  17.  */
  18.  
  19. /*
  20.  * Declaration for library routine.
  21.  */
  22. #begdef LibDcl(nm,n,pn)
  23.    #passthru OpBlock(nm,n,pn,0)
  24.  
  25.    int O##nm(nargs,cargp)
  26.    int nargs;
  27.    register dptr cargp;
  28. #enddef                    /* LibDcl */
  29.  
  30. /*
  31.  * Error exit from non top-level routines. Set tentative values for
  32.  *   error number and error value; these errors will but put in
  33.  *   effect if the run-time error routine is called.
  34.  */
  35. #begdef ReturnErrVal(err_num, offending_val, ret_val)
  36.    do {
  37.    t_errornumber = err_num;
  38.    t_errorvalue = offending_val;
  39.    t_have_val = 1;
  40.    return ret_val;
  41.    } while (0)
  42. #enddef                    /* ReturnErrVal */
  43.  
  44. #begdef ReturnErrNum(err_num, ret_val)
  45.    do {
  46.    t_errornumber = err_num;
  47.    t_errorvalue = nulldesc;
  48.    t_have_val = 0;
  49.    return ret_val;
  50.    } while (0)
  51. #enddef                    /* ReturnErrNum */
  52.  
  53. /*
  54.  * Code expansions for exits from C code for top-level routines.
  55.  */
  56. #define Fail        return A_Resume
  57. #define Return        return A_Continue
  58.  
  59. /*
  60.  * RunErr encapsulates a call to the function err_msg, followed
  61.  *  by Fail.  The idea is to avoid the problem of calling
  62.  *  runerr directly and forgetting that it may actually return.
  63.  */
  64.  
  65. #define RunErr(n,dp) do {\
  66.    err_msg((int)n,dp);\
  67.    Fail;\
  68.    } while (0)
  69.  
  70. /*
  71.  * Protection macro.
  72.  */
  73. #define Protect(notnull,orelse) do {if ((notnull)==NULL) orelse;} while(0)
  74.  
  75. #ifdef EventMon
  76. /*
  77.  * perform what amounts to "function inlining" of EVVal
  78.  */
  79. #begdef EVVal(value,event)
  80.    do {
  81.       if (is:null(curpstate->eventmask)) break;
  82.       else if (!Testb((word)event, curpstate->eventmask)) break;
  83.       MakeInt(value, &(curpstate->parent->eventval));
  84.       actparent(event);
  85.    } while (0)
  86. #enddef                    /* EVVal */
  87. #begdef EVValD(dp,event)
  88.    do {
  89.       if (is:null(curpstate->eventmask)) break;
  90.       else if (!Testb((word)event, curpstate->eventmask)) break;
  91.       curpstate->parent->eventval = *(dp);
  92.       actparent(event);
  93.    } while (0)
  94. #enddef                    /* EVValD */
  95. #begdef EVValX(bp,event)
  96.    do {
  97.       struct progstate *parent = curpstate->parent;
  98.       if (is:null(curpstate->eventmask)) break;
  99.       else if (!Testb((word)event, curpstate->eventmask)) break;
  100.       parent->eventval.dword = D_Coexpr;
  101.       BlkLoc(parent->eventval) = (union block *)(bp);
  102.       actparent(event);
  103.    } while (0)
  104. #enddef                    /* EVValX */
  105.  
  106. #if UNIX
  107.    #begdef EVTick()
  108.    /*
  109.     * EVTick() - record a Tick event reflecting a clock advance.
  110.     *
  111.     *  The interpreter main loop has detected a change in the profile counters.
  112.     *  This means that the system clock has ticked.  Record an event and update
  113.     *  the records.
  114.     */
  115.    do {
  116.       word sum, nticks;
  117.  
  118.       oldtick = ticker.l[0] + ticker.l[1];
  119.       sum = ticker.s[0] + ticker.s[1] + ticker.s[2] + ticker.s[3];
  120.       nticks = sum - oldsum;
  121.       EVVal(nticks, E_Tick);
  122.       oldsum = sum;
  123.    } while (0)
  124.    #enddef                /* EVTick */
  125. #else                    /* UNIX */
  126.    #define EVTick()
  127. #endif                    /* UNIX */
  128.  
  129. #define InterpEVVal(arg1,arg2)  { ExInterp; EVVal(arg1,arg2); EntInterp; }
  130. #define InterpEVValD(arg1,arg2) { ExInterp; EVValD(arg1,arg2); EntInterp; }
  131. #define InterpEVValX(arg1,arg2) { ExInterp; EVValX(arg1,arg2); EntInterp; }
  132. #define InterpEVTick()          { ExInterp; EVTick(); EntInterp; }
  133.  
  134. /*
  135.  * Macro with construction of event descriptor.
  136.  */
  137.  
  138. #begdef Desc_EVValD(bp, code, type)
  139.    do {
  140.    eventdesc.dword = type;
  141.    eventdesc.vword.bptr = (union block *)(bp);
  142.    EVValD(&eventdesc, code);
  143.    } while (0)
  144. #enddef                    /* Desc_EVValD */
  145.  
  146. #else                    /* EventMon */
  147.    #define EVVal(arg1,arg2)
  148.    #define EVValD(arg1,arg2)
  149.    #define EVValX(arg1,arg2)
  150.    #define EVTick()
  151.    #define InterpEVVal(arg1,arg2)
  152.    #define InterpEVValD(arg1,arg2)
  153.    #define InterpEVValX(arg1,arg2)
  154.    #define InterpEVTick()
  155.    #define Desc_EVValD(bp, code, type)
  156. #endif                    /* EventMon */
  157.  
  158. /*
  159.  * dummy typedefs for things defined in #include files
  160.  */
  161. typedef int clock_t, time_t, fd_set;
  162.  
  163. #if OS2_32
  164.    typedef int HFILE, ULONG;
  165. #endif                    /* OS2_32 */
  166.  
  167. #if WildCards
  168.    typedef int FINDDATA_T;
  169. #endif                    /* WildCards */
  170.  
  171. #ifdef ReadDirectory
  172.    typedef int DIR;
  173. #endif                    /* ReadDirectory */
  174.  
  175. /*
  176.  * graphics
  177.  */
  178. #ifdef Graphics
  179.    typedef int wbp, wsp, wcp, wdp, wclrp, wfp;
  180.    typedef int wbinding, wstate, wcontext, wfont;
  181.    typedef int siptr, stringint;
  182.    typedef int XRectangle, XPoint, XSegment, XArc, SysColor, LinearColor;
  183.    typedef int LONG, SHORT;
  184.  
  185.    #ifdef MacGraph
  186.       typedef int Str255, Point, StandardFileReply, SFTypeList, Ptr, PixMap;
  187.       typedef int Boolean, Rect, PolyHandle, EventRecord, wsp, MouseInfoType;
  188.       typedef int Handle, MenuHandle, OSErr, WindowPtr, GWorldFlags;
  189.       typedef int PaletteHandle, BitMap, RgnHandle, QDErr, GWorldPtr;
  190.       typedef int GrafPtr, GDHandle, PixMapHandle, OSType, FInfo;
  191.       typedef int IOParam, DialogPtr, ControlHandle, StringHandle, Size;
  192.    #endif                /* MacGraph */
  193.  
  194.    #ifdef XWindows
  195.       typedef int Atom, Time, XSelectionEvent, XErrorEvent, XErrorHandler;
  196.       typedef int XGCValues, XColor, XFontStruct, XWindowAttributes, XEvent;
  197.       typedef int XExposeEvent, XKeyEvent, XButtonEvent, XConfigureEvent;
  198.       typedef int XSizeHints, XWMHints, XClassHint, XTextProperty;
  199.       typedef int Colormap, XVisualInfo, va_list;
  200.       typedef int *Display, Cursor, GC, Window, Pixmap, Visual, KeySym;
  201.       typedef int WidgetClass, XImage, XpmAttributes;
  202.    #endif                /* XWindows */
  203.  
  204.    #ifdef MSWindows
  205.       typedef int clock_t, jmp_buf, MINMAXINFO, OSVERSIONINFO, BOOL_CALLBACK;
  206.       typedef int int_PASCAL, LRESULT_CALLBACK, MSG, BYTE, WORD, DWORD;
  207.       typedef int HINSTANCE, LPSTR, HBITMAP, WNDCLASS, PAINTSTRUCT, POINT, RECT;
  208.       typedef int HWND, HDC, UINT, WPARAM, LPARAM, HANDLE, HPEN, HBRUSH, SIZE;
  209.       typedef int COLORREF, HFONT, LOGFONT, TEXTMETRIC, FONTENUMPROC, FARPROC;
  210.       typedef int LOGPALETTE, HPALETTE, PALETTEENTRY, HCURSOR, BITMAP, HDIB;
  211.       typedef int va_list, LOGPEN, LOGBRUSH, LPVOID, MCI_PLAY_PARMS;
  212.       typedef int MCI_OPEN_PARMS, MCI_STATUS_PARMS, MCI_SEQ_SET_PARMS;
  213.       typedef int CHOOSEFONT, CHOOSECOLOR, OPENFILENAME, HMENU, LPBITMAPINFO;
  214.       typedef int childcontrol, CPINFO, BITMAPINFO, BITMAPINFOHEADER, RGBQUAD;
  215.       #ifdef FAttrib
  216.          typedef unsigned long mode_t;
  217.          typedef int HFILE, OFSTRUCT, FILETIME, SYSTEMTIME;
  218.       #endif                /* FAttrib */
  219.    #endif                /* MSWindows */
  220.  
  221.    #ifdef PresentationManager
  222.       /* OS/2 PM specifics */
  223.       typedef int HAB, HPS, QMSG, HMQ, HWND, USHORT, MRESULT, ULONG, MPARAM;
  224.       typedef int PFNWP, HMODULE, SHORT, BOOL, TID, RECTL, ERRORID;
  225.       typedef int MRESULT_N_EXPENTRY, SIZEL, HDC, POINTL, HMTX, HBITMAP;
  226.       typedef int VOID_APIENTRY, UCHAR, HEV, LINEBUNDLE, BUTMAPARRAYFILEHEADER;
  227.       typedef int LONG, BITMAPINFOHEADER2, PBITMAPINFO2, PSZ, RGB2, BITMAPINFO2;
  228.       typedef int FONTMETRICS, PRECTL, PCHARBUNDLE, PLINEBUNDLE, PIMAGEBUNDLE;
  229.       typedef int AREABUNDLE, PAREABUNDLE, PPOINTL, POLYGON, CHARBUNDLE;
  230.       typedef int lclIdentifier, BYTE, PBYTE, PRGB2, FATTRS, PFATTRS, PULONG;
  231.       typedef int PBITMAPINFOHEADER2, BITMAPFILEHEADER2, BITMAPARRAYFILEHEADER2;
  232.       typedef int colorEntry, ARCPARAMS, threadargs, HPOINTER, CURSORINFO;
  233.       typedef int PCURSORINFO, DEVOPENSTRUCT, PDEVOPENDATA, SIZEF, HRGN, PSWP;
  234.       typedef int va_list, BITMAPINFOHEADER, BITMAPFILEHEADER;
  235.       typedef int PBITMAPINFOHEADER, MinBitmapHeader, RGB;
  236.    #endif                /* PresentationManager */
  237.  
  238.    /*
  239.     * Convenience macros to make up for RTL's long-windedness.
  240.     */
  241.    #begdef CnvCShort(desc, s)
  242.       {
  243.       C_integer tmp;
  244.       if (!cnv:C_integer(desc,tmp) || tmp > 0x7FFF || tmp < -0x8000)
  245.          runerr(101,desc);
  246.       s = (short) tmp;
  247.       }
  248.    #enddef                /* CnvCShort */
  249.  
  250.    #define CnvCInteger(d,i) \
  251.       if (!cnv:C_integer(d,i)) runerr(101,d);
  252.  
  253.    #define DefCInteger(d,default,i) \
  254.       if (!def:C_integer(d,default,i)) runerr(101,d);
  255.  
  256.    #define CnvString(din,dout) \
  257.       if (!cnv:string(din,dout)) runerr(103,din);
  258.  
  259.    #define CnvTmpString(din,dout) \
  260.       if (!cnv:tmp_string(din,dout)) runerr(103,din);
  261.  
  262.    /*
  263.     * conventions supporting optional initial window arguments:
  264.     *
  265.     * All routines declare argv[argc] as their parameters
  266.     * Macro OptWindow checks argv[0] and assigns _w_ and warg if it is a window
  267.     * warg serves as a base index and is added everywhere argv is indexed
  268.     * n is used to denote the actual number of "objects" in the call
  269.     * Macro ReturnWindow returns either the initial window argument, or &window
  270.     */
  271.    #begdef OptWindow(w)
  272.       if (argc>warg && is:file(argv[warg])) {
  273.          if ((BlkLoc(argv[warg])->file.status & Fs_Window) == 0)
  274.             runerr(140,argv[warg]);
  275.          if ((BlkLoc(argv[warg])->file.status & (Fs_Read|Fs_Write)) == 0)
  276.             runerr(142,argv[warg]);
  277.          (w) = (wbp)BlkLoc(argv[warg])->file.fd;
  278.          if (ISCLOSED(w))
  279.             runerr(142,argv[warg]);
  280.          warg++;
  281.          }
  282.       else {
  283.          if (!(is:file(kywd_xwin[XKey_Window]) &&
  284.             (BlkLoc(kywd_xwin[XKey_Window])->file.status & Fs_Window)))
  285.                runerr(140,kywd_xwin[XKey_Window]);
  286.          if (!(BlkLoc(kywd_xwin[XKey_Window])->file.status&(Fs_Read|Fs_Write)))
  287.             runerr(142,kywd_xwin[XKey_Window]);
  288.          (w) = (wbp)BlkLoc(kywd_xwin[XKey_Window])->file.fd;
  289.          if (ISCLOSED(w))
  290.             runerr(142,kywd_xwin[XKey_Window]);
  291.          }
  292.    #enddef                /* OptWindow */
  293.  
  294.    #begdef ReturnWindow
  295.          if (!warg) return kywd_xwin[XKey_Window];
  296.          else return argv[0]
  297.    #enddef                /* ReturnWindow */
  298.  
  299.    #begdef CheckArgMultiple(mult)
  300.       {
  301.       if ((argc-warg) % (mult)) runerr(146);
  302.       n = (argc-warg)/mult;
  303.       if (!n) runerr(146);
  304.       }
  305.    #enddef                /* CheckArgMultiple */
  306.  
  307.    /*
  308.     * calloc to make sure uninit'd entries are zeroed.
  309.     */
  310.    #begdef GRFX_ALLOC(var,type)
  311.       do {
  312.          var = (struct type *)calloc(1, sizeof(struct type));
  313.          if (var == NULL) ReturnErrNum(305, NULL);
  314.          var->refcount = 1;
  315.       } while(0)
  316.    #enddef                /* GRFX_ALLOC */
  317.  
  318.    #begdef GRFX_LINK(var, chain)
  319.       do {
  320.          var->next = chain;
  321.          var->previous = NULL;
  322.          if (chain) chain->previous = var;
  323.          chain = var;
  324.       } while(0)
  325.    #enddef                /* GRFX_LINK */
  326.  
  327.    #begdef GRFX_UNLINK(var, chain)
  328.       do {
  329.          if (var->previous) var->previous->next = var->next;
  330.          else chain = var->next;
  331.          if (var->next) var->next->previous = var->previous;
  332.          free(var);
  333.       } while(0)
  334.    #enddef                /* GRFX_UNLINK */
  335.  
  336. #endif                    /* Graphics */
  337.