vrshoot

view libs/ft2static/freetype/fterrors.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
1 /***************************************************************************/
2 /* */
3 /* fterrors.h */
4 /* */
5 /* FreeType error code handling (specification). */
6 /* */
7 /* Copyright 1996-2001, 2002, 2004, 2007 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 /***************************************************************************/
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). You can then use the macro */
32 /* FT_ERROR_BASE macro to extract the generic error code from an */
33 /* FT_Error value. */
34 /* */
35 /* */
36 /* II - Error Message strings */
37 /* -------------------------- */
38 /* */
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 */
43 /* them). */
44 /* */
45 /* To do so, you have to define the following macros before including */
46 /* this file: */
47 /* */
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 */
51 /* (see below). */
52 /* */
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. */
58 /* */
59 /* FT_ERROR_END_LIST :: */
60 /* This macro ends the list. */
61 /* */
62 /* Additionally, you have to undefine __FTERRORS_H__ before #including */
63 /* this file. */
64 /* */
65 /* Here is a simple example: */
66 /* */
67 /* { */
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 } }; */
72 /* */
73 /* const struct */
74 /* { */
75 /* int err_code; */
76 /* const char* err_msg; */
77 /* } ft_errors[] = */
78 /* */
79 /* #include FT_ERRORS_H */
80 /* } */
81 /* */
82 /*************************************************************************/
85 #ifndef __FTERRORS_H__
86 #define __FTERRORS_H__
89 /* include module base error codes */
90 #include FT_MODULE_ERRORS_H
93 /*******************************************************************/
94 /*******************************************************************/
95 /***** *****/
96 /***** SETUP MACROS *****/
97 /***** *****/
98 /*******************************************************************/
99 /*******************************************************************/
102 #undef FT_NEED_EXTERN_C
104 #undef FT_ERR_XCAT
105 #undef FT_ERR_CAT
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_'. */
113 /* */
114 #ifndef FT_ERR_PREFIX
115 #define FT_ERR_PREFIX FT_Err_
116 #endif
119 /* FT_ERR_BASE is used as the base for module-specific errors. */
120 /* */
121 #ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
123 #ifndef FT_ERR_BASE
124 #define FT_ERR_BASE FT_Mod_Err_Base
125 #endif
127 #else
129 #undef FT_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. */
137 /* */
138 #ifndef FT_ERRORDEF
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 ) };
144 #ifdef __cplusplus
145 #define FT_NEED_EXTERN_C
146 extern "C" {
147 #endif
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
162 FT_ERROR_START_LIST
163 #endif
166 /* now include the error codes */
167 #include FT_ERROR_DEFINITIONS_H
170 #ifdef FT_ERROR_END_LIST
171 FT_ERROR_END_LIST
172 #endif
175 /*******************************************************************/
176 /*******************************************************************/
177 /***** *****/
178 /***** SIMPLE CLEANUP *****/
179 /***** *****/
180 /*******************************************************************/
181 /*******************************************************************/
183 #ifdef FT_NEED_EXTERN_C
184 }
185 #endif
187 #undef FT_ERROR_START_LIST
188 #undef FT_ERROR_END_LIST
190 #undef FT_ERRORDEF
191 #undef FT_ERRORDEF_
192 #undef FT_NOERRORDEF_
194 #undef FT_NEED_EXTERN_C
195 #undef FT_ERR_CONCAT
196 #undef FT_ERR_BASE
198 /* FT_KEEP_ERR_PREFIX is needed for ftvalid.h */
199 #ifndef FT_KEEP_ERR_PREFIX
200 #undef FT_ERR_PREFIX
201 #endif
203 #endif /* __FTERRORS_H__ */
206 /* END */