ftdebug.h
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:11k
源码类别:

其他游戏

开发平台:

Visual C++

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /*  ftdebug.h                                                              */
  4. /*                                                                         */
  5. /*    Debugging and logging component (specification).                     */
  6. /*                                                                         */
  7. /*  Copyright 1996-2001, 2002, 2004, 2006, 2007 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. #ifndef __FTDEBUG_H__
  23. #define __FTDEBUG_H__
  24. #include <ft2build.h>
  25. #include FT_CONFIG_CONFIG_H
  26. #include FT_FREETYPE_H
  27. FT_BEGIN_HEADER
  28.   /* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */
  29.   /* is already defined; this simplifies the following #ifdefs            */
  30.   /*                                                                      */
  31. #ifdef FT_DEBUG_LEVEL_TRACE
  32. #undef  FT_DEBUG_LEVEL_ERROR
  33. #define FT_DEBUG_LEVEL_ERROR
  34. #endif
  35.   /*************************************************************************/
  36.   /*                                                                       */
  37.   /* Define the trace enums as well as the trace levels array when they    */
  38.   /* are needed.                                                           */
  39.   /*                                                                       */
  40.   /*************************************************************************/
  41. #ifdef FT_DEBUG_LEVEL_TRACE
  42. #define FT_TRACE_DEF( x )  trace_ ## x ,
  43.   /* defining the enumeration */
  44.   typedef enum
  45.   {
  46. #include FT_INTERNAL_TRACE_H
  47.     trace_count
  48.   } FT_Trace;
  49.   /* defining the array of trace levels, provided by `src/base/ftdebug.c' */
  50.   extern int  ft_trace_levels[trace_count];
  51. #undef FT_TRACE_DEF
  52. #endif /* FT_DEBUG_LEVEL_TRACE */
  53.   /*************************************************************************/
  54.   /*                                                                       */
  55.   /* Define the FT_TRACE macro                                             */
  56.   /*                                                                       */
  57.   /* IMPORTANT!                                                            */
  58.   /*                                                                       */
  59.   /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */
  60.   /* value before using any TRACE macro.                                   */
  61.   /*                                                                       */
  62.   /*************************************************************************/
  63. #ifdef FT_DEBUG_LEVEL_TRACE
  64. #define FT_TRACE( level, varformat )                      
  65.           do                                              
  66.           {                                               
  67.             if ( ft_trace_levels[FT_COMPONENT] >= level ) 
  68.               FT_Message varformat;                       
  69.           } while ( 0 )
  70. #else /* !FT_DEBUG_LEVEL_TRACE */
  71. #define FT_TRACE( level, varformat )  do ; while ( 0 )      /* nothing */
  72. #endif /* !FT_DEBUG_LEVEL_TRACE */
  73.   /*************************************************************************/
  74.   /*                                                                       */
  75.   /* <Function>                                                            */
  76.   /*    FT_Trace_Get_Count                                                 */
  77.   /*                                                                       */
  78.   /* <Description>                                                         */
  79.   /*    Return the number of available trace components.                   */
  80.   /*                                                                       */
  81.   /* <Return>                                                              */
  82.   /*    The number of trace components.  0 if FreeType 2 is not built with */
  83.   /*    FT_DEBUG_LEVEL_TRACE definition.                                   */
  84.   /*                                                                       */
  85.   /* <Note>                                                                */
  86.   /*    This function may be useful if you want to access elements of      */
  87.   /*    the internal `ft_trace_levels' array by an index.                  */
  88.   /*                                                                       */
  89.   FT_BASE( FT_Int )
  90.   FT_Trace_Get_Count( void );
  91.   /*************************************************************************/
  92.   /*                                                                       */
  93.   /* <Function>                                                            */
  94.   /*    FT_Trace_Get_Name                                                  */
  95.   /*                                                                       */
  96.   /* <Description>                                                         */
  97.   /*    Return the name of a trace component.                              */
  98.   /*                                                                       */
  99.   /* <Input>                                                               */
  100.   /*    The index of the trace component.                                  */
  101.   /*                                                                       */
  102.   /* <Return>                                                              */
  103.   /*    The name of the trace component.  This is a statically allocated   */
  104.   /*    C string, so do not free it after use.  NULL if FreeType 2 is not  */
  105.   /*    built with FT_DEBUG_LEVEL_TRACE definition.                        */
  106.   /*                                                                       */
  107.   /* <Note>                                                                */
  108.   /*    Use @FT_Trace_Get_Count to get the number of available trace       */
  109.   /*    components.                                                        */
  110.   /*                                                                       */
  111.   /*    This function may be useful if you want to control FreeType 2's    */
  112.   /*    debug level in your application.                                   */
  113.   /*                                                                       */
  114.   FT_BASE( const char * )
  115.   FT_Trace_Get_Name( FT_Int  idx );
  116.   /*************************************************************************/
  117.   /*                                                                       */
  118.   /* You need two opening resp. closing parentheses!                       */
  119.   /*                                                                       */
  120.   /* Example: FT_TRACE0(( "Value is %i", foo ))                            */
  121.   /*                                                                       */
  122.   /*************************************************************************/
  123. #define FT_TRACE0( varformat )  FT_TRACE( 0, varformat )
  124. #define FT_TRACE1( varformat )  FT_TRACE( 1, varformat )
  125. #define FT_TRACE2( varformat )  FT_TRACE( 2, varformat )
  126. #define FT_TRACE3( varformat )  FT_TRACE( 3, varformat )
  127. #define FT_TRACE4( varformat )  FT_TRACE( 4, varformat )
  128. #define FT_TRACE5( varformat )  FT_TRACE( 5, varformat )
  129. #define FT_TRACE6( varformat )  FT_TRACE( 6, varformat )
  130. #define FT_TRACE7( varformat )  FT_TRACE( 7, varformat )
  131.   /*************************************************************************/
  132.   /*                                                                       */
  133.   /*  Define the FT_ERROR macro                                            */
  134.   /*                                                                       */
  135.   /*************************************************************************/
  136. #ifdef FT_DEBUG_LEVEL_ERROR
  137. #define FT_ERROR( varformat )  FT_Message  varformat
  138. #else  /* !FT_DEBUG_LEVEL_ERROR */
  139. #define FT_ERROR( varformat )  do ; while ( 0 )      /* nothing */
  140. #endif /* !FT_DEBUG_LEVEL_ERROR */
  141.   /*************************************************************************/
  142.   /*                                                                       */
  143.   /* Define the FT_ASSERT macro                                            */
  144.   /*                                                                       */
  145.   /*************************************************************************/
  146. #ifdef FT_DEBUG_LEVEL_ERROR
  147. #define FT_ASSERT( condition )                                      
  148.           do                                                        
  149.           {                                                         
  150.             if ( !( condition ) )                                   
  151.               FT_Panic( "assertion failed on line %d of file %sn", 
  152.                         __LINE__, __FILE__ );                       
  153.           } while ( 0 )
  154. #else /* !FT_DEBUG_LEVEL_ERROR */
  155. #define FT_ASSERT( condition )  do ; while ( 0 )
  156. #endif /* !FT_DEBUG_LEVEL_ERROR */
  157.   /*************************************************************************/
  158.   /*                                                                       */
  159.   /*  Define `FT_Message' and `FT_Panic' when needed                       */
  160.   /*                                                                       */
  161.   /*************************************************************************/
  162. #ifdef FT_DEBUG_LEVEL_ERROR
  163. #include "stdio.h"  /* for vprintf() */
  164.   /* print a message */
  165.   FT_BASE( void )
  166.   FT_Message( const char*  fmt, ... );
  167.   /* print a message and exit */
  168.   FT_BASE( void )
  169.   FT_Panic( const char*  fmt, ... );
  170. #endif /* FT_DEBUG_LEVEL_ERROR */
  171.   FT_BASE( void )
  172.   ft_debug_init( void );
  173. #if defined( _MSC_VER )      /* Visual C++ (and Intel C++) */
  174.   /* we disable the warning `conditional expression is constant' here */
  175.   /* in order to compile cleanly with the maximum level of warnings   */
  176. #pragma warning( disable : 4127 )
  177. #endif /* _MSC_VER */
  178. FT_END_HEADER
  179. #endif /* __FTDEBUG_H__ */
  180. /* END */