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 #ifdef WIN32
00035 #include <stdio.h>
00036 #include <stdlib.h>
00037 #include <kpathsea/kpathsea.h>
00038 #include <c-auto.h>
00039 #endif
00040 
00041 #include "types.h"
00042 
00043 #define   Permanent(obj)    t1_Permanent(obj)
00044 #define   Temporary(obj)    t1_Temporary(obj)
00045 #define   Destroy(obj)      t1_Destroy(obj)
00046 #define   Dup(obj)          t1_Dup(obj)
00047 #define   InitImager()      t1_InitImager()
00048 #define   TermImager()      t1_TermImager()
00049 #define   Pragmatics(f,v)   t1_Pragmatics(f,v)
00050 #define   ErrorMsg()        t1_ErrorMsg()
00051  
00052 struct xobject *t1_Permanent();  /* make an object permanent                  */
00053 struct xobject *t1_Temporary();  /* make an object temporary                  */
00054 struct xobject *t1_Destroy();    /* destroy an object                         */
00055 struct xobject *t1_Dup();     /* duplicate an object                          */
00056 void t1_InitImager();         /* initialize TYPE1IMAGER                           */
00057 void t1_TermImager();         /* terminate TYPE1IMAGER                            */
00058 void t1_Pragmatics();         /* set debug flags, etc.                        */
00059 char *t1_ErrorMsg();          /* return last TYPE1IMAGER error message            */
00060  
00061 /*END SHARED*/
00062 /*SHARED*/
00063  
00064 #define   Allocate(n,t,s)   t1_Allocate(n,t,s)
00065 #define   Free(obj)         t1_Free(obj)
00066 #define   NonObjectFree(a)  Xfree(a)
00067 #define   Consume           t1_Consume
00068 #define   ArgErr(s,o,r)     t1_ArgErr(s,o,r)
00069 #define   TypeErr(n,o,e,r)  t1_TypeErr(n,o,e,r)
00070 #define   Copy(obj)         t1_Copy(obj)
00071 #define   Unique(obj)       t1_Unique(obj)
00072  
00073 void t1_abort();              /* crash; software logic error                  */
00074 struct xobject *t1_Allocate();    /* allocate memory                          */
00075 void t1_Free();               /* free memory                                  */
00076 struct xobject *t1_Unique();  /* make a unique temporary copy of an object    */
00077 struct xobject *t1_ArgErr();  /* handle argument errors                       */
00078 struct xobject *t1_TypeErr(); /* handle 'bad type' argument errors            */
00079 #ifdef KPATHSEA
00080 void t1_Consume PVAR1H(int);  /* consume a variable number of arguments       */
00081 #else
00082 void t1_Consume();            /* consume a variable number of arguments       */
00083 #endif
00084 struct xobject *t1_Copy();    /* make a new copy, not reference bump PNM      */
00085  
00086 /*END SHARED*/
00087 /*SHARED*/
00088  
00089 #define   ON          (~0)   /* all bits on                                  */
00090 #ifndef FALSE
00091 #define   FALSE       0      /* handy zero value                             */
00092 #endif
00093 #ifndef TRUE
00094 #define   TRUE        1      /* handy non-zero value                         */
00095 #endif
00096  
00097 #ifndef   NULL
00098 #define   NULL        0
00099 /*
00100 The NULL pointer is system specific.  (Most systems, however, use 0.)
00101 TYPE1IMAGER could have its own NULL, independent of the rest of the system,
00102 were it not for malloc().  The system call malloc() returns NULL when
00103 out of memory.
00104 :i1/portibility assumptions/
00105 */
00106 #endif
00107  
00108 #ifdef MAX
00109 #undef MAX
00110 #endif
00111 
00112 #ifdef MIN
00113 #undef MIN
00114 #endif
00115 
00116 #ifdef ABS
00117 #undef ABS
00118 #endif
00119 
00120 #define   MIN(a,b)    (((a)<(b)) ? a : b)
00121 #define   MAX(a,b)    (((a)>(b)) ? a : b)
00122 #define   ABS(a)      (((a)>=0)?(a):-(a))
00123  
00124 /*END SHARED*/
00125 /*SHARED*/
00126  
00127 struct xobject {
00128        char type;           /* encoded type of object                         */
00129        unsigned char flag;  /* flag byte for temporary object characteristics */
00130        short references;    /* count of pointers to this object
00131                                (plus 1 for permanent objects) PNM             */
00132 } ;
00133  
00134 /*END SHARED*/
00135 /*SHARED*/
00136  
00137 #define XOBJ_COMMON      char type; unsigned char flag; short references;
00138  
00139 /*END SHARED*/
00140 /*SHARED*/
00141  
00142  
00143 #define   INVALIDTYPE    0
00144 #define   FONTTYPE       1
00145 #define   REGIONTYPE     3
00146 #define   PICTURETYPE    4
00147 #define   SPACETYPE      5
00148 #define   LINESTYLETYPE  6
00149 #define   EDGETYPE       7
00150 #define   STROKEPATHTYPE 8
00151 #define   CLUTTYPE       9
00152  
00153 #define   ISPATHTYPE(type)    ((type)&0x10)  /* all path segments have this bit on */
00154 #define   LINETYPE    (0+ISPATHTYPE(ON))
00155 #define   CONICTYPE   (1+ISPATHTYPE(ON))
00156 #define   BEZIERTYPE  (2+ISPATHTYPE(ON))
00157 #define   HINTTYPE    (3+ISPATHTYPE(ON))
00158  
00159 #define   MOVETYPE    (5+ISPATHTYPE(ON))
00160 #define   TEXTTYPE    (6+ISPATHTYPE(ON))
00161  
00162 /*END SHARED*/
00163 /*SHARED*/
00164  
00165 #define   ISPERMANENT(flag)   ((flag)&0x01)
00166 #define   ISIMMORTAL(flag)    ((flag)&0x02)
00167  
00168 /*END SHARED*/
00169 /*SHARED*/
00170  
00171 #define   PRESERVE(obj)   if (!ISPERMANENT((obj)->flag)) \
00172    (obj)->references++;
00173  
00174 /*END SHARED*/
00175 /*SHARED*/
00176  
00177 #define  LONGCOPY(dest,source,bytes) { \
00178     register LONG *p1 = (LONG *)dest;  register LONG *p2 = (LONG *)source; \
00179     register int count = (bytes) / sizeof(LONG); \
00180     while (--count >= 0) *p1++ = *p2++; }
00181  
00182  
00183 /*END SHARED*/
00184 /*SHARED*/
00185  
00186 #define   FOLLOWING(p)  ((p)+1)
00187  
00188 /*END SHARED*/
00189 /*SHARED*/
00190  
00191 #define  TYPECHECK(name, obj, expect, whenBAD, consumables, rettype) { \
00192     if (obj->type != expect) { \
00193          (Consume)consumables; \
00194          return((rettype)TypeErr(name, obj, expect, whenBAD)); \
00195     } \
00196 }
00197  
00198 /*END SHARED*/
00199 /*SHARED*/
00200  
00201 #define  ARGCHECK(test,msg,obj,whenBAD,consumables,rettype) { \
00202     if (test) { \
00203         (Consume)consumables; \
00204         return((rettype)ArgErr(msg, obj, whenBAD)); \
00205     } \
00206 }
00207  
00208 /*END SHARED*/
00209 /*SHARED*/
00210  
00211 /* Changed use of Dup() below to Temporary(Copy()) because Dup() does not
00212    necessarily return a Unique Copy anymore! 3-26-91 */
00213 #define  TYPENULLCHECK(name, obj, expect, whenBAD, consumables,rettype) \
00214     if (obj == NULL) { \
00215         (Consume)consumables; \
00216         if (whenBAD != NULL && ISPERMANENT(whenBAD->flag)) \
00217               return((rettype)Temporary(Copy(whenBAD))); \
00218         else  return((rettype)whenBAD); \
00219     } else { \
00220         if (obj->type != expect) { \
00221              (Consume)consumables; \
00222              return((rettype)TypeErr(name, obj, expect, whenBAD)); \
00223         } \
00224     }
00225 /*END SHARED*/
00226 /*SHARED*/
00227  
00228 #define  MAKECONSUME(obj,stmt)  { if (!ISPERMANENT(obj->flag)) stmt; }
00229  
00230 /*END SHARED*/
00231 /*SHARED*/
00232  
00233 #define MAKEUNIQUE(obj,stmt) ( ( (obj)->references > 1 ) ? stmt : obj )
00234  
00235 /*END SHARED*/
00236 /*SHARED*/
00237 /* NDW: personally, I want to see status and error messages! */
00238 #define IfTrace0(condition,model)                                 \
00239         {if (condition) printf(model);}
00240 #define IfTrace1(condition,model,arg0)                            \
00241         {if (condition) printf(model,arg0);}
00242 #define IfTrace2(condition,model,arg0,arg1)                       \
00243         {if (condition) printf(model,arg0,arg1);}
00244 #define IfTrace3(condition,model,arg0,arg1,arg2)                  \
00245         {if (condition) printf(model,arg0,arg1,arg2);}
00246 #define IfTrace4(condition,model,arg0,arg1,arg2,arg3)             \
00247         {if (condition) printf(model,arg0,arg1,arg2,arg3);}
00248 #define IfTrace5(condition,model,arg0,arg1,arg2,arg3,arg4)        \
00249         {if (condition) printf(model,arg0,arg1,arg2,arg3,arg4);}
00250 #define IfTrace6(condition,model,arg0,arg1,arg2,arg3,arg4,arg5)   \
00251         {if (condition) printf(model,arg0,arg1,arg2,arg3,arg4,arg5);}
00252 /* NDW: patch ends */
00253  
00254 void Trace0();
00255 char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
00256  
00257 #ifdef GLOBALS
00258  
00259 #define   extern
00260 #define   INITIALIZED(value)      = value
00261  
00262 #else
00263  
00264 #define   INITIALIZED(value)
00265  
00266 #endif
00267  
00268 extern char MustCheckArgs  INITIALIZED(TRUE);
00269 extern char MustTraceCalls INITIALIZED(FALSE);
00270 extern char MustCrash      INITIALIZED(TRUE);
00271 extern char InternalTrace  INITIALIZED(TRUE);
00272 extern char LineIOTrace    INITIALIZED(TRUE);
00273  
00274 extern char ProcessHints   INITIALIZED(TRUE);
00275  
00276 extern char SaveFontPaths  INITIALIZED(TRUE);
00277  
00278 extern short CRASTERCompressionType   INITIALIZED(1);
00279  
00280 extern char ConicDebug     INITIALIZED(0);
00281 extern char LineDebug      INITIALIZED(0);
00282 extern char RegionDebug    INITIALIZED(0);
00283 extern char PathDebug      INITIALIZED(0);
00284 extern char FontDebug      INITIALIZED(0);
00285 extern char SpaceDebug     INITIALIZED(0);
00286 extern char StrokeDebug    INITIALIZED(0);
00287 extern char MemoryDebug    INITIALIZED(0);
00288 extern char HintDebug      INITIALIZED(0);
00289 extern char ImageDebug     INITIALIZED(0);
00290 extern char OffPageDebug   INITIALIZED(0);
00291  
00292 extern short CachedChars   INITIALIZED(0x7FFF);
00293 extern short CachedFonts   INITIALIZED(0x7FFF);
00294 extern int   CacheBLimit   INITIALIZED(12500);
00295 extern char  Continuity    INITIALIZED(2);
00296  
00297 #ifdef extern
00298 #undef extern
00299 #endif
00300  
00301 extern void Xfree(void*);
00302 
00303 /*
00304 We define other routines formatting parameters
00305 */
00306 #define    DumpArea(area)    t1_DumpArea(area)
00307 #define    DumpText(text)    t1_DumpText(text)
00308 #define    DumpPath(path)    t1_DumpPath(path)
00309 #define    DumpSpace(space)  t1_DumpSpace(space)
00310 #define    DumpEdges(e)      t1_DumpEdges(e)
00311 #define    FormatFP(s,p)     t1_FormatFP(s,p)
00312  
00313 void t1_DumpArea();           /* dump a region structure                      */
00314 void t1_DumpText();           /* dump a textpath structure                    */
00315 void t1_DumpPath();           /* dump a path list                             */
00316 void t1_DumpSpace();          /* dump a coordinate space structure            */
00317 void t1_DumpEdges();          /* dump a region's edge list                    */
00318 void t1_FormatFP();           /* dump a format a "fractpel" coordinate        */
00319  
00320 /*END SHARED*/