You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

124 lines
4.0 KiB

  1. /*
  2. * fontconfig/fontconfig/fcprivate.h
  3. *
  4. * Copyright © 2001 Keith Packard
  5. *
  6. * Permission to use, copy, modify, distribute, and sell this software and its
  7. * documentation for any purpose is hereby granted without fee, provided that
  8. * the above copyright notice appear in all copies and that both that
  9. * copyright notice and this permission notice appear in supporting
  10. * documentation, and that the name of Keith Packard not be used in
  11. * advertising or publicity pertaining to distribution of the software without
  12. * specific, written prior permission. Keith Packard makes no
  13. * representations about the suitability of this software for any purpose. It
  14. * is provided "as is" without express or implied warranty.
  15. *
  16. * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  17. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  18. * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  19. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  20. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  21. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  22. * PERFORMANCE OF THIS SOFTWARE.
  23. */
  24. #ifndef _FCPRIVATE_H_
  25. #define _FCPRIVATE_H_
  26. /*
  27. * I tried this with functions that took va_list* arguments
  28. * but portability concerns made me change these functions
  29. * into macros (sigh).
  30. */
  31. #define FcPatternVapBuild(result, orig, va) \
  32. { \
  33. FcPattern *__p__ = (orig); \
  34. const char *__o__; \
  35. FcValue __v__; \
  36. \
  37. if (!__p__) \
  38. { \
  39. __p__ = FcPatternCreate (); \
  40. if (!__p__) \
  41. goto _FcPatternVapBuild_bail0; \
  42. } \
  43. for (;;) \
  44. { \
  45. __o__ = va_arg (va, const char *); \
  46. if (!__o__) \
  47. break; \
  48. __v__.type = va_arg (va, FcType); \
  49. switch (__v__.type) { \
  50. case FcTypeVoid: \
  51. goto _FcPatternVapBuild_bail1; \
  52. case FcTypeInteger: \
  53. __v__.u.i = va_arg (va, int); \
  54. break; \
  55. case FcTypeDouble: \
  56. __v__.u.d = va_arg (va, double); \
  57. break; \
  58. case FcTypeString: \
  59. __v__.u.s = va_arg (va, const FcChar8 *); \
  60. break; \
  61. case FcTypeBool: \
  62. __v__.u.b = va_arg (va, FcBool); \
  63. break; \
  64. case FcTypeMatrix: \
  65. __v__.u.m = va_arg (va, const FcMatrix *); \
  66. break; \
  67. case FcTypeCharSet: \
  68. __v__.u.c = va_arg (va, const FcCharSet *); \
  69. break; \
  70. case FcTypeFTFace: \
  71. __v__.u.f = va_arg (va, FT_Face); \
  72. break; \
  73. case FcTypeLangSet: \
  74. __v__.u.l = va_arg (va, const FcLangSet *); \
  75. break; \
  76. } \
  77. if (!FcPatternAdd (__p__, __o__, __v__, FcTrue)) \
  78. goto _FcPatternVapBuild_bail1; \
  79. } \
  80. result = __p__; \
  81. goto _FcPatternVapBuild_return; \
  82. \
  83. _FcPatternVapBuild_bail1: \
  84. if (!orig) \
  85. FcPatternDestroy (__p__); \
  86. _FcPatternVapBuild_bail0: \
  87. result = (void*)0; \
  88. \
  89. _FcPatternVapBuild_return: \
  90. ; \
  91. }
  92. #define FcObjectSetVapBuild(__ret__, __first__, __va__) \
  93. { \
  94. FcObjectSet *__os__; \
  95. const char *__ob__; \
  96. \
  97. __ret__ = 0; \
  98. __os__ = FcObjectSetCreate (); \
  99. if (!__os__) \
  100. goto _FcObjectSetVapBuild_bail0; \
  101. __ob__ = __first__; \
  102. while (__ob__) \
  103. { \
  104. if (!FcObjectSetAdd (__os__, __ob__)) \
  105. goto _FcObjectSetVapBuild_bail1; \
  106. __ob__ = va_arg (__va__, const char *); \
  107. } \
  108. __ret__ = __os__; \
  109. \
  110. _FcObjectSetVapBuild_bail1: \
  111. if (!__ret__ && __os__) \
  112. FcObjectSetDestroy (__os__); \
  113. _FcObjectSetVapBuild_bail0: \
  114. ; \
  115. }
  116. #endif /* _FCPRIVATE_H_ */