1
/* $XConsortium: objects.h,v 1.6 92/03/20 14:35:56 keith 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
36
#define Permanent(obj) t1_Permanent(obj)
37
#define Temporary(obj) t1_Temporary(obj)
38
#define Destroy(obj) t1_Destroy(obj)
39
#define Dup(obj) t1_Dup(obj)
40
#define InitImager() t1_InitImager()
41
#define TermImager() t1_TermImager()
42
#define Pragmatics(f,v) t1_Pragmatics(f,v)
43
#define ErrorMsg() t1_ErrorMsg()
45
struct xobject *t1_Permanent(); /* make an object permanent */
46
struct xobject *t1_Temporary(); /* make an object temporary */
47
struct xobject *t1_Destroy(); /* destroy an object */
48
struct xobject *t1_Dup(); /* duplicate an object */
49
void t1_InitImager(); /* initialize TYPE1IMAGER */
50
void t1_TermImager(); /* terminate TYPE1IMAGER */
51
void t1_Pragmatics(); /* set debug flags, etc. */
52
char *t1_ErrorMsg(); /* return last TYPE1IMAGER error message */
57
#define abort(line,no) t1_abort(line,no)
58
#define Allocate(n,t,s) t1_Allocate(n,t,s)
59
#define Free(obj) t1_Free(obj)
60
#define NonObjectFree(a) free(a)
61
#define Consume t1_Consume
62
#define ArgErr(s,o,r) t1_ArgErr(s,o,r)
63
#define TypeErr(n,o,e,r) t1_TypeErr(n,o,e,r)
64
#define Copy(obj) t1_Copy(obj)
65
#define Unique(obj) t1_Unique(obj)
67
void t1_abort(); /* crash; software logic error */
68
struct xobject *t1_Allocate(); /* allocate memory */
69
void t1_Free(); /* free memory */
70
struct xobject *t1_Unique(); /* make a unique temporary copy of an object */
71
struct xobject *t1_ArgErr(); /* handle argument errors */
72
struct xobject *t1_TypeErr(); /* handle 'bad type' argument errors */
73
void t1_Consume(); /* consume a variable number of arguments */
74
struct xobject *t1_Copy(); /* make a new copy, not reference bump PNM */
79
#define ON (~0) /* all bits on */
81
#define FALSE 0 /* handy zero value */
84
#define TRUE 1 /* handy non-zero value */
90
The NULL pointer is system specific. (Most systems, however, use 0.)
91
TYPE1IMAGER could have its own NULL, independent of the rest of the system,
92
were it not for malloc(). The system call malloc() returns NULL when
94
:i1/portibility assumptions/
98
#define TYPE1_MIN(a,b) (((a)<(b)) ? a : b)
99
#define TYPE1_MAX(a,b) (((a)>(b)) ? a : b)
100
#define TYPE1_ABS(a) (((a)>=0)?(a):-(a))
106
char type; /* encoded type of object */
107
unsigned char flag; /* flag byte for temporary object characteristics */
108
short references; /* count of pointers to this object
109
(plus 1 for permanent objects) PNM */
115
#define XOBJ_COMMON char type; unsigned char flag; short references;
121
#define INVALIDTYPE 0
124
#define PICTURETYPE 4
126
#define LINESTYLETYPE 6
128
#define STROKEPATHTYPE 8
131
#define ISPATHTYPE(type) ((type)&0x10) /* all path segments have this bit on */
132
#define LINETYPE (0+ISPATHTYPE(ON))
133
#define CONICTYPE (1+ISPATHTYPE(ON))
134
#define BEZIERTYPE (2+ISPATHTYPE(ON))
135
#define HINTTYPE (3+ISPATHTYPE(ON))
137
#define MOVETYPE (5+ISPATHTYPE(ON))
138
#define TEXTTYPE (6+ISPATHTYPE(ON))
143
#define ISPERMANENT(flag) ((flag)&0x01)
144
#define ISIMMORTAL(flag) ((flag)&0x02)
149
#define PRESERVE(obj) if (!ISPERMANENT((obj)->flag)) \
155
#define LONGCOPY(dest,source,bytes) { \
156
register LONG *p1 = (LONG *)dest; register LONG *p2 = (LONG *)source; \
157
register int count = (bytes) / sizeof(LONG); \
158
while (--count >= 0) *p1++ = *p2++; }
164
#define FOLLOWING(p) ((p)+1)
169
#define TYPECHECK(name, obj, expect, whenBAD, consumables, rettype) { \
170
if (obj->type != expect) { \
171
(Consume)consumables; \
172
return((rettype)TypeErr(name, obj, expect, whenBAD)); \
179
#define ARGCHECK(test,msg,obj,whenBAD,consumables,rettype) { \
181
(Consume)consumables; \
182
return((rettype)ArgErr(msg, obj, whenBAD)); \
189
/* Changed use of Dup() below to Temporary(Copy()) because Dup() does not
190
necessarily return a Unique Copy anymore! 3-26-91 */
191
#define TYPENULLCHECK(name, obj, expect, whenBAD, consumables,rettype) \
193
(Consume)consumables; \
194
if (whenBAD != NULL && ISPERMANENT(whenBAD->flag)) \
195
return((rettype)Temporary(Copy(whenBAD))); \
196
else return((rettype)whenBAD); \
198
if (obj->type != expect) { \
199
(Consume)consumables; \
200
return((rettype)TypeErr(name, obj, expect, whenBAD)); \
206
#define MAKECONSUME(obj,stmt) { if (!ISPERMANENT(obj->flag)) stmt; }
211
#define MAKEUNIQUE(obj,stmt) ( ( (obj)->references > 1 ) ? stmt : obj )
215
/* NDW: personally, I want to see status and error messages! */
216
#define IfTrace0(condition,model) \
217
{if (condition) printf(model);}
218
#define IfTrace1(condition,model,arg0) \
219
{if (condition) printf(model,arg0);}
220
#define IfTrace2(condition,model,arg0,arg1) \
221
{if (condition) printf(model,arg0,arg1);}
222
#define IfTrace3(condition,model,arg0,arg1,arg2) \
223
{if (condition) printf(model,arg0,arg1,arg2);}
224
#define IfTrace4(condition,model,arg0,arg1,arg2,arg3) \
225
{if (condition) printf(model,arg0,arg1,arg2,arg3);}
226
#define IfTrace5(condition,model,arg0,arg1,arg2,arg3,arg4) \
227
{if (condition) printf(model,arg0,arg1,arg2,arg3,arg4);}
228
#define IfTrace6(condition,model,arg0,arg1,arg2,arg3,arg4,arg5) \
229
{if (condition) printf(model,arg0,arg1,arg2,arg3,arg4,arg5);}
230
/* NDW: patch ends */
233
char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
238
#define INITIALIZED(value) = value
242
#define INITIALIZED(value)
246
extern char MustCheckArgs INITIALIZED(TRUE);
247
extern char MustTraceCalls INITIALIZED(FALSE);
248
extern char MustCrash INITIALIZED(TRUE);
249
extern char InternalTrace INITIALIZED(TRUE);
250
extern char LineIOTrace INITIALIZED(TRUE);
252
extern char ProcessHints INITIALIZED(TRUE);
254
extern char SaveFontPaths INITIALIZED(TRUE);
256
extern short CRASTERCompressionType INITIALIZED(1);
258
extern char ConicDebug INITIALIZED(0);
259
extern char LineDebug INITIALIZED(0);
260
extern char RegionDebug INITIALIZED(0);
261
extern char PathDebug INITIALIZED(0);
262
extern char FontDebug INITIALIZED(0);
263
extern char SpaceDebug INITIALIZED(0);
264
extern char StrokeDebug INITIALIZED(0);
265
extern char MemoryDebug INITIALIZED(0);
266
extern char HintDebug INITIALIZED(0);
267
extern char ImageDebug INITIALIZED(0);
268
extern char OffPageDebug INITIALIZED(0);
270
extern short CachedChars INITIALIZED(0x7FFF);
271
extern short CachedFonts INITIALIZED(0x7FFF);
272
extern int CacheBLimit INITIALIZED(12500);
273
extern char Continuity INITIALIZED(2);
280
We define other routines formatting parameters
282
#define DumpArea(area) t1_DumpArea(area)
283
#define DumpText(text) t1_DumpText(text)
284
/* #define DumpPath(path) t1_DumpPath(path) */ /* commented by RMz, 1999-06-10 */
285
#define DumpSpace(space) t1_DumpSpace(space)
286
#define DumpEdges(e) t1_DumpEdges(e)
287
#define FormatFP(s,p) t1_FormatFP(s,p)
289
void t1_DumpArea(); /* dump a region structure */
290
void t1_DumpText(); /* dump a textpath structure */
291
void t1_DumpPath(); /* dump a path list */
292
void t1_DumpSpace(); /* dump a coordinate space structure */
293
void t1_DumpEdges(); /* dump a region's edge list */
294
void t1_FormatFP(); /* dump a format a "fractpel" coordinate */