1 /***************************************************************************/
5 /* Debugging and logging component (specification). */
7 /* Copyright 1996-2001 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
24 #include FT_CONFIG_CONFIG_H
30 #ifdef FT_DEBUG_LEVEL_TRACE
33 /* note that not all levels are used currently */
35 typedef enum FT_Trace_
37 /* the first level must always be `trace_any' */
41 trace_aaraster, /* anti-aliasing raster (ftgrays.c) */
42 trace_calc, /* calculations (ftcalc.c) */
43 trace_extend, /* extension manager (ftextend.c) */
44 trace_glyph, /* glyph manager (ftglyph.c) */
45 trace_io, /* i/o monitoring (ftsystem.c) */
46 trace_init, /* initialization (ftinit.c) */
47 trace_list, /* list manager (ftlist.c) */
48 trace_memory, /* memory manager (ftobjs.c) */
49 trace_mm, /* MM interface (ftmm.c) */
50 trace_objs, /* base objects (ftobjs.c) */
51 trace_outline, /* outline management (ftoutln.c) */
52 trace_raster, /* rasterizer (ftraster.c) */
53 trace_stream, /* stream manager (ftstream.c) */
55 /* Cache sub-system */
58 /* SFNT driver components */
59 trace_sfobjs, /* SFNT object handler (sfobjs.c) */
60 trace_ttcmap, /* charmap handler (ttcmap.c) */
61 trace_ttload, /* basic TrueType tables (ttload.c) */
62 trace_ttpost, /* PS table processing (ttpost.c) */
63 trace_ttsbit, /* TrueType sbit handling (ttsbit.c) */
65 /* TrueType driver components */
66 trace_ttdriver, /* TT font driver (ttdriver.c) */
67 trace_ttgload, /* TT glyph loader (ttgload.c) */
68 trace_ttinterp, /* bytecode interpreter (ttinterp.c) */
69 trace_ttobjs, /* TT objects manager (ttobjs.c) */
70 trace_ttpload, /* TT data/program loader (ttpload.c) */
72 /* Type 1 driver components */
80 /* PostScript helper module `psaux' */
84 /* Type 2 driver components */
91 /* CID driver components */
99 /* Windows fonts component */
102 /* PCF fonts component */
106 /* the last level must always be `trace_max' */
112 /* declared in ftdebug.c */
113 extern char ft_trace_levels[trace_max];
116 /*************************************************************************/
120 /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */
121 /* value before using any TRACE macro. */
123 /*************************************************************************/
126 #define FT_TRACE( level, varformat ) \
129 if ( ft_trace_levels[FT_COMPONENT] >= level ) \
130 FT_Message varformat; \
134 /*************************************************************************/
137 /* FT_SetTraceLevel */
140 /* Sets the trace level for debugging. */
143 /* component :: The component which should be traced. See above for */
144 /* a complete list. If set to `trace_any', all */
145 /* components will be traced. */
147 /* level :: The tracing level. */
150 FT_SetTraceLevel( FT_Trace component,
154 #elif defined( FT_DEBUG_LEVEL_ERROR )
157 #define FT_TRACE( level, varformat ) do ; while ( 0 ) /* nothing */
160 #else /* release mode */
163 #define FT_Assert( condition ) do ; while ( 0 ) /* nothing */
165 #define FT_TRACE( level, varformat ) do ; while ( 0 ) /* nothing */
166 #define FT_ERROR( varformat ) do ; while ( 0 ) /* nothing */
169 #endif /* FT_DEBUG_LEVEL_TRACE, FT_DEBUG_LEVEL_ERROR */
172 /*************************************************************************/
174 /* Define macros and functions that are common to the debug and trace */
177 /* You need vprintf() to be able to compile ftdebug.c. */
179 /*************************************************************************/
182 #if defined( FT_DEBUG_LEVEL_TRACE ) || defined( FT_DEBUG_LEVEL_ERROR )
185 #include "stdio.h" /* for vprintf() */
188 #define FT_Assert( condition ) \
191 if ( !( condition ) ) \
192 FT_Panic( "assertion failed on line %d of file %s\n", \
193 __LINE__, __FILE__ ); \
196 /* print a message */
198 FT_Message( const char* fmt, ... );
200 /* print a message and exit */
202 FT_Panic( const char* fmt, ... );
204 #define FT_ERROR( varformat ) FT_Message varformat
207 #endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
210 /*************************************************************************/
212 /* You need two opening resp. closing parentheses! */
214 /* Example: FT_TRACE0(( "Value is %i", foo )) */
216 /*************************************************************************/
218 #define FT_TRACE0( varformat ) FT_TRACE( 0, varformat )
219 #define FT_TRACE1( varformat ) FT_TRACE( 1, varformat )
220 #define FT_TRACE2( varformat ) FT_TRACE( 2, varformat )
221 #define FT_TRACE3( varformat ) FT_TRACE( 3, varformat )
222 #define FT_TRACE4( varformat ) FT_TRACE( 4, varformat )
223 #define FT_TRACE5( varformat ) FT_TRACE( 5, varformat )
224 #define FT_TRACE6( varformat ) FT_TRACE( 6, varformat )
225 #define FT_TRACE7( varformat ) FT_TRACE( 7, varformat )
228 #if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
230 /* we disable the warning `conditional expression is constant' here */
231 /* in order to compile cleanly with the maximum level of warnings */
232 #pragma warning( disable : 4127 )
234 #endif /* _MSC_VER */
239 #endif /* __FTDEBUG_H__ */