fcprivate.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 the author(s) not be used in
  11. * advertising or publicity pertaining to distribution of the software without
  12. * specific, written prior permission. The authors make 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, int); \
  49. switch (__v__.type) { \
  50. case FcTypeUnknown: \
  51. case FcTypeVoid: \
  52. goto _FcPatternVapBuild_bail1; \
  53. case FcTypeInteger: \
  54. __v__.u.i = va_arg (va, int); \
  55. break; \
  56. case FcTypeDouble: \
  57. __v__.u.d = va_arg (va, double); \
  58. break; \
  59. case FcTypeString: \
  60. __v__.u.s = va_arg (va, const FcChar8 *); \
  61. break; \
  62. case FcTypeBool: \
  63. __v__.u.b = va_arg (va, FcBool); \
  64. break; \
  65. case FcTypeMatrix: \
  66. __v__.u.m = va_arg (va, const FcMatrix *); \
  67. break; \
  68. case FcTypeCharSet: \
  69. __v__.u.c = va_arg (va, const FcCharSet *); \
  70. break; \
  71. case FcTypeFTFace: \
  72. __v__.u.f = va_arg (va, FT_Face); \
  73. break; \
  74. case FcTypeLangSet: \
  75. __v__.u.l = va_arg (va, const FcLangSet *); \
  76. break; \
  77. case FcTypeRange: \
  78. __v__.u.r = va_arg (va, const FcRange *); \
  79. break; \
  80. } \
  81. if (!FcPatternAdd (__p__, __o__, __v__, FcTrue)) \
  82. goto _FcPatternVapBuild_bail1; \
  83. } \
  84. result = __p__; \
  85. goto _FcPatternVapBuild_return; \
  86. \
  87. _FcPatternVapBuild_bail1: \
  88. if (!orig) \
  89. FcPatternDestroy (__p__); \
  90. _FcPatternVapBuild_bail0: \
  91. result = (void*)0; \
  92. \
  93. _FcPatternVapBuild_return: \
  94. ; \
  95. }
  96. #define FcObjectSetVapBuild(__ret__, __first__, __va__) \
  97. { \
  98. FcObjectSet *__os__; \
  99. const char *__ob__; \
  100. \
  101. __ret__ = 0; \
  102. __os__ = FcObjectSetCreate (); \
  103. if (!__os__) \
  104. goto _FcObjectSetVapBuild_bail0; \
  105. __ob__ = __first__; \
  106. while (__ob__) \
  107. { \
  108. if (!FcObjectSetAdd (__os__, __ob__)) \
  109. goto _FcObjectSetVapBuild_bail1; \
  110. __ob__ = va_arg (__va__, const char *); \
  111. } \
  112. __ret__ = __os__; \
  113. \
  114. _FcObjectSetVapBuild_bail1: \
  115. if (!__ret__ && __os__) \
  116. FcObjectSetDestroy (__os__); \
  117. _FcObjectSetVapBuild_bail0: \
  118. ; \
  119. }
  120. #ifndef FC_ATTRIBUTE_VISIBILITY_HIDDEN
  121. #define FC_ATTRIBUTE_VISIBILITY_HIDDEN __attribute((visibility("hidden")))
  122. #endif
  123. #ifndef FC_ATTRIBUTE_VISIBILITY_EXPORT
  124. #define FC_ATTRIBUTE_VISIBILITY_EXPORT __attribute((visibility("default")))
  125. #endif
  126. #endif /* _FCPRIVATE_H_ */