1 /* $XConsortium: objects.h,v 1.8 94/03/22 19:08:58 gildea Exp $ */
2 /* Copyright International Business Machines, Corp. 1991
4 * Copyright Lexmark International, Inc. 1991
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.
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
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()
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 */
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)
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 */
76 #define ON (~0) /* all bits on */
78 #define FALSE 0 /* handy zero value */
81 #define TRUE 1 /* handy non-zero value */
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
91 :i1/portibility assumptions/
96 #define MIN(a,b) (((a)<(b)) ? a : b)
99 #define MAX(a,b) (((a)>(b)) ? a : b)
102 #define ABS(a) (((a)>=0)?(a):-(a))
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 */
118 #define XOBJ_COMMON char type; unsigned char flag; short references;
124 #define INVALIDTYPE 0
127 #define PICTURETYPE 4
129 #define LINESTYLETYPE 6
131 #define STROKEPATHTYPE 8
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))
140 #define MOVETYPE (5+ISPATHTYPE(ON))
141 #define TEXTTYPE (6+ISPATHTYPE(ON))
146 #define ISPERMANENT(flag) ((flag)&0x01)
147 #define ISIMMORTAL(flag) ((flag)&0x02)
152 #define PRESERVE(obj) if (!ISPERMANENT((obj)->flag)) \
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++; }
167 #define FOLLOWING(p) ((p)+1)
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)); \
182 #define ARGCHECK(test,msg,obj,whenBAD,consumables,rettype) { \
184 (Consume)consumables; \
185 return((rettype)ArgErr(msg, obj, whenBAD)); \
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) \
196 (Consume)consumables; \
197 if (whenBAD != NULL && ISPERMANENT(whenBAD->flag)) \
198 return((rettype)Temporary(Copy(whenBAD))); \
199 else return((rettype)whenBAD); \
201 if (obj->type != expect) { \
202 (Consume)consumables; \
203 return((rettype)TypeErr(name, obj, expect, whenBAD)); \
209 #define MAKECONSUME(obj,stmt) { if (!ISPERMANENT(obj->flag)) stmt; }
214 #define MAKEUNIQUE(obj,stmt) ( ( (obj)->references > 1 ) ? stmt : obj )
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)
228 char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
233 #define INITIALIZED(value) = value
237 #define INITIALIZED(value)
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);
247 extern char ProcessHints INITIALIZED(TRUE);
249 extern char SaveFontPaths INITIALIZED(TRUE);
251 extern short CRASTERCompressionType INITIALIZED(1);
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);
265 extern short CachedChars INITIALIZED(0x7FFF);
266 extern short CachedFonts INITIALIZED(0x7FFF);
267 extern int CacheBLimit INITIALIZED(12500);
268 extern char Continuity INITIALIZED(2);
275 We define other routines formatting parameters
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)
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 */