1 /***************************************************************************/
2 /*                                                                         */
3 /*  fterrors.h                                                             */
4 /*                                                                         */
5 /*    FreeType error code handling (specification).                        */
6 /*                                                                         */
7 /*  Copyright 1996-2002, 2004, 2007, 2013 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 
18 
19   /*************************************************************************/
20   /*                                                                       */
21   /* This special header file is used to define the handling of FT2        */
22   /* enumeration constants.  It can also be used to generate error message */
23   /* strings with a small macro trick explained below.                     */
24   /*                                                                       */
25   /* I - Error Formats                                                     */
26   /* -----------------                                                     */
27   /*                                                                       */
28   /*   The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be   */
29   /*   defined in ftoption.h in order to make the higher byte indicate     */
30   /*   the module where the error has happened (this is not compatible     */
31   /*   with standard builds of FreeType 2).  See the file `ftmoderr.h' for */
32   /*   more details.                                                       */
33   /*                                                                       */
34   /*                                                                       */
35   /* II - Error Message strings                                            */
36   /* --------------------------                                            */
37   /*                                                                       */
38   /*   The error definitions below are made through special macros that    */
39   /*   allow client applications to build a table of error message strings */
40   /*   if they need it.  The strings are not included in a normal build of */
41   /*   FreeType 2 to save space (most client applications do not use       */
42   /*   them).                                                              */
43   /*                                                                       */
44   /*   To do so, you have to define the following macros before including  */
45   /*   this file:                                                          */
46   /*                                                                       */
47   /*   FT_ERROR_START_LIST ::                                              */
48   /*     This macro is called before anything else to define the start of  */
49   /*     the error list.  It is followed by several FT_ERROR_DEF calls     */
50   /*     (see below).                                                      */
51   /*                                                                       */
52   /*   FT_ERROR_DEF( e, v, s ) ::                                          */
53   /*     This macro is called to define one single error.                  */
54   /*     `e' is the error code identifier (e.g. FT_Err_Invalid_Argument).  */
55   /*     `v' is the error numerical value.                                 */
56   /*     `s' is the corresponding error string.                            */
57   /*                                                                       */
58   /*   FT_ERROR_END_LIST ::                                                */
59   /*     This macro ends the list.                                         */
60   /*                                                                       */
61   /*   Additionally, you have to undefine __FTERRORS_H__ before #including */
62   /*   this file.                                                          */
63   /*                                                                       */
64   /*   Here is a simple example:                                           */
65   /*                                                                       */
66   /*     {                                                                 */
67   /*       #undef __FTERRORS_H__                                           */
68   /*       #define FT_ERRORDEF( e, v, s )  { e, s },                       */
69   /*       #define FT_ERROR_START_LIST     {                               */
70   /*       #define FT_ERROR_END_LIST       { 0, 0 } };                     */
71   /*                                                                       */
72   /*       const struct                                                    */
73   /*       {                                                               */
74   /*         int          err_code;                                        */
75   /*         const char*  err_msg;                                         */
76   /*       } ft_errors[] =                                                 */
77   /*                                                                       */
78   /*       #include FT_ERRORS_H                                            */
79   /*     }                                                                 */
80   /*                                                                       */
81   /*************************************************************************/
82 
83 
84 #ifndef __FTERRORS_H__
85 #define __FTERRORS_H__
86 
87 
88   /* include module base error codes */
89 #include FT_MODULE_ERRORS_H
90 
91 
92   /*******************************************************************/
93   /*******************************************************************/
94   /*****                                                         *****/
95   /*****                       SETUP MACROS                      *****/
96   /*****                                                         *****/
97   /*******************************************************************/
98   /*******************************************************************/
99 
100 
101 #undef  FT_NEED_EXTERN_C
102 
103 
104   /* FT_ERR_PREFIX is used as a prefix for error identifiers. */
105   /* By default, we use `FT_Err_'.                            */
106   /*                                                          */
107 #ifndef FT_ERR_PREFIX
108 #define FT_ERR_PREFIX  FT_Err_
109 #endif
110 
111 
112   /* FT_ERR_BASE is used as the base for module-specific errors. */
113   /*                                                             */
114 #ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
115 
116 #ifndef FT_ERR_BASE
117 #define FT_ERR_BASE  FT_Mod_Err_Base
118 #endif
119 
120 #else
121 
122 #undef FT_ERR_BASE
123 #define FT_ERR_BASE  0
124 
125 #endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */
126 
127 
128   /* If FT_ERRORDEF is not defined, we need to define a simple */
129   /* enumeration type.                                         */
130   /*                                                           */
131 #ifndef FT_ERRORDEF
132 
133 #define FT_ERRORDEF( e, v, s )  e = v,
134 #define FT_ERROR_START_LIST     enum {
135 #define FT_ERROR_END_LIST       FT_ERR_CAT( FT_ERR_PREFIX, Max ) };
136 
137 #ifdef __cplusplus
138 #define FT_NEED_EXTERN_C
139   extern "C" {
140 #endif
141 
142 #endif /* !FT_ERRORDEF */
143 
144 
145   /* this macro is used to define an error */
146 #define FT_ERRORDEF_( e, v, s )                                             \
147           FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s )
148 
149   /* this is only used for <module>_Err_Ok, which must be 0! */
150 #define FT_NOERRORDEF_( e, v, s )                             \
151           FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s )
152 
153 
154 #ifdef FT_ERROR_START_LIST
155   FT_ERROR_START_LIST
156 #endif
157 
158 
159   /* now include the error codes */
160 #include FT_ERROR_DEFINITIONS_H
161 
162 
163 #ifdef FT_ERROR_END_LIST
164   FT_ERROR_END_LIST
165 #endif
166 
167 
168   /*******************************************************************/
169   /*******************************************************************/
170   /*****                                                         *****/
171   /*****                      SIMPLE CLEANUP                     *****/
172   /*****                                                         *****/
173   /*******************************************************************/
174   /*******************************************************************/
175 
176 #ifdef FT_NEED_EXTERN_C
177   }
178 #endif
179 
180 #undef FT_ERROR_START_LIST
181 #undef FT_ERROR_END_LIST
182 
183 #undef FT_ERRORDEF
184 #undef FT_ERRORDEF_
185 #undef FT_NOERRORDEF_
186 
187 #undef FT_NEED_EXTERN_C
188 #undef FT_ERR_BASE
189 
190   /* FT_ERR_PREFIX is needed internally */
191 #ifndef FT2_BUILD_LIBRARY
192 #undef FT_ERR_PREFIX
193 #endif
194 
195 #endif /* __FTERRORS_H__ */
196 
197 
198 /* END */
199