fterrors.h 9.1 KB

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