OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ftdebug.h */ | 3 /* ftdebug.h */ |
4 /* */ | 4 /* */ |
5 /* Debugging and logging component (specification). */ | 5 /* Debugging and logging component (specification). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 1996-2001, 2002, 2004, 2006, 2007, 2008, 2009 by */ | 7 /* Copyright 1996-2002, 2004, 2006-2009, 2013 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 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 */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /* */ | 16 /* */ |
17 /* IMPORTANT: A description of FreeType's debugging support can be */ | 17 /* IMPORTANT: A description of FreeType's debugging support can be */ |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 #else /* !FT_DEBUG_LEVEL_ERROR */ | 179 #else /* !FT_DEBUG_LEVEL_ERROR */ |
180 | 180 |
181 #define FT_ERROR( varformat ) do { } while ( 0 ) /* nothing */ | 181 #define FT_ERROR( varformat ) do { } while ( 0 ) /* nothing */ |
182 | 182 |
183 #endif /* !FT_DEBUG_LEVEL_ERROR */ | 183 #endif /* !FT_DEBUG_LEVEL_ERROR */ |
184 | 184 |
185 | 185 |
186 /*************************************************************************/ | 186 /*************************************************************************/ |
187 /* */ | 187 /* */ |
188 /* Define the FT_ASSERT macro. */ | 188 /* Define the FT_ASSERT and FT_THROW macros. The call to `FT_Throw' */ |
| 189 /* makes it possible to easily set a breakpoint at this function. */ |
189 /* */ | 190 /* */ |
190 /*************************************************************************/ | 191 /*************************************************************************/ |
191 | 192 |
192 #ifdef FT_DEBUG_LEVEL_ERROR | 193 #ifdef FT_DEBUG_LEVEL_ERROR |
193 | 194 |
194 #define FT_ASSERT( condition ) \ | 195 #define FT_ASSERT( condition ) \ |
195 do \ | 196 do \ |
196 { \ | 197 { \ |
197 if ( !( condition ) ) \ | 198 if ( !( condition ) ) \ |
198 FT_Panic( "assertion failed on line %d of file %s\n", \ | 199 FT_Panic( "assertion failed on line %d of file %s\n", \ |
199 __LINE__, __FILE__ ); \ | 200 __LINE__, __FILE__ ); \ |
200 } while ( 0 ) | 201 } while ( 0 ) |
201 | 202 |
| 203 #define FT_THROW( e ) \ |
| 204 ( FT_Throw( FT_ERR_CAT( FT_ERR_PREFIX, e ), \ |
| 205 __LINE__, \ |
| 206 __FILE__ ) | \ |
| 207 FT_ERR_CAT( FT_ERR_PREFIX, e ) ) |
| 208 |
202 #else /* !FT_DEBUG_LEVEL_ERROR */ | 209 #else /* !FT_DEBUG_LEVEL_ERROR */ |
203 | 210 |
204 #define FT_ASSERT( condition ) do { } while ( 0 ) | 211 #define FT_ASSERT( condition ) do { } while ( 0 ) |
205 | 212 |
| 213 #define FT_THROW( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) |
| 214 |
206 #endif /* !FT_DEBUG_LEVEL_ERROR */ | 215 #endif /* !FT_DEBUG_LEVEL_ERROR */ |
207 | 216 |
208 | 217 |
209 /*************************************************************************/ | 218 /*************************************************************************/ |
210 /* */ | 219 /* */ |
211 /* Define `FT_Message' and `FT_Panic' when needed. */ | 220 /* Define `FT_Message' and `FT_Panic' when needed. */ |
212 /* */ | 221 /* */ |
213 /*************************************************************************/ | 222 /*************************************************************************/ |
214 | 223 |
215 #ifdef FT_DEBUG_LEVEL_ERROR | 224 #ifdef FT_DEBUG_LEVEL_ERROR |
216 | 225 |
217 #include "stdio.h" /* for vfprintf() */ | 226 #include "stdio.h" /* for vfprintf() */ |
218 | 227 |
219 /* print a message */ | 228 /* print a message */ |
220 FT_BASE( void ) | 229 FT_BASE( void ) |
221 FT_Message( const char* fmt, | 230 FT_Message( const char* fmt, |
222 ... ); | 231 ... ); |
223 | 232 |
224 /* print a message and exit */ | 233 /* print a message and exit */ |
225 FT_BASE( void ) | 234 FT_BASE( void ) |
226 FT_Panic( const char* fmt, | 235 FT_Panic( const char* fmt, |
227 ... ); | 236 ... ); |
228 | 237 |
| 238 /* report file name and line number of an error */ |
| 239 FT_BASE( int ) |
| 240 FT_Throw( FT_Error error, |
| 241 int line, |
| 242 const char* file ); |
| 243 |
229 #endif /* FT_DEBUG_LEVEL_ERROR */ | 244 #endif /* FT_DEBUG_LEVEL_ERROR */ |
230 | 245 |
231 | 246 |
232 FT_BASE( void ) | 247 FT_BASE( void ) |
233 ft_debug_init( void ); | 248 ft_debug_init( void ); |
234 | 249 |
235 | 250 |
236 #if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ | |
237 | |
238 /* We disable the warning `conditional expression is constant' here */ | |
239 /* in order to compile cleanly with the maximum level of warnings. */ | |
240 #pragma warning( disable : 4127 ) | |
241 | |
242 #endif /* _MSC_VER */ | |
243 | |
244 | |
245 FT_END_HEADER | 251 FT_END_HEADER |
246 | 252 |
247 #endif /* __FTDEBUG_H__ */ | 253 #endif /* __FTDEBUG_H__ */ |
248 | 254 |
249 | 255 |
250 /* END */ | 256 /* END */ |
OLD | NEW |