Back to index

tetex-bin  3.0
objects.h
Go to the documentation of this file.
00001 /* $XConsortium: objects.h,v 1.6 92/03/20 14:35:56 keith Exp $ */
00002 /* Copyright International Business Machines, Corp. 1991
00003  * All Rights Reserved
00004  * Copyright Lexmark International, Inc. 1991
00005  * All Rights Reserved
00006  *
00007  * License to use, copy, modify, and distribute this software and its
00008  * documentation for any purpose and without fee is hereby granted,
00009  * provided that the above copyright notice appear in all copies and that
00010  * both that copyright notice and this permission notice appear in
00011  * supporting documentation, and that the name of IBM or Lexmark not be
00012  * used in advertising or publicity pertaining to distribution of the
00013  * software without specific, written prior permission.
00014  *
00015  * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
00016  * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
00017  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
00018  * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE
00019  * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
00020  * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF THE
00021  * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
00022  * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN NO EVENT SHALL
00023  * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
00024  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
00025  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
00026  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
00027  * THIS SOFTWARE.
00028  */
00029 /*SHARED*/
00030  
00031 /*END SHARED*/
00032 /*SHARED*/
00033 
00034 #include "types.h"
00035 
00036 #define   Permanent(obj)    t1_Permanent(obj)
00037 #define   Temporary(obj)    t1_Temporary(obj)
00038 #define   Destroy(obj)      t1_Destroy(obj)
00039 #define   Dup(obj)          t1_Dup(obj)
00040 #define   InitImager()      t1_InitImager()
00041 #define   TermImager()      t1_TermImager()
00042 #define   Pragmatics(f,v)   t1_Pragmatics(f,v)
00043 #define   ErrorMsg()        t1_ErrorMsg()
00044  
00045 struct xobject *t1_Permanent();  /* make an object permanent                  */
00046 struct xobject *t1_Temporary();  /* make an object temporary                  */
00047 struct xobject *t1_Destroy();    /* destroy an object                         */
00048 struct xobject *t1_Dup();     /* duplicate an object                          */
00049 void t1_InitImager();         /* initialize TYPE1IMAGER                           */
00050 void t1_TermImager();         /* terminate TYPE1IMAGER                            */
00051 void t1_Pragmatics();         /* set debug flags, etc.                        */
00052 char *t1_ErrorMsg();          /* return last TYPE1IMAGER error message            */
00053  
00054 /*END SHARED*/
00055 /*SHARED*/
00056  
00057 #define   abort(line,no)       t1_abort(line,no)
00058 #define   Allocate(n,t,s)   t1_Allocate(n,t,s)
00059 #define   Free(obj)         t1_Free(obj)
00060 #define   NonObjectFree(a)  free(a)
00061 #define   Consume           t1_Consume
00062 #define   ArgErr(s,o,r)     t1_ArgErr(s,o,r)
00063 #define   TypeErr(n,o,e,r)  t1_TypeErr(n,o,e,r)
00064 #define   Copy(obj)         t1_Copy(obj)
00065 #define   Unique(obj)       t1_Unique(obj)
00066  
00067 void t1_abort();              /* crash; software logic error                  */
00068 struct xobject *t1_Allocate();    /* allocate memory                          */
00069 void t1_Free();               /* free memory                                  */
00070 struct xobject *t1_Unique();  /* make a unique temporary copy of an object    */
00071 struct xobject *t1_ArgErr();  /* handle argument errors                       */
00072 struct xobject *t1_TypeErr(); /* handle 'bad type' argument errors            */
00073 void t1_Consume();            /* consume a variable number of arguments       */
00074 struct xobject *t1_Copy();    /* make a new copy, not reference bump PNM      */
00075  
00076 /*END SHARED*/
00077 /*SHARED*/
00078  
00079 #define   ON          (~0)   /* all bits on                                  */
00080 #ifndef FALSE
00081 #define   FALSE       0      /* handy zero value                             */
00082 #endif
00083 #ifndef TRUE
00084 #define   TRUE        1      /* handy non-zero value                         */
00085 #endif
00086  
00087 #ifndef   NULL
00088 #define   NULL        0
00089 /*
00090 The NULL pointer is system specific.  (Most systems, however, use 0.)
00091 TYPE1IMAGER could have its own NULL, independent of the rest of the system,
00092 were it not for malloc().  The system call malloc() returns NULL when
00093 out of memory.
00094 :i1/portibility assumptions/
00095 */
00096 #endif
00097  
00098 #define   TYPE1_MIN(a,b)    (((a)<(b)) ? a : b)
00099 #define   TYPE1_MAX(a,b)    (((a)>(b)) ? a : b)
00100 #define   TYPE1_ABS(a)      (((a)>=0)?(a):-(a))
00101  
00102 /*END SHARED*/
00103 /*SHARED*/
00104  
00105 struct xobject {
00106        char type;           /* encoded type of object                         */
00107        unsigned char flag;  /* flag byte for temporary object characteristics */
00108        short references;    /* count of pointers to this object
00109                                (plus 1 for permanent objects) PNM             */
00110 } ;
00111  
00112 /*END SHARED*/
00113 /*SHARED*/
00114  
00115 #define XOBJ_COMMON      char type; unsigned char flag; short references;
00116  
00117 /*END SHARED*/
00118 /*SHARED*/
00119  
00120  
00121 #define   INVALIDTYPE    0
00122 #define   FONTTYPE       1
00123 #define   REGIONTYPE     3
00124 #define   PICTURETYPE    4
00125 #define   SPACETYPE      5
00126 #define   LINESTYLETYPE  6
00127 #define   EDGETYPE       7
00128 #define   STROKEPATHTYPE 8
00129 #define   CLUTTYPE       9
00130  
00131 #define   ISPATHTYPE(type)    ((type)&0x10)  /* all path segments have this bit on */
00132 #define   LINETYPE    (0+ISPATHTYPE(ON))
00133 #define   CONICTYPE   (1+ISPATHTYPE(ON))
00134 #define   BEZIERTYPE  (2+ISPATHTYPE(ON))
00135 #define   HINTTYPE    (3+ISPATHTYPE(ON))
00136  
00137 #define   MOVETYPE    (5+ISPATHTYPE(ON))
00138 #define   TEXTTYPE    (6+ISPATHTYPE(ON))
00139  
00140 /*END SHARED*/
00141 /*SHARED*/
00142  
00143 #define   ISPERMANENT(flag)   ((flag)&0x01)
00144 #define   ISIMMORTAL(flag)    ((flag)&0x02)
00145  
00146 /*END SHARED*/
00147 /*SHARED*/
00148  
00149 #define   PRESERVE(obj)   if (!ISPERMANENT((obj)->flag)) \
00150    (obj)->references++;
00151  
00152 /*END SHARED*/
00153 /*SHARED*/
00154  
00155 #define  LONGCOPY(dest,source,bytes) { \
00156     register LONG *p1 = (LONG *)dest;  register LONG *p2 = (LONG *)source; \
00157     register int count = (bytes) / sizeof(LONG); \
00158     while (--count >= 0) *p1++ = *p2++; }
00159  
00160  
00161 /*END SHARED*/
00162 /*SHARED*/
00163  
00164 #define   FOLLOWING(p)  ((p)+1)
00165  
00166 /*END SHARED*/
00167 /*SHARED*/
00168  
00169 #define  TYPECHECK(name, obj, expect, whenBAD, consumables, rettype) { \
00170     if (obj->type != expect) { \
00171          (Consume)consumables; \
00172          return((rettype)TypeErr(name, obj, expect, whenBAD)); \
00173     } \
00174 }
00175  
00176 /*END SHARED*/
00177 /*SHARED*/
00178  
00179 #define  ARGCHECK(test,msg,obj,whenBAD,consumables,rettype) { \
00180     if (test) { \
00181         (Consume)consumables; \
00182         return((rettype)ArgErr(msg, obj, whenBAD)); \
00183     } \
00184 }
00185  
00186 /*END SHARED*/
00187 /*SHARED*/
00188  
00189 /* Changed use of Dup() below to Temporary(Copy()) because Dup() does not
00190    necessarily return a Unique Copy anymore! 3-26-91 */
00191 #define  TYPENULLCHECK(name, obj, expect, whenBAD, consumables,rettype) \
00192     if (obj == NULL) { \
00193         (Consume)consumables; \
00194         if (whenBAD != NULL && ISPERMANENT(whenBAD->flag)) \
00195               return((rettype)Temporary(Copy(whenBAD))); \
00196         else  return((rettype)whenBAD); \
00197     } else { \
00198         if (obj->type != expect) { \
00199              (Consume)consumables; \
00200              return((rettype)TypeErr(name, obj, expect, whenBAD)); \
00201         } \
00202     }
00203 /*END SHARED*/
00204 /*SHARED*/
00205  
00206 #define  MAKECONSUME(obj,stmt)  { if (!ISPERMANENT(obj->flag)) stmt; }
00207  
00208 /*END SHARED*/
00209 /*SHARED*/
00210  
00211 #define MAKEUNIQUE(obj,stmt) ( ( (obj)->references > 1 ) ? stmt : obj )
00212  
00213 /*END SHARED*/
00214 /*SHARED*/
00215 /* NDW: personally, I want to see status and error messages! */
00216 #define IfTrace0(condition,model)                                 \
00217         {if (condition) printf(model);}
00218 #define IfTrace1(condition,model,arg0)                            \
00219         {if (condition) printf(model,arg0);}
00220 #define IfTrace2(condition,model,arg0,arg1)                       \
00221         {if (condition) printf(model,arg0,arg1);}
00222 #define IfTrace3(condition,model,arg0,arg1,arg2)                  \
00223         {if (condition) printf(model,arg0,arg1,arg2);}
00224 #define IfTrace4(condition,model,arg0,arg1,arg2,arg3)             \
00225         {if (condition) printf(model,arg0,arg1,arg2,arg3);}
00226 #define IfTrace5(condition,model,arg0,arg1,arg2,arg3,arg4)        \
00227         {if (condition) printf(model,arg0,arg1,arg2,arg3,arg4);}
00228 #define IfTrace6(condition,model,arg0,arg1,arg2,arg3,arg4,arg5)   \
00229         {if (condition) printf(model,arg0,arg1,arg2,arg3,arg4,arg5);}
00230 /* NDW: patch ends */
00231  
00232 void Trace0();
00233 char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
00234  
00235 #ifdef GLOBALS
00236  
00237 #define   extern
00238 #define   INITIALIZED(value)      = value
00239  
00240 #else
00241  
00242 #define   INITIALIZED(value)
00243  
00244 #endif
00245  
00246 extern char MustCheckArgs  INITIALIZED(TRUE);
00247 extern char MustTraceCalls INITIALIZED(FALSE);
00248 extern char MustCrash      INITIALIZED(TRUE);
00249 extern char InternalTrace  INITIALIZED(TRUE);
00250 extern char LineIOTrace    INITIALIZED(TRUE);
00251  
00252 extern char ProcessHints   INITIALIZED(TRUE);
00253  
00254 extern char SaveFontPaths  INITIALIZED(TRUE);
00255  
00256 extern short CRASTERCompressionType   INITIALIZED(1);
00257  
00258 extern char ConicDebug     INITIALIZED(0);
00259 extern char LineDebug      INITIALIZED(0);
00260 extern char RegionDebug    INITIALIZED(0);
00261 extern char PathDebug      INITIALIZED(0);
00262 extern char FontDebug      INITIALIZED(0);
00263 extern char SpaceDebug     INITIALIZED(0);
00264 extern char StrokeDebug    INITIALIZED(0);
00265 extern char MemoryDebug    INITIALIZED(0);
00266 extern char HintDebug      INITIALIZED(0);
00267 extern char ImageDebug     INITIALIZED(0);
00268 extern char OffPageDebug   INITIALIZED(0);
00269  
00270 extern short CachedChars   INITIALIZED(0x7FFF);
00271 extern short CachedFonts   INITIALIZED(0x7FFF);
00272 extern int   CacheBLimit   INITIALIZED(12500);
00273 extern char  Continuity    INITIALIZED(2);
00274  
00275 #ifdef extern
00276 #undef extern
00277 #endif
00278  
00279 /*
00280 We define other routines formatting parameters
00281 */
00282 #define    DumpArea(area)    t1_DumpArea(area)
00283 #define    DumpText(text)    t1_DumpText(text)
00284 /* #define    DumpPath(path)    t1_DumpPath(path) */ /* commented by RMz, 1999-06-10 */
00285 #define    DumpSpace(space)  t1_DumpSpace(space)
00286 #define    DumpEdges(e)      t1_DumpEdges(e)
00287 #define    FormatFP(s,p)     t1_FormatFP(s,p)
00288  
00289 void t1_DumpArea();           /* dump a region structure                      */
00290 void t1_DumpText();           /* dump a textpath structure                    */
00291 void t1_DumpPath();           /* dump a path list                             */
00292 void t1_DumpSpace();          /* dump a coordinate space structure            */
00293 void t1_DumpEdges();          /* dump a region's edge list                    */
00294 void t1_FormatFP();           /* dump a format a "fractpel" coordinate        */
00295  
00296 /*END SHARED*/