[692] | 1 | /***************************************************************************/
|
---|
| 2 | /* */
|
---|
| 3 | /* ftdebug.h */
|
---|
| 4 | /* */
|
---|
| 5 | /* Debugging and logging component (specification). */
|
---|
| 6 | /* */
|
---|
| 7 | /* Copyright 1996-2001, 2002, 2004 by */
|
---|
| 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
---|
| 9 | /* */
|
---|
| 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. */
|
---|
| 15 | /* */
|
---|
| 16 | /* */
|
---|
| 17 | /* IMPORTANT: A description of FreeType's debugging support can be */
|
---|
| 18 | /* found in "docs/DEBUG.TXT". Read it if you need to use or */
|
---|
| 19 | /* understand this code. */
|
---|
| 20 | /* */
|
---|
| 21 | /***************************************************************************/
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | #ifndef __FTDEBUG_H__
|
---|
| 25 | #define __FTDEBUG_H__
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | #include <ft2build.h>
|
---|
| 29 | #include FT_CONFIG_CONFIG_H
|
---|
| 30 | #include FT_FREETYPE_H
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | FT_BEGIN_HEADER
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | /* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */
|
---|
| 37 | /* is already defined; this simplifies the following #ifdefs */
|
---|
| 38 | /* */
|
---|
| 39 | #ifdef FT_DEBUG_LEVEL_TRACE
|
---|
| 40 | #undef FT_DEBUG_LEVEL_ERROR
|
---|
| 41 | #define FT_DEBUG_LEVEL_ERROR
|
---|
| 42 | #endif
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | /*************************************************************************/
|
---|
| 46 | /* */
|
---|
| 47 | /* Define the trace enums as well as the trace levels array when they */
|
---|
| 48 | /* are needed. */
|
---|
| 49 | /* */
|
---|
| 50 | /*************************************************************************/
|
---|
| 51 |
|
---|
| 52 | #ifdef FT_DEBUG_LEVEL_TRACE
|
---|
| 53 |
|
---|
| 54 | #define FT_TRACE_DEF( x ) trace_ ## x ,
|
---|
| 55 |
|
---|
| 56 | /* defining the enumeration */
|
---|
| 57 | typedef enum
|
---|
| 58 | {
|
---|
| 59 | #include FT_INTERNAL_TRACE_H
|
---|
| 60 | trace_count
|
---|
| 61 |
|
---|
| 62 | } FT_Trace;
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | /* defining the array of trace levels, provided by `src/base/ftdebug.c' */
|
---|
| 66 | extern int ft_trace_levels[trace_count];
|
---|
| 67 |
|
---|
| 68 | #undef FT_TRACE_DEF
|
---|
| 69 |
|
---|
| 70 | #endif /* FT_DEBUG_LEVEL_TRACE */
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | /*************************************************************************/
|
---|
| 74 | /* */
|
---|
| 75 | /* Define the FT_TRACE macro */
|
---|
| 76 | /* */
|
---|
| 77 | /* IMPORTANT! */
|
---|
| 78 | /* */
|
---|
| 79 | /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */
|
---|
| 80 | /* value before using any TRACE macro. */
|
---|
| 81 | /* */
|
---|
| 82 | /*************************************************************************/
|
---|
| 83 |
|
---|
| 84 | #ifdef FT_DEBUG_LEVEL_TRACE
|
---|
| 85 |
|
---|
| 86 | #define FT_TRACE( level, varformat ) \
|
---|
| 87 | do \
|
---|
| 88 | { \
|
---|
| 89 | if ( ft_trace_levels[FT_COMPONENT] >= level ) \
|
---|
| 90 | FT_Message varformat; \
|
---|
| 91 | } while ( 0 )
|
---|
| 92 |
|
---|
| 93 | #else /* !FT_DEBUG_LEVEL_TRACE */
|
---|
| 94 |
|
---|
| 95 | #define FT_TRACE( level, varformat ) do ; while ( 0 ) /* nothing */
|
---|
| 96 |
|
---|
| 97 | #endif /* !FT_DEBUG_LEVEL_TRACE */
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | /*************************************************************************/
|
---|
| 101 | /* */
|
---|
| 102 | /* <Function> */
|
---|
| 103 | /* FT_Trace_Get_Count */
|
---|
| 104 | /* */
|
---|
| 105 | /* <Description> */
|
---|
| 106 | /* Return the number of available trace components. */
|
---|
| 107 | /* */
|
---|
| 108 | /* <Return> */
|
---|
| 109 | /* The number of trace components. 0 if FreeType 2 is not built with */
|
---|
| 110 | /* FT_DEBUG_LEVEL_TRACE definition. */
|
---|
| 111 | /* */
|
---|
| 112 | /* <Note> */
|
---|
| 113 | /* This function may be useful if you want to access elements of */
|
---|
| 114 | /* the internal `ft_trace_levels' array by an index. */
|
---|
| 115 | /* */
|
---|
| 116 | FT_EXPORT( FT_Int )
|
---|
| 117 | FT_Trace_Get_Count( void );
|
---|
| 118 |
|
---|
| 119 |
|
---|
| 120 | /*************************************************************************/
|
---|
| 121 | /* */
|
---|
| 122 | /* <Function> */
|
---|
| 123 | /* FT_Trace_Get_Name */
|
---|
| 124 | /* */
|
---|
| 125 | /* <Description> */
|
---|
| 126 | /* Return the name of a trace component. */
|
---|
| 127 | /* */
|
---|
| 128 | /* <Input> */
|
---|
| 129 | /* The index of the trace component. */
|
---|
| 130 | /* */
|
---|
| 131 | /* <Return> */
|
---|
| 132 | /* The name of the trace component. This is a statically allocated */
|
---|
| 133 | /* C string, so do not free it after use. NULL if FreeType 2 is not */
|
---|
| 134 | /* built with FT_DEBUG_LEVEL_TRACE definition. */
|
---|
| 135 | /* */
|
---|
| 136 | /* <Note> */
|
---|
| 137 | /* Use @FT_Trace_Get_Count to get the number of available trace */
|
---|
| 138 | /* components. */
|
---|
| 139 | /* */
|
---|
| 140 | /* This function may be useful if you want to control FreeType 2's */
|
---|
| 141 | /* debug level in your appliaciton. */
|
---|
| 142 | /* */
|
---|
| 143 | FT_EXPORT( const char * )
|
---|
| 144 | FT_Trace_Get_Name( FT_Int idx );
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | /*************************************************************************/
|
---|
| 148 | /* */
|
---|
| 149 | /* You need two opening resp. closing parentheses! */
|
---|
| 150 | /* */
|
---|
| 151 | /* Example: FT_TRACE0(( "Value is %i", foo )) */
|
---|
| 152 | /* */
|
---|
| 153 | /*************************************************************************/
|
---|
| 154 |
|
---|
| 155 | #define FT_TRACE0( varformat ) FT_TRACE( 0, varformat )
|
---|
| 156 | #define FT_TRACE1( varformat ) FT_TRACE( 1, varformat )
|
---|
| 157 | #define FT_TRACE2( varformat ) FT_TRACE( 2, varformat )
|
---|
| 158 | #define FT_TRACE3( varformat ) FT_TRACE( 3, varformat )
|
---|
| 159 | #define FT_TRACE4( varformat ) FT_TRACE( 4, varformat )
|
---|
| 160 | #define FT_TRACE5( varformat ) FT_TRACE( 5, varformat )
|
---|
| 161 | #define FT_TRACE6( varformat ) FT_TRACE( 6, varformat )
|
---|
| 162 | #define FT_TRACE7( varformat ) FT_TRACE( 7, varformat )
|
---|
| 163 |
|
---|
| 164 |
|
---|
| 165 | /*************************************************************************/
|
---|
| 166 | /* */
|
---|
| 167 | /* Define the FT_ERROR macro */
|
---|
| 168 | /* */
|
---|
| 169 | /*************************************************************************/
|
---|
| 170 |
|
---|
| 171 | #ifdef FT_DEBUG_LEVEL_ERROR
|
---|
| 172 |
|
---|
| 173 | #define FT_ERROR( varformat ) FT_Message varformat
|
---|
| 174 |
|
---|
| 175 | #else /* !FT_DEBUG_LEVEL_ERROR */
|
---|
| 176 |
|
---|
| 177 | #define FT_ERROR( varformat ) do ; while ( 0 ) /* nothing */
|
---|
| 178 |
|
---|
| 179 | #endif /* !FT_DEBUG_LEVEL_ERROR */
|
---|
| 180 |
|
---|
| 181 |
|
---|
| 182 | /*************************************************************************/
|
---|
| 183 | /* */
|
---|
| 184 | /* Define the FT_ASSERT macro */
|
---|
| 185 | /* */
|
---|
| 186 | /*************************************************************************/
|
---|
| 187 |
|
---|
| 188 | #ifdef FT_DEBUG_LEVEL_ERROR
|
---|
| 189 |
|
---|
| 190 | #define FT_ASSERT( condition ) \
|
---|
| 191 | do \
|
---|
| 192 | { \
|
---|
| 193 | if ( !( condition ) ) \
|
---|
| 194 | FT_Panic( "assertion failed on line %d of file %s\n", \
|
---|
| 195 | __LINE__, __FILE__ ); \
|
---|
| 196 | } while ( 0 )
|
---|
| 197 |
|
---|
| 198 | #else /* !FT_DEBUG_LEVEL_ERROR */
|
---|
| 199 |
|
---|
| 200 | #define FT_ASSERT( condition ) do ; while ( 0 )
|
---|
| 201 |
|
---|
| 202 | #endif /* !FT_DEBUG_LEVEL_ERROR */
|
---|
| 203 |
|
---|
| 204 |
|
---|
| 205 | /*************************************************************************/
|
---|
| 206 | /* */
|
---|
| 207 | /* Define 'FT_Message' and 'FT_Panic' when needed */
|
---|
| 208 | /* */
|
---|
| 209 | /*************************************************************************/
|
---|
| 210 |
|
---|
| 211 | #ifdef FT_DEBUG_LEVEL_ERROR
|
---|
| 212 |
|
---|
| 213 | #include "stdio.h" /* for vprintf() */
|
---|
| 214 |
|
---|
| 215 | /* print a message */
|
---|
| 216 | FT_EXPORT( void )
|
---|
| 217 | FT_Message( const char* fmt, ... );
|
---|
| 218 |
|
---|
| 219 | /* print a message and exit */
|
---|
| 220 | FT_EXPORT( void )
|
---|
| 221 | FT_Panic( const char* fmt, ... );
|
---|
| 222 |
|
---|
| 223 | #endif /* FT_DEBUG_LEVEL_ERROR */
|
---|
| 224 |
|
---|
| 225 |
|
---|
| 226 | FT_BASE( void )
|
---|
| 227 | ft_debug_init( void );
|
---|
| 228 |
|
---|
| 229 |
|
---|
| 230 | #if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
|
---|
| 231 |
|
---|
| 232 | /* we disable the warning `conditional expression is constant' here */
|
---|
| 233 | /* in order to compile cleanly with the maximum level of warnings */
|
---|
| 234 | #pragma warning( disable : 4127 )
|
---|
| 235 |
|
---|
| 236 | #endif /* _MSC_VER */
|
---|
| 237 |
|
---|
| 238 |
|
---|
| 239 | FT_END_HEADER
|
---|
| 240 |
|
---|
| 241 | #endif /* __FTDEBUG_H__ */
|
---|
| 242 |
|
---|
| 243 |
|
---|
| 244 | /* END */
|
---|