misc/libfreetype/include/freetype/fterrors.h
changeset 9431 0f5961910e27
parent 9357 a501f5ec7b34
parent 9429 7a97a554ac80
child 9433 f0a8ac191839
equal deleted inserted replaced
9357:a501f5ec7b34 9431:0f5961910e27
     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 /***************************************************************************/
       
    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).  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   /*************************************************************************/
       
    83 
       
    84 
       
    85 #ifndef __FTERRORS_H__
       
    86 #define __FTERRORS_H__
       
    87 
       
    88 
       
    89   /* include module base error codes */
       
    90 #include FT_MODULE_ERRORS_H
       
    91 
       
    92 
       
    93   /*******************************************************************/
       
    94   /*******************************************************************/
       
    95   /*****                                                         *****/
       
    96   /*****                       SETUP MACROS                      *****/
       
    97   /*****                                                         *****/
       
    98   /*******************************************************************/
       
    99   /*******************************************************************/
       
   100 
       
   101 
       
   102 #undef  FT_NEED_EXTERN_C
       
   103 
       
   104 #undef  FT_ERR_XCAT
       
   105 #undef  FT_ERR_CAT
       
   106 
       
   107 #define FT_ERR_XCAT( x, y )  x ## y
       
   108 #define FT_ERR_CAT( x, y )   FT_ERR_XCAT( x, y )
       
   109 
       
   110 
       
   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
       
   117 
       
   118 
       
   119   /* FT_ERR_BASE is used as the base for module-specific errors. */
       
   120   /*                                                             */
       
   121 #ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
       
   122 
       
   123 #ifndef FT_ERR_BASE
       
   124 #define FT_ERR_BASE  FT_Mod_Err_Base
       
   125 #endif
       
   126 
       
   127 #else
       
   128 
       
   129 #undef FT_ERR_BASE
       
   130 #define FT_ERR_BASE  0
       
   131 
       
   132 #endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */
       
   133 
       
   134 
       
   135   /* If FT_ERRORDEF is not defined, we need to define a simple */
       
   136   /* enumeration type.                                         */
       
   137   /*                                                           */
       
   138 #ifndef FT_ERRORDEF
       
   139 
       
   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 ) };
       
   143 
       
   144 #ifdef __cplusplus
       
   145 #define FT_NEED_EXTERN_C
       
   146   extern "C" {
       
   147 #endif
       
   148 
       
   149 #endif /* !FT_ERRORDEF */
       
   150 
       
   151 
       
   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 )
       
   155 
       
   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 )
       
   159 
       
   160 
       
   161 #ifdef FT_ERROR_START_LIST
       
   162   FT_ERROR_START_LIST
       
   163 #endif
       
   164 
       
   165 
       
   166   /* now include the error codes */
       
   167 #include FT_ERROR_DEFINITIONS_H
       
   168 
       
   169 
       
   170 #ifdef FT_ERROR_END_LIST
       
   171   FT_ERROR_END_LIST
       
   172 #endif
       
   173 
       
   174 
       
   175   /*******************************************************************/
       
   176   /*******************************************************************/
       
   177   /*****                                                         *****/
       
   178   /*****                      SIMPLE CLEANUP                     *****/
       
   179   /*****                                                         *****/
       
   180   /*******************************************************************/
       
   181   /*******************************************************************/
       
   182 
       
   183 #ifdef FT_NEED_EXTERN_C
       
   184   }
       
   185 #endif
       
   186 
       
   187 #undef FT_ERROR_START_LIST
       
   188 #undef FT_ERROR_END_LIST
       
   189 
       
   190 #undef FT_ERRORDEF
       
   191 #undef FT_ERRORDEF_
       
   192 #undef FT_NOERRORDEF_
       
   193 
       
   194 #undef FT_NEED_EXTERN_C
       
   195 #undef FT_ERR_CONCAT
       
   196 #undef FT_ERR_BASE
       
   197 
       
   198   /* FT_KEEP_ERR_PREFIX is needed for ftvalid.h */
       
   199 #ifndef FT_KEEP_ERR_PREFIX
       
   200 #undef FT_ERR_PREFIX
       
   201 #endif
       
   202 
       
   203 #endif /* __FTERRORS_H__ */
       
   204 
       
   205 
       
   206 /* END */