summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype/freetype-1.5/lib/ttdebug.h
blob: 0fd1389febb2f7a2395b3a25b2e8e1855654b105 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*******************************************************************
 *
 *  ttdebug.h
 *
 *    Debugging and Logging component (specification)
 *
 *  Copyright 1996-2001 by
 *  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.
 *
 *
 *  This component contains various macros and functions used to
 *  ease the debugging of the FreeType engine. Its main purpose
 *  is in assertion checking, tracing, and error detection.
 *
 *  There are now three debugging modes:
 *
 *  - trace mode:
 *
 *       Error and trace messages are sent to the log file
 *       (which can be the standard error output).  Define
 *       DEBUG_LEVEL_TRACE to enable this mode.
 *
 *  - error mode:
 *
 *       Only error messages are generated.  Define
 *       DEBUG_LEVEL_ERROR to enable this mode.
 *
 *  - release mode:
 *
 *       Error messages are neither sent nor generated. The code is
 *       free from any debugging parts.
 *
 ******************************************************************/

#ifndef TTDEBUG_H
#define TTDEBUG_H

#include "ttconfig.h"
#include "tttypes.h"


#ifdef __cplusplus
  extern "C" {
#endif


#if defined( DEBUG_LEVEL_TRACE )

  typedef enum Trace_Component_
  {
    trace_any = 0,
    trace_api,
    trace_interp,
    trace_load,
    trace_gload,
    trace_memory,
    trace_file,
    trace_mutex,
    trace_cache,
    trace_calc,
    trace_cmap,
    trace_extend,
    trace_objs,
    trace_raster,

    trace_bitmap,
    trace_max

  } Trace_Component;


  /* Here we define an array to hold the trace levels per component. */
  /* Since it is globally defined, all array members are set to 0.   */
  /* You should set the values in this array either in your program  */
  /* or with your debugger.                                          */
  /*                                                                 */
  /* Currently, up to eight levels (PTRACE0-PTRACE7, see below) are  */
  /* used in some parts of the engine.                               */
  /*                                                                 */
  /* For example, to have all tracing messages in the raster         */
  /* component, say                                                  */
  /*                                                                 */
  /*   #define DEBUG_LEVEL_TRACE                                     */
  /*   #include "ttdebug.h"                                          */
  /*                                                                 */
  /*   ...                                                           */
  /*   set_tt_trace_levels( trace_raster, 7 )                        */
  /*                                                                 */
  /* in your code before initializing the FreeType engine.           */
  /*                                                                 */
  /* Maybe it is better to define DEBUG_LEVEL_TRACE in ttconfig.h... */

  extern char  tt_trace_levels[trace_max];

  /* IMPORTANT:                                                 */
  /*                                                            */
  /*  Each component must define the macro TT_COMPONENT         */
  /*  to a valid Trace_Component value before using any         */
  /*  PTRACEx macro.                                            */
  /*                                                            */

#define  PTRACE( level, varformat )  \
         if ( tt_trace_levels[TT_COMPONENT] >= level ) TT_Message##varformat

#elif defined( DEBUG_LEVEL_ERROR )

#define  PTRACE( level, varformat )  /* nothing */

#else  /* RELEASE MODE */

#define TT_Assert( condition, action )  /* nothing */

#define PTRACE( level, varformat )      /* nothing */
#define PERROR( varformat )             /* nothing */
#define PANIC( varformat )              /* nothing */

#endif


/************************************************************************/
/*                                                                      */
/*  Define macros and fuctions that are common to the debug and trace   */
/*  modes.                                                              */
/*                                                                      */

#if defined( DEBUG_LEVEL_TRACE ) || defined( DEBUG_LEVEL_ERROR )


#define TT_Assert( condition, action )  if ( !(condition) ) ( action )

  void  TT_Message( const String*  fmt, ... );
  void  TT_Panic  ( const String*  fmt, ... );
  /* print a message and exit */

  const String*  Cur_U_Line( void*  exec );

#define PERROR( varformat )  TT_Message##varformat
#define PANIC( varformat )   TT_Panic##varformat

#endif

#if defined( DEBUG_LEVEL_TRACE )

  void  set_tt_trace_levels( int  index, char  value );

#endif


#define  PTRACE0( varformat )  PTRACE( 0, varformat )
#define  PTRACE1( varformat )  PTRACE( 1, varformat )
#define  PTRACE2( varformat )  PTRACE( 2, varformat )
#define  PTRACE3( varformat )  PTRACE( 3, varformat )
#define  PTRACE4( varformat )  PTRACE( 4, varformat )
#define  PTRACE5( varformat )  PTRACE( 5, varformat )
#define  PTRACE6( varformat )  PTRACE( 6, varformat )
#define  PTRACE7( varformat )  PTRACE( 7, varformat )


#ifdef __cplusplus
  }
#endif


#endif /* TTDEBUG_H */