1 /* $XConsortium: objects.h,v 1.8 94/03/22 19:08:58 gildea Exp $ */
2 /* Copyright International Business Machines, Corp. 1991
3  * All Rights Reserved
4  * Copyright Lexmark International, Inc. 1991
5  * All Rights Reserved
6  *
7  * License to use, copy, modify, and distribute this software and its
8  * documentation for any purpose and without fee is hereby granted,
9  * provided that the above copyright notice appear in all copies and that
10  * both that copyright notice and this permission notice appear in
11  * supporting documentation, and that the name of IBM or Lexmark not be
12  * used in advertising or publicity pertaining to distribution of the
13  * software without specific, written prior permission.
14  *
15  * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
16  * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
17  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
18  * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE
19  * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
20  * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF THE
21  * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
22  * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN NO EVENT SHALL
23  * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
24  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
25  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
26  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
27  * THIS SOFTWARE.
28  */
29 /*SHARED*/
30 
31 /*END SHARED*/
32 /*SHARED*/
33 
34 #define   Permanent(obj)    t1_Permanent(obj)
35 #define   Temporary(obj)    t1_Temporary(obj)
36 #define   Destroy(obj)      t1_Destroy(obj)
37 #define   Dup(obj)          t1_Dup(obj)
38 #define   InitImager()      t1_InitImager()
39 #define   TermImager()      t1_TermImager()
40 #define   Pragmatics(f,v)   t1_Pragmatics(f,v)
41 #define   ErrorMsg()        t1_ErrorMsg()
42 
43 struct xobject *t1_Permanent();  /* make an object permanent                 */
44 struct xobject *t1_Temporary();  /* make an object temporary                 */
45 struct xobject *t1_Destroy();    /* destroy an object                        */
46 struct xobject *t1_Dup();     /* duplicate an object                         */
47 void t1_InitImager();         /* initialize TYPE1IMAGER                      */
48 void t1_TermImager();         /* terminate TYPE1IMAGER                       */
49 void t1_Pragmatics();         /* set debug flags, etc.                       */
50 char *t1_ErrorMsg();          /* return last TYPE1IMAGER error message       */
51 
52 /*END SHARED*/
53 /*SHARED*/
54 
55 #define   abort(line)       FatalError(line)
56 #define   Allocate(n,t,s)   t1_Allocate(n,t,s)
57 #define   Free(obj)         t1_Free(obj)
58 #define   NonObjectFree(a)  xiFree(a)
59 #define   Consume           t1_Consume
60 #define   ArgErr(s,o,r)     t1_ArgErr(s,o,r)
61 #define   TypeErr(n,o,e,r)  t1_TypeErr(n,o,e,r)
62 #define   Copy(obj)         t1_Copy(obj)
63 #define   Unique(obj)       t1_Unique(obj)
64 
65 struct xobject *t1_Allocate();    /* allocate memory                         */
66 void t1_Free();               /* free memory                                 */
67 struct xobject *t1_Unique();  /* make a unique temporary copy of an object   */
68 struct xobject *t1_ArgErr();  /* handle argument errors                      */
69 struct xobject *t1_TypeErr(); /* handle 'bad type' argument errors           */
70 void t1_Consume();            /* consume a variable number of arguments      */
71 struct xobject *t1_Copy();    /* make a new copy, not reference bump PNM     */
72 
73 /*END SHARED*/
74 /*SHARED*/
75 
76 #define   ON          (~0)   /* all bits on                                  */
77 #ifndef FALSE
78 #define   FALSE       0      /* handy zero value                             */
79 #endif
80 #ifndef TRUE
81 #define   TRUE        1      /* handy non-zero value                         */
82 #endif
83 
84 #ifndef   NULL
85 #define   NULL        0
86 /*
87 The NULL pointer is system specific.  (Most systems, however, use 0.)
88 TYPE1IMAGER could have its own NULL, independent of the rest of the system,
89 were it not for malloc().  The system call malloc() returns NULL when
90 out of memory.
91 :i1/portibility assumptions/
92 */
93 #endif
94 
95 #ifndef MIN
96 #define   MIN(a,b)    (((a)<(b)) ? a : b)
97 #endif
98 #ifndef MAX
99 #define   MAX(a,b)    (((a)>(b)) ? a : b)
100 #endif
101 #ifndef ABS
102 #define   ABS(a)      (((a)>=0)?(a):-(a))
103 #endif
104 
105 /*END SHARED*/
106 /*SHARED*/
107 
108 struct xobject {
109        char type;           /* encoded type of object                        */
110        unsigned char flag;  /* flag byte for temporary object characteristics*/
111        short references;    /* count of pointers to this object
112                                (plus 1 for permanent objects) PNM            */
113 } ;
114 
115 /*END SHARED*/
116 /*SHARED*/
117 
118 #define XOBJ_COMMON      char type; unsigned char flag; short references;
119 
120 /*END SHARED*/
121 /*SHARED*/
122 
123 
124 #define   INVALIDTYPE    0
125 #define   FONTTYPE       1
126 #define   REGIONTYPE     3
127 #define   PICTURETYPE    4
128 #define   SPACETYPE      5
129 #define   LINESTYLETYPE  6
130 #define   EDGETYPE       7
131 #define   STROKEPATHTYPE 8
132 #define   CLUTTYPE       9
133 
134 #define   ISPATHTYPE(type)    ((type)&0x10)  /* all path segments have this bit on */
135 #define   LINETYPE    (0+ISPATHTYPE(ON))
136 #define   CONICTYPE   (1+ISPATHTYPE(ON))
137 #define   BEZIERTYPE  (2+ISPATHTYPE(ON))
138 #define   HINTTYPE    (3+ISPATHTYPE(ON))
139 
140 #define   MOVETYPE    (5+ISPATHTYPE(ON))
141 #define   TEXTTYPE    (6+ISPATHTYPE(ON))
142 
143 /*END SHARED*/
144 /*SHARED*/
145 
146 #define   ISPERMANENT(flag)   ((flag)&0x01)
147 #define   ISIMMORTAL(flag)    ((flag)&0x02)
148 
149 /*END SHARED*/
150 /*SHARED*/
151 
152 #define   PRESERVE(obj)   if (!ISPERMANENT((obj)->flag)) \
153    (obj)->references++;
154 
155 /*END SHARED*/
156 /*SHARED*/
157 
158 #define  LONGCOPY(dest,source,bytes) { \
159     register long *p1 = (long *)dest;  register long *p2 = (long *)source; \
160     register int count = (bytes) / sizeof(long); \
161     while (--count >= 0) *p1++ = *p2++; }
162 
163 
164 /*END SHARED*/
165 /*SHARED*/
166 
167 #define   FOLLOWING(p)  ((p)+1)
168 
169 /*END SHARED*/
170 /*SHARED*/
171 
172 #define  TYPECHECK(name, obj, expect, whenBAD, consumables, rettype) { \
173     if (obj->type != expect) { \
174          (Consume)consumables; \
175          return((rettype)TypeErr(name, obj, expect, whenBAD)); \
176     } \
177 }
178 
179 /*END SHARED*/
180 /*SHARED*/
181 
182 #define  ARGCHECK(test,msg,obj,whenBAD,consumables,rettype) { \
183     if (test) { \
184         (Consume)consumables; \
185         return((rettype)ArgErr(msg, obj, whenBAD)); \
186     } \
187 }
188 
189 /*END SHARED*/
190 /*SHARED*/
191 
192 /* Changed use of Dup() below to Temporary(Copy()) because Dup() does not
193    necessarily return a Unique Copy anymore! 3-26-91 */
194 #define  TYPENULLCHECK(name, obj, expect, whenBAD, consumables,rettype) \
195     if (obj == NULL) { \
196         (Consume)consumables; \
197         if (whenBAD != NULL && ISPERMANENT(whenBAD->flag)) \
198               return((rettype)Temporary(Copy(whenBAD))); \
199         else  return((rettype)whenBAD); \
200     } else { \
201         if (obj->type != expect) { \
202              (Consume)consumables; \
203              return((rettype)TypeErr(name, obj, expect, whenBAD)); \
204         } \
205     }
206 /*END SHARED*/
207 /*SHARED*/
208 
209 #define  MAKECONSUME(obj,stmt)  { if (!ISPERMANENT(obj->flag)) stmt; }
210 
211 /*END SHARED*/
212 /*SHARED*/
213 
214 #define MAKEUNIQUE(obj,stmt) ( ( (obj)->references > 1 ) ? stmt : obj )
215 
216 /*END SHARED*/
217 /*SHARED*/
218 #define IfTrace0(condition,model)
219 #define IfTrace1(condition,model,arg0)
220 #define IfTrace2(condition,model,arg0,arg1)
221 #define IfTrace3(condition,model,arg0,arg1,arg2)
222 #define IfTrace4(condition,model,arg0,arg1,arg2,arg3)
223 #define IfTrace5(condition,model,arg0,arg1,arg2,arg3,arg4)
224 #define IfTrace6(condition,model,arg0,arg1,arg2,arg3,arg4,arg5)
225 
226 
227 void Trace0();
228 char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
229 
230 #ifdef GLOBALS
231 
232 #define   extern
233 #define   INITIALIZED(value)      = value
234 
235 #else
236 
237 #define   INITIALIZED(value)
238 
239 #endif
240 
241 extern char MustCheckArgs  INITIALIZED(TRUE);
242 extern char MustTraceCalls INITIALIZED(FALSE);
243 extern char MustCrash      INITIALIZED(TRUE);
244 extern char InternalTrace  INITIALIZED(TRUE);
245 extern char LineIOTrace    INITIALIZED(TRUE);
246 
247 extern char ProcessHints   INITIALIZED(TRUE);
248 
249 extern char SaveFontPaths  INITIALIZED(TRUE);
250 
251 extern short CRASTERCompressionType   INITIALIZED(1);
252 
253 extern char ConicDebug     INITIALIZED(0);
254 extern char LineDebug      INITIALIZED(0);
255 extern char RegionDebug    INITIALIZED(0);
256 extern char PathDebug      INITIALIZED(0);
257 extern char FontDebug      INITIALIZED(0);
258 extern char SpaceDebug     INITIALIZED(0);
259 extern char StrokeDebug    INITIALIZED(0);
260 extern char MemoryDebug    INITIALIZED(0);
261 extern char HintDebug      INITIALIZED(0);
262 extern char ImageDebug     INITIALIZED(0);
263 extern char OffPageDebug   INITIALIZED(0);
264 
265 extern short CachedChars   INITIALIZED(0x7FFF);
266 extern short CachedFonts   INITIALIZED(0x7FFF);
267 extern int   CacheBLimit   INITIALIZED(12500);
268 extern char  Continuity    INITIALIZED(2);
269 
270 #ifdef extern
271 #undef extern
272 #endif
273 
274 /*
275 We define other routines formatting parameters
276 */
277 #define    DumpArea(area)    t1_DumpArea(area)
278 #define    DumpText(text)    t1_DumpText(text)
279 #define    DumpPath(path)    t1_DumpPath(path)
280 #define    DumpSpace(space)  t1_DumpSpace(space)
281 #define    DumpEdges(e)      t1_DumpEdges(e)
282 #define    FormatFP(s,p)     t1_FormatFP(s,p)
283 
284 void t1_DumpArea();           /* dump a region structure                     */
285 void t1_DumpText();           /* dump a textpath structure                   */
286 void t1_DumpPath();           /* dump a path list                            */
287 void t1_DumpSpace();          /* dump a coordinate space structure           */
288 void t1_DumpEdges();          /* dump a region's edge list                   */
289 void t1_FormatFP();           /* dump a format a "fractpel" coordinate       */
290 
291 /*END SHARED*/
292