ftdebug.h

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  ftdebug.h                                                              */
00004 /*                                                                         */
00005 /*    Debugging and logging component (specification).                     */
00006 /*                                                                         */
00007 /*  Copyright 1996-2001, 2002, 2004, 2006, 2007, 2008, 2009 by             */
00008 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
00009 /*                                                                         */
00010 /*  This file is part of the FreeType project, and may only be used,       */
00011 /*  modified, and distributed under the terms of the FreeType project      */
00012 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00013 /*  this file you indicate that you have read the license and              */
00014 /*  understand and accept it fully.                                        */
00015 /*                                                                         */
00016 /*                                                                         */
00017 /*  IMPORTANT: A description of FreeType's debugging support can be        */
00018 /*             found in `docs/DEBUG.TXT'.  Read it if you need to use or   */
00019 /*             understand this code.                                       */
00020 /*                                                                         */
00021 /***************************************************************************/
00022 
00023 
00024 #ifndef __FTDEBUG_H__
00025 #define __FTDEBUG_H__
00026 
00027 
00028 #include <ft2build.h>
00029 #include FT_CONFIG_CONFIG_H
00030 #include FT_FREETYPE_H
00031 
00032 
00033 FT_BEGIN_HEADER
00034 
00035 
00036   /* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */
00037   /* is already defined; this simplifies the following #ifdefs            */
00038   /*                                                                      */
00039 #ifdef FT_DEBUG_LEVEL_TRACE
00040 #undef  FT_DEBUG_LEVEL_ERROR
00041 #define FT_DEBUG_LEVEL_ERROR
00042 #endif
00043 
00044 
00045   /*************************************************************************/
00046   /*                                                                       */
00047   /* Define the trace enums as well as the trace levels array when they    */
00048   /* are needed.                                                           */
00049   /*                                                                       */
00050   /*************************************************************************/
00051 
00052 #ifdef FT_DEBUG_LEVEL_TRACE
00053 
00054 #define FT_TRACE_DEF( x )  trace_ ## x ,
00055 
00056   /* defining the enumeration */
00057   typedef enum  FT_Trace_
00058   {
00059 #include FT_INTERNAL_TRACE_H
00060     trace_count
00061 
00062   } FT_Trace;
00063 
00064 
00065   /* defining the array of trace levels, provided by `src/base/ftdebug.c' */
00066   extern int  ft_trace_levels[trace_count];
00067 
00068 #undef FT_TRACE_DEF
00069 
00070 #endif /* FT_DEBUG_LEVEL_TRACE */
00071 
00072 
00073   /*************************************************************************/
00074   /*                                                                       */
00075   /* Define the FT_TRACE macro                                             */
00076   /*                                                                       */
00077   /* IMPORTANT!                                                            */
00078   /*                                                                       */
00079   /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */
00080   /* value before using any TRACE macro.                                   */
00081   /*                                                                       */
00082   /*************************************************************************/
00083 
00084 #ifdef FT_DEBUG_LEVEL_TRACE
00085 
00086 #define FT_TRACE( level, varformat )                      \
00087           do                                              \
00088           {                                               \
00089             if ( ft_trace_levels[FT_COMPONENT] >= level ) \
00090               FT_Message varformat;                       \
00091           } while ( 0 )
00092 
00093 #else /* !FT_DEBUG_LEVEL_TRACE */
00094 
00095 #define FT_TRACE( level, varformat )  do { } while ( 0 )      /* nothing */
00096 
00097 #endif /* !FT_DEBUG_LEVEL_TRACE */
00098 
00099 
00100   /*************************************************************************/
00101   /*                                                                       */
00102   /* <Function>                                                            */
00103   /*    FT_Trace_Get_Count                                                 */
00104   /*                                                                       */
00105   /* <Description>                                                         */
00106   /*    Return the number of available trace components.                   */
00107   /*                                                                       */
00108   /* <Return>                                                              */
00109   /*    The number of trace components.  0 if FreeType 2 is not built with */
00110   /*    FT_DEBUG_LEVEL_TRACE definition.                                   */
00111   /*                                                                       */
00112   /* <Note>                                                                */
00113   /*    This function may be useful if you want to access elements of      */
00114   /*    the internal `ft_trace_levels' array by an index.                  */
00115   /*                                                                       */
00116   FT_BASE( FT_Int )
00117   FT_Trace_Get_Count( void );
00118 
00119 
00120   /*************************************************************************/
00121   /*                                                                       */
00122   /* <Function>                                                            */
00123   /*    FT_Trace_Get_Name                                                  */
00124   /*                                                                       */
00125   /* <Description>                                                         */
00126   /*    Return the name of a trace component.                              */
00127   /*                                                                       */
00128   /* <Input>                                                               */
00129   /*    The index of the trace component.                                  */
00130   /*                                                                       */
00131   /* <Return>                                                              */
00132   /*    The name of the trace component.  This is a statically allocated   */
00133   /*    C string, so do not free it after use.  NULL if FreeType 2 is not  */
00134   /*    built with FT_DEBUG_LEVEL_TRACE definition.                        */
00135   /*                                                                       */
00136   /* <Note>                                                                */
00137   /*    Use @FT_Trace_Get_Count to get the number of available trace       */
00138   /*    components.                                                        */
00139   /*                                                                       */
00140   /*    This function may be useful if you want to control FreeType 2's    */
00141   /*    debug level in your application.                                   */
00142   /*                                                                       */
00143   FT_BASE( const char * )
00144   FT_Trace_Get_Name( FT_Int  idx );
00145 
00146 
00147   /*************************************************************************/
00148   /*                                                                       */
00149   /* You need two opening and closing parentheses!                         */
00150   /*                                                                       */
00151   /* Example: FT_TRACE0(( "Value is %i", foo ))                            */
00152   /*                                                                       */
00153   /* Output of the FT_TRACEX macros is sent to stderr.                     */
00154   /*                                                                       */
00155   /*************************************************************************/
00156 
00157 #define FT_TRACE0( varformat )  FT_TRACE( 0, varformat )
00158 #define FT_TRACE1( varformat )  FT_TRACE( 1, varformat )
00159 #define FT_TRACE2( varformat )  FT_TRACE( 2, varformat )
00160 #define FT_TRACE3( varformat )  FT_TRACE( 3, varformat )
00161 #define FT_TRACE4( varformat )  FT_TRACE( 4, varformat )
00162 #define FT_TRACE5( varformat )  FT_TRACE( 5, varformat )
00163 #define FT_TRACE6( varformat )  FT_TRACE( 6, varformat )
00164 #define FT_TRACE7( varformat )  FT_TRACE( 7, varformat )
00165 
00166 
00167   /*************************************************************************/
00168   /*                                                                       */
00169   /* Define the FT_ERROR macro.                                            */
00170   /*                                                                       */
00171   /* Output of this macro is sent to stderr.                               */
00172   /*                                                                       */
00173   /*************************************************************************/
00174 
00175 #ifdef FT_DEBUG_LEVEL_ERROR
00176 
00177 #define FT_ERROR( varformat )  FT_Message  varformat
00178 
00179 #else  /* !FT_DEBUG_LEVEL_ERROR */
00180 
00181 #define FT_ERROR( varformat )  do { } while ( 0 )      /* nothing */
00182 
00183 #endif /* !FT_DEBUG_LEVEL_ERROR */
00184 
00185 
00186   /*************************************************************************/
00187   /*                                                                       */
00188   /* Define the FT_ASSERT macro.                                           */
00189   /*                                                                       */
00190   /*************************************************************************/
00191 
00192 #ifdef FT_DEBUG_LEVEL_ERROR
00193 
00194 #define FT_ASSERT( condition )                                      \
00195           do                                                        \
00196           {                                                         \
00197             if ( !( condition ) )                                   \
00198               FT_Panic( "assertion failed on line %d of file %s\n", \
00199                         __LINE__, __FILE__ );                       \
00200           } while ( 0 )
00201 
00202 #else /* !FT_DEBUG_LEVEL_ERROR */
00203 
00204 #define FT_ASSERT( condition )  do { } while ( 0 )
00205 
00206 #endif /* !FT_DEBUG_LEVEL_ERROR */
00207 
00208 
00209   /*************************************************************************/
00210   /*                                                                       */
00211   /* Define `FT_Message' and `FT_Panic' when needed.                       */
00212   /*                                                                       */
00213   /*************************************************************************/
00214 
00215 #ifdef FT_DEBUG_LEVEL_ERROR
00216 
00217 #include "stdio.h"  /* for vfprintf() */
00218 
00219   /* print a message */
00220   FT_BASE( void )
00221   FT_Message( const char*  fmt,
00222               ... );
00223 
00224   /* print a message and exit */
00225   FT_BASE( void )
00226   FT_Panic( const char*  fmt,
00227             ... );
00228 
00229 #endif /* FT_DEBUG_LEVEL_ERROR */
00230 
00231 
00232   FT_BASE( void )
00233   ft_debug_init( void );
00234 
00235 
00236 #if defined( _MSC_VER )      /* Visual C++ (and Intel C++) */
00237 
00238   /* We disable the warning `conditional expression is constant' here */
00239   /* in order to compile cleanly with the maximum level of warnings.  */
00240 #pragma warning( disable : 4127 )
00241 
00242 #endif /* _MSC_VER */
00243 
00244 
00245 FT_END_HEADER
00246 
00247 #endif /* __FTDEBUG_H__ */
00248 
00249 
00250 /* END */

Generated on Tue Jul 5 14:13:38 2011 for ROOT_528-00b_version by  doxygen 1.5.1