1999-12-17 00:11:37 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftdebug.h */
|
|
|
|
/* */
|
|
|
|
/* Debugging and logging component (specification). */
|
|
|
|
/* */
|
2000-01-08 18:10:33 +01:00
|
|
|
/* Copyright 1996-2000 by */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
|
|
|
/* This file is part of the FreeType project, and may only be used */
|
|
|
|
/* modified and distributed under the terms of the FreeType project */
|
|
|
|
/* 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
|
|
|
|
|
2000-06-02 23:31:32 +02:00
|
|
|
#include <freetype/config/ftconfig.h> /* for FT_DEBUG_LEVEL_TRACE, */
|
|
|
|
/* FT_DEBUG_LEVEL_ERROR */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-06-02 23:31:32 +02:00
|
|
|
/* A very stupid pre-processor trick. See K&R version 2 */
|
|
|
|
/* section A12.3 for details... */
|
|
|
|
/* */
|
|
|
|
/* It is also described in the section `Separate */
|
|
|
|
/* Expansion of Macro Arguments' in the info file */
|
|
|
|
/* `cpp.info', describing GNU cpp. */
|
|
|
|
/* */
|
|
|
|
#define FT_CAT( x, y ) x ## y
|
|
|
|
#define FT_XCAT( x, y ) FT_CAT( x, y )
|
|
|
|
|
2000-05-12 17:01:18 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum FT_Trace_
|
|
|
|
{
|
2000-01-08 18:10:33 +01:00
|
|
|
/* the first level must always be `trace_any' */
|
1999-12-17 00:11:37 +01:00
|
|
|
trace_any = 0,
|
|
|
|
|
2000-06-02 23:31:32 +02:00
|
|
|
/* we start with an enum for each common component */
|
|
|
|
trace_io, /* i/o monitoring -- see ftsystem.c */
|
|
|
|
trace_memory, /* memory manager -- see ftobjs.c */
|
|
|
|
trace_stream, /* stream manager -- see ftstream.c */
|
|
|
|
trace_calc, /* computations -- see ftcalc.c */
|
|
|
|
trace_raster, /* raster -- see ftraster.c */
|
|
|
|
trace_list, /* list manager -- see ftlist.c */
|
|
|
|
trace_objs, /* base objects -- see ftobjs.c */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* then define an enum for each TrueType driver component */
|
|
|
|
trace_ttobjs,
|
|
|
|
trace_ttload,
|
|
|
|
trace_ttgload,
|
|
|
|
trace_ttinterp,
|
|
|
|
trace_ttcmap,
|
|
|
|
trace_ttextend,
|
|
|
|
trace_ttdriver,
|
|
|
|
|
|
|
|
/* define an enum for each Type1 driver component */
|
|
|
|
trace_t1objs,
|
|
|
|
trace_t1load,
|
|
|
|
trace_t1gload,
|
|
|
|
trace_t1hint,
|
|
|
|
trace_t1driver,
|
|
|
|
|
|
|
|
/* other trace levels */
|
2000-01-08 18:10:33 +01:00
|
|
|
trace_init,
|
2000-06-02 23:31:32 +02:00
|
|
|
trace_extend,
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* the last level must always be `trace_max' */
|
|
|
|
trace_max
|
|
|
|
|
|
|
|
} FT_Trace;
|
|
|
|
|
2000-01-08 18:10:33 +01:00
|
|
|
/* declared in ftdebug.c */
|
1999-12-17 00:11:37 +01:00
|
|
|
extern char ft_trace_levels[trace_max];
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* IMPORTANT! */
|
|
|
|
/* */
|
|
|
|
/* Each component must define the macro FT_COMPONENT to a valid */
|
|
|
|
/* Trace_Component value before using any TRACE macro. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2000-01-08 18:10:33 +01:00
|
|
|
#define FT_TRACE( level, varformat ) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if ( ft_trace_levels[FT_COMPONENT] >= level ) \
|
2000-05-12 17:01:18 +02:00
|
|
|
FT_XCAT( FT_Message, varformat ); \
|
2000-01-08 18:10:33 +01:00
|
|
|
} while ( 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-05-24 02:31:14 +02:00
|
|
|
FT_EXPORT_DEF(void) FT_SetTraceLevel( FT_Trace component,
|
|
|
|
char level );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
#elif defined( FT_DEBUG_LEVEL_ERROR )
|
|
|
|
|
|
|
|
|
2000-01-08 18:10:33 +01:00
|
|
|
#define FT_TRACE( level, varformat ) while ( 0 ) { } /* nothing */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
#else /* release mode */
|
|
|
|
|
|
|
|
|
2000-01-08 18:10:33 +01:00
|
|
|
#define FT_Assert( condition ) while ( 0 ) { } /* nothing */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-01-08 18:10:33 +01:00
|
|
|
#define FT_TRACE( level, varformat ) while ( 0 ) { } /* nothing */
|
|
|
|
#define FT_ERROR( varformat ) while ( 0 ) { } /* nothing */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* FT_DEBUG_LEVEL_TRACE, FT_DEBUG_LEVEL_ERROR */
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Define macros and functions that are common to the debug and trace */
|
|
|
|
/* modes. */
|
|
|
|
/* */
|
2000-01-08 18:10:33 +01:00
|
|
|
/* You need vprintf() to be able to compile ftdebug.c. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
#if defined( FT_DEBUG_LEVEL_TRACE ) || defined( FT_DEBUG_LEVEL_ERROR )
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdio.h" /* for vprintf() */
|
|
|
|
|
2000-01-08 18:10:33 +01:00
|
|
|
#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
|
|
|
|
2000-01-08 18:10:33 +01:00
|
|
|
/* print a message */
|
2000-05-24 02:31:14 +02:00
|
|
|
FT_EXPORT_DEF(void) FT_Message( const char* fmt, ... );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* print a message and exit */
|
2000-05-24 02:31:14 +02:00
|
|
|
FT_EXPORT_DEF(void) FT_Panic ( const char* fmt, ... );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-05-26 04:07:40 +02:00
|
|
|
#define FT_ERROR(varformat) do { FT_XCAT( FT_Message, varformat ); } while(0)
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
|
|
|
|
|
|
|
|
|
2000-01-08 18:10:33 +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 )
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FTDEBUG_H */
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|