1
/***************************************************************************/
5
/* FreeType error code handling (specification). */
7
/* Copyright 1996-2001, 2002 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
/* Since release 2.1, the error constants have changed. The lower */
29
/* byte of the error value gives the "generic" error code, while the */
30
/* higher byte indicates in which module the error occurred. */
32
/* You can use the macro FT_ERROR_BASE(x) macro to extract the generic */
33
/* error code from an FT_Error value. */
35
/* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */
36
/* undefined in ftoption.h in order to make the higher byte always */
37
/* zero, in case you need to be compatible with previous versions of */
41
/* II - Error Message strings */
42
/* -------------------------- */
44
/* The error definitions below are made through special macros that */
45
/* allow client applications to build a table of error message strings */
46
/* if they need it. The strings are not included in a normal build of */
47
/* FreeType 2 to save space (most client applications do not use */
50
/* To do so, you have to define the following macros before including */
53
/* FT_ERROR_START_LIST :: */
54
/* This macro is called before anything else to define the start of */
55
/* the error list. It is followed by several FT_ERROR_DEF calls */
58
/* FT_ERROR_DEF( e, v, s ) :: */
59
/* This macro is called to define one single error. */
60
/* `e' is the error code identifier (e.g. FT_Err_Invalid_Argument). */
61
/* `v' is the error numerical value. */
62
/* `s' is the corresponding error string. */
64
/* FT_ERROR_END_LIST :: */
65
/* This macro ends the list. */
67
/* Additionally, you have to undefine __FTERRORS_H__ before #including */
70
/* Here is a simple example: */
73
/* #undef __FTERRORS_H__ */
74
/* #define FT_ERRORDEF( e, v, s ) { e, s }, */
75
/* #define FT_ERROR_START_LIST { */
76
/* #define FT_ERROR_END_LIST { 0, 0 } }; */
81
/* const char* err_msg */
84
/* #include FT_ERRORS_H */
87
/*************************************************************************/
90
#ifndef __FTERRORS_H__
91
#define __FTERRORS_H__
94
/* include module base error codes */
95
#include FT_MODULE_ERRORS_H
98
/*******************************************************************/
99
/*******************************************************************/
101
/***** SETUP MACROS *****/
103
/*******************************************************************/
104
/*******************************************************************/
107
#undef FT_NEED_EXTERN_C
112
#define FT_ERR_XCAT( x, y ) x ## y
113
#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
116
/* FT_ERR_PREFIX is used as a prefix for error identifiers. */
117
/* By default, we use `FT_Err_'. */
119
#ifndef FT_ERR_PREFIX
120
#define FT_ERR_PREFIX FT_Err_
124
/* FT_ERR_BASE is used as the base for module-specific errors. */
126
#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
129
#define FT_ERR_BASE FT_Mod_Err_Base
135
#define FT_ERR_BASE 0
137
#endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */
140
/* If FT_ERRORDEF is not defined, we need to define a simple */
141
/* enumeration type. */
145
#define FT_ERRORDEF( e, v, s ) e = v,
146
#define FT_ERROR_START_LIST enum {
147
#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) };
150
#define FT_NEED_EXTERN_C
154
#endif /* !FT_ERRORDEF */
157
/* this macro is used to define an error */
158
#define FT_ERRORDEF_( e, v, s ) \
159
FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s )
161
/* this is only used for FT_Err_Ok, which must be 0! */
162
#define FT_NOERRORDEF_( e, v, s ) \
163
FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s )
166
#ifdef FT_ERROR_START_LIST
171
/* no include the error codes */
172
#include FT_ERROR_DEFINITIONS_H
175
#ifdef FT_ERROR_END_LIST
180
/*******************************************************************/
181
/*******************************************************************/
183
/***** SIMPLE CLEANUP *****/
185
/*******************************************************************/
186
/*******************************************************************/
188
#ifdef FT_NEED_EXTERN_C
192
#undef FT_ERROR_START_LIST
193
#undef FT_ERROR_END_LIST
197
#undef FT_NOERRORDEF_
199
#undef FT_NEED_EXTERN_C
204
#endif /* __FTERRORS_H__ */