1 /***************************************************************************/
5 /* FreeType error code handling (specification). */
7 /* Copyright 1996-2001, 2002, 2004, 2007 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
16 /***************************************************************************/
19 /*************************************************************************/
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. */
25 /* I - Error Formats */
26 /* ----------------- */
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). You can then use the macro */
32 /* FT_ERROR_BASE macro to extract the generic error code from an */
36 /* II - Error Message strings */
37 /* -------------------------- */
39 /* The error definitions below are made through special macros that */
40 /* allow client applications to build a table of error message strings */
41 /* if they need it. The strings are not included in a normal build of */
42 /* FreeType 2 to save space (most client applications do not use */
45 /* To do so, you have to define the following macros before including */
48 /* FT_ERROR_START_LIST :: */
49 /* This macro is called before anything else to define the start of */
50 /* the error list. It is followed by several FT_ERROR_DEF calls */
53 /* FT_ERROR_DEF( e, v, s ) :: */
54 /* This macro is called to define one single error. */
55 /* `e' is the error code identifier (e.g. FT_Err_Invalid_Argument). */
56 /* `v' is the error numerical value. */
57 /* `s' is the corresponding error string. */
59 /* FT_ERROR_END_LIST :: */
60 /* This macro ends the list. */
62 /* Additionally, you have to undefine __FTERRORS_H__ before #including */
65 /* Here is a simple example: */
68 /* #undef __FTERRORS_H__ */
69 /* #define FT_ERRORDEF( e, v, s ) { e, s }, */
70 /* #define FT_ERROR_START_LIST { */
71 /* #define FT_ERROR_END_LIST { 0, 0 } }; */
76 /* const char* err_msg; */
79 /* #include FT_ERRORS_H */
82 /*************************************************************************/
85 #ifndef __FTERRORS_H__
86 #define __FTERRORS_H__
89 /* include module base error codes */
90 #include FT_MODULE_ERRORS_H
93 /*******************************************************************/
94 /*******************************************************************/
96 /***** SETUP MACROS *****/
98 /*******************************************************************/
99 /*******************************************************************/
102 #undef FT_NEED_EXTERN_C
107 #define FT_ERR_XCAT( x, y ) x ## y
108 #define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
111 /* FT_ERR_PREFIX is used as a prefix for error identifiers. */
112 /* By default, we use `FT_Err_'. */
114 #ifndef FT_ERR_PREFIX
115 #define FT_ERR_PREFIX FT_Err_
119 /* FT_ERR_BASE is used as the base for module-specific errors. */
121 #ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
124 #define FT_ERR_BASE FT_Mod_Err_Base
130 #define FT_ERR_BASE 0
132 #endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */
135 /* If FT_ERRORDEF is not defined, we need to define a simple */
136 /* enumeration type. */
140 #define FT_ERRORDEF( e, v, s ) e = v,
141 #define FT_ERROR_START_LIST enum {
142 #define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) };
145 #define FT_NEED_EXTERN_C
149 #endif /* !FT_ERRORDEF */
152 /* this macro is used to define an error */
153 #define FT_ERRORDEF_( e, v, s ) \
154 FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s )
156 /* this is only used for <module>_Err_Ok, which must be 0! */
157 #define FT_NOERRORDEF_( e, v, s ) \
158 FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s )
161 #ifdef FT_ERROR_START_LIST
166 /* now include the error codes */
167 #include FT_ERROR_DEFINITIONS_H
170 #ifdef FT_ERROR_END_LIST
175 /*******************************************************************/
176 /*******************************************************************/
178 /***** SIMPLE CLEANUP *****/
180 /*******************************************************************/
181 /*******************************************************************/
183 #ifdef FT_NEED_EXTERN_C
187 #undef FT_ERROR_START_LIST
188 #undef FT_ERROR_END_LIST
192 #undef FT_NOERRORDEF_
194 #undef FT_NEED_EXTERN_C
197 /* FT_KEEP_ERR_PREFIX is needed for ftvalid.h */
198 #ifndef FT_KEEP_ERR_PREFIX
201 #undef FT_KEEP_ERR_PREFIX
204 #endif /* __FTERRORS_H__ */