json-version-macros.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* json-version-macros.h - JSON-GLib symbol versioning macros
  2. *
  3. * This file is part of JSON-GLib
  4. * Copyright © 2014 Emmanuele Bassi
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __JSON_VERSION_MACROS_H__
  20. #define __JSON_VERSION_MACROS_H__
  21. #if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION)
  22. #error "Only <json-glib/json-glib.h> can be included directly."
  23. #endif
  24. #include "json-version.h"
  25. #ifndef _JSON_EXTERN
  26. #define _JSON_EXTERN extern
  27. #endif
  28. #ifdef JSON_DISABLE_DEPRECATION_WARNINGS
  29. #define JSON_DEPRECATED _JSON_EXTERN
  30. #define JSON_DEPRECATED_FOR(f) _JSON_EXTERN
  31. #define JSON_UNAVAILABLE(maj,min) _JSON_EXTERN
  32. #else
  33. #define JSON_DEPRECATED G_DEPRECATED _JSON_EXTERN
  34. #define JSON_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _JSON_EXTERN
  35. #define JSON_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _JSON_EXTERN
  36. #endif
  37. /* XXX: Each new cycle should add a new version symbol here */
  38. #define JSON_VERSION_1_0 (G_ENCODE_VERSION (1, 0))
  39. #define JSON_VERSION_1_2 (G_ENCODE_VERSION (1, 2))
  40. #define JSON_VERSION_1_4 (G_ENCODE_VERSION (1, 4))
  41. #define JSON_VERSION_1_6 (G_ENCODE_VERSION (1, 6))
  42. /* evaluates to the current stable version; for development cycles,
  43. * this means the next stable target
  44. */
  45. #if (JSON_MINOR_VERSION == 99)
  46. #define JSON_VERSION_CUR_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION + 1, 0))
  47. #elif (JSON_MINOR_VERSION % 2)
  48. #define JSON_VERSION_CUR_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION, JSON_MINOR_VERSION + 1))
  49. #else
  50. #define JSON_VERSION_CUR_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION, JSON_MINOR_VERSION))
  51. #endif
  52. /* evaluates to the previous stable version */
  53. #if (JSON_MINOR_VERSION == 99)
  54. #define JSON_VERSION_PREV_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION + 1, 0))
  55. #elif (JSON_MINOR_VERSION % 2)
  56. #define JSON_VERSION_PREV_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION, JSON_MINOR_VERSION - 1))
  57. #else
  58. #define JSON_VERSION_PREV_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION, JSON_MINOR_VERSION - 2))
  59. #endif
  60. /**
  61. * JSON_VERSION_MIN_REQUIRED:
  62. *
  63. * A macro that should be defined by the user prior to including
  64. * the gdk.h header.
  65. * The definition should be one of the predefined JSON version
  66. * macros: %JSON_VERSION_1_0, %JSON_VERSION_1_2,...
  67. *
  68. * This macro defines the lower bound for the JSON-GLib API to use.
  69. *
  70. * If a function has been deprecated in a newer version of JSON-GLib,
  71. * it is possible to use this symbol to avoid the compiler warnings
  72. * without disabling warning for every deprecated function.
  73. *
  74. * Since: 1.0
  75. */
  76. #ifndef JSON_VERSION_MIN_REQUIRED
  77. # define JSON_VERSION_MIN_REQUIRED (JSON_VERSION_CUR_STABLE)
  78. #endif
  79. /**
  80. * JSON_VERSION_MAX_ALLOWED:
  81. *
  82. * A macro that should be defined by the user prior to including
  83. * the json-glib.h header.
  84. * The definition should be one of the predefined JSON-GLib version
  85. * macros: %JSON_VERSION_1_0, %JSON_VERSION_1_2,...
  86. *
  87. * This macro defines the upper bound for the JSON API-GLib to use.
  88. *
  89. * If a function has been introduced in a newer version of JSON-GLib,
  90. * it is possible to use this symbol to get compiler warnings when
  91. * trying to use that function.
  92. *
  93. * Since: 1.0
  94. */
  95. #ifndef JSON_VERSION_MAX_ALLOWED
  96. # if JSON_VERSION_MIN_REQUIRED > JSON_VERSION_PREV_STABLE
  97. # define JSON_VERSION_MAX_ALLOWED (JSON_VERSION_MIN_REQUIRED)
  98. # else
  99. # define JSON_VERSION_MAX_ALLOWED (JSON_VERSION_CUR_STABLE)
  100. # endif
  101. #endif
  102. /* sanity checks */
  103. #if JSON_VERSION_MAX_ALLOWED < JSON_VERSION_MIN_REQUIRED
  104. #error "JSON_VERSION_MAX_ALLOWED must be >= JSON_VERSION_MIN_REQUIRED"
  105. #endif
  106. #if JSON_VERSION_MIN_REQUIRED < JSON_VERSION_1_0
  107. #error "JSON_VERSION_MIN_REQUIRED must be >= JSON_VERSION_1_0"
  108. #endif
  109. /* XXX: Every new stable minor release should add a set of macros here */
  110. /* 1.0 */
  111. #if JSON_VERSION_MIN_REQUIRED >= JSON_VERSION_1_0
  112. # define JSON_DEPRECATED_IN_1_0 JSON_DEPRECATED
  113. # define JSON_DEPRECATED_IN_1_0_FOR(f) JSON_DEPRECATED_FOR(f)
  114. #else
  115. # define JSON_DEPRECATED_IN_1_0 _JSON_EXTERN
  116. # define JSON_DEPRECATED_IN_1_0_FOR(f) _JSON_EXTERN
  117. #endif
  118. #if JSON_VERSION_MAX_ALLOWED < JSON_VERSION_1_0
  119. # define JSON_AVAILABLE_IN_1_0 JSON_UNAVAILABLE(1, 0)
  120. #else
  121. # define JSON_AVAILABLE_IN_1_0 _JSON_EXTERN
  122. #endif
  123. /* 1.2 */
  124. #if JSON_VERSION_MIN_REQUIRED >= JSON_VERSION_1_2
  125. # define JSON_DEPRECATED_IN_1_2 JSON_DEPRECATED
  126. # define JSON_DEPRECATED_IN_1_2_FOR(f) JSON_DEPRECATED_FOR(f)
  127. #else
  128. # define JSON_DEPRECATED_IN_1_2 _JSON_EXTERN
  129. # define JSON_DEPRECATED_IN_1_2_FOR(f) _JSON_EXTERN
  130. #endif
  131. #if JSON_VERSION_MAX_ALLOWED < JSON_VERSION_1_2
  132. # define JSON_AVAILABLE_IN_1_2 JSON_UNAVAILABLE(1, 2)
  133. #else
  134. # define JSON_AVAILABLE_IN_1_2 _JSON_EXTERN
  135. #endif
  136. /* 1.4 */
  137. #if JSON_VERSION_MIN_REQUIRED >= JSON_VERSION_1_4
  138. # define JSON_DEPRECATED_IN_1_4 JSON_DEPRECATED
  139. # define JSON_DEPRECATED_IN_1_4_FOR(f) JSON_DEPRECATED_FOR(f)
  140. #else
  141. # define JSON_DEPRECATED_IN_1_4 _JSON_EXTERN
  142. # define JSON_DEPRECATED_IN_1_4_FOR(f) _JSON_EXTERN
  143. #endif
  144. #if JSON_VERSION_MAX_ALLOWED < JSON_VERSION_1_4
  145. # define JSON_AVAILABLE_IN_1_4 JSON_UNAVAILABLE(1, 4)
  146. #else
  147. # define JSON_AVAILABLE_IN_1_4 _JSON_EXTERN
  148. #endif
  149. /* 1.6 */
  150. #if JSON_VERSION_MIN_REQUIRED >= JSON_VERSION_1_6
  151. # define JSON_DEPRECATED_IN_1_6 JSON_DEPRECATED
  152. # define JSON_DEPRECATED_IN_1_6_FOR(f) JSON_DEPRECATED_FOR(f)
  153. #else
  154. # define JSON_DEPRECATED_IN_1_6 _JSON_EXTERN
  155. # define JSON_DEPRECATED_IN_1_6_FOR(f) _JSON_EXTERN
  156. #endif
  157. #if JSON_VERSION_MAX_ALLOWED < JSON_VERSION_1_6
  158. # define JSON_AVAILABLE_IN_1_6 JSON_UNAVAILABLE(1, 6)
  159. #else
  160. # define JSON_AVAILABLE_IN_1_6 _JSON_EXTERN
  161. #endif
  162. #endif /* __JSON_VERSION_MACROS_H__ */