freetype2/include/freetype/internal/ftdebug.h

193 lines
7.3 KiB
C
Raw Normal View History

1999-12-17 00:11:37 +01:00
/***************************************************************************/
/* */
/* ftdebug.h */
/* */
/* Debugging and logging component (specification). */
/* */
/* Copyright 1996-2001 by */
1999-12-17 00:11:37 +01:00
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
2000-07-18 08:50:03 +02:00
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
1999-12-17 00:11:37 +01:00
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef __FTDEBUG_H__
#define __FTDEBUG_H__
1999-12-17 00:11:37 +01:00
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
1999-12-17 00:11:37 +01:00
FT_BEGIN_HEADER
1999-12-17 00:11:37 +01:00
/* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */
/* is already defined.. this simplifies the following #ifdefs.. */
/* */
1999-12-17 00:11:37 +01:00
#ifdef FT_DEBUG_LEVEL_TRACE
# undef FT_DEBUG_LEVEL_ERROR
# define FT_DEBUG_LEVEL_ERROR
#endif
1999-12-17 00:11:37 +01:00
/*************************************************************************/
/* */
/* Define the trace enums as well as the trace levels array when */
/* they're needed */
/* */
/*************************************************************************/
#ifdef FT_DEBUG_LEVEL_TRACE
# define FT_TRACE_DEF(x) trace_ ## x ,
/* defining the enums */
typedef enum
1999-12-17 00:11:37 +01:00
{
# include FT_INTERNAL_TRACE_H
trace_count,
1999-12-17 00:11:37 +01:00
} FT_Trace;
2000-07-18 08:50:03 +02:00
/* defining the array of trace levels, provided by 'src/base/ftdebug.c' */
extern int ft_trace_levels [ trace_count ];
# undef FT_TRACE_DEF
#endif /* FT_DEBUG_LEVEL_TRACE */
1999-12-17 00:11:37 +01:00
/*************************************************************************/
/* */
/* Define the FT_TRACE macro */
/* */
1999-12-17 00:11:37 +01:00
/* IMPORTANT! */
/* */
/* Each component must define the macro FT_COMPONENT to a valid FT_Trace */
/* value before using any TRACE macro. */
1999-12-17 00:11:37 +01:00
/* */
/*************************************************************************/
#ifdef FT_DEBUG_LEVEL_TRACE
1999-12-17 00:11:37 +01:00
# define FT_TRACE( level, varformat ) \
do \
{ \
if ( ft_trace_levels[FT_COMPONENT] >= level ) \
FT_Message varformat; \
} while ( 0 )
1999-12-17 00:11:37 +01:00
#else /* !FT_DEBUG_LEVEL_TRACE */
# define FT_TRACE( level, varformat ) do ; while ( 0 ) /* nothing */
#endif /* !FT_DEBUG_LEVEL_TRACE */
1999-12-17 00:11:37 +01:00
/*************************************************************************/
/* */
/* You need two opening resp. closing parentheses! */
/* */
/* Example: FT_TRACE0(( "Value is %i", foo )) */
/* */
/*************************************************************************/
1999-12-17 00:11:37 +01:00
#define FT_TRACE0( varformat ) FT_TRACE( 0, varformat )
#define FT_TRACE1( varformat ) FT_TRACE( 1, varformat )
#define FT_TRACE2( varformat ) FT_TRACE( 2, varformat )
#define FT_TRACE3( varformat ) FT_TRACE( 3, varformat )
#define FT_TRACE4( varformat ) FT_TRACE( 4, varformat )
#define FT_TRACE5( varformat ) FT_TRACE( 5, varformat )
#define FT_TRACE6( varformat ) FT_TRACE( 6, varformat )
#define FT_TRACE7( varformat ) FT_TRACE( 7, varformat )
1999-12-17 00:11:37 +01:00
/*************************************************************************/
/* */
/* Define the FT_ERROR macro */
/* */
/*************************************************************************/
1999-12-17 00:11:37 +01:00
#ifdef FT_DEBUG_LEVEL_ERROR
1999-12-17 00:11:37 +01:00
# define FT_ERROR( varformat ) FT_Message varformat
1999-12-17 00:11:37 +01:00
#else /* !FT_DEBUG_LEVEL_ERROR */
1999-12-17 00:11:37 +01:00
# define FT_ERROR( varformat ) do ; while ( 0 ) /* nothing */
1999-12-17 00:11:37 +01:00
#endif /* !FT_DEBUG_LEVEL_ERROR */
1999-12-17 00:11:37 +01:00
/*************************************************************************/
/* */
/* Define the FT_ASSERT macro */
1999-12-17 00:11:37 +01:00
/* */
/*************************************************************************/
#ifdef FT_DEBUG_LEVEL_ERROR
#define FT_ASSERT( condition ) \
do \
{ \
if ( !( condition ) ) \
FT_Panic( "assertion failed on line %d of file %s\n", \
__LINE__, __FILE__ ); \
} while ( 0 )
1999-12-17 00:11:37 +01:00
#else /* !FT_DEBUG_LEVEL_ERROR */
# define FT_ASSERT( condition ) do ; while ( 0 )
#endif /* !FT_DEBUG_LEVEL_ERROR */
/*************************************************************************/
/* */
/* Define 'FT_Message' and 'FT_Panic' when needed */
/* */
/*************************************************************************/
#ifdef FT_DEBUG_LEVEL_ERROR
#include "stdio.h" /* for vprintf() */
/* print a message */
FT_EXPORT( void )
FT_Message( const char* fmt, ... );
1999-12-17 00:11:37 +01:00
/* print a message and exit */
FT_EXPORT( void )
FT_Panic( const char* fmt, ... );
1999-12-17 00:11:37 +01:00
#endif /* FT_DEBUG_LEVEL_ERROR */
1999-12-17 00:11:37 +01:00
FT_BASE( void ) ft_debug_init( void );
1999-12-17 00:11:37 +01:00
2001-06-20 01:03:41 +02:00
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
2001-06-20 01:03:41 +02:00
/* we disable the warning `conditional expression is constant' here */
/* in order to compile cleanly with the maximum level of warnings */
#pragma warning( disable : 4127 )
#endif /* _MSC_VER */
1999-12-17 00:11:37 +01:00
FT_END_HEADER
1999-12-17 00:11:37 +01:00
#endif /* __FTDEBUG_H__ */
1999-12-17 00:11:37 +01:00
/* END */