Debian Codegraph @

src/dex-version-macros.h

raw symbols SCIP
1 /*
2 * dex-version-macros.h
3 *
4 * Copyright 2022 Christian Hergert <[email protected]>
5 *
6 * This library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of the
9 * License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * 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 General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * SPDX-License-Identifier: LGPL-2.1-or-later
20 */
21
22 #pragma once
23
24 #include <glib.h>
25
26 #include "dex-version.h"
27
28 #ifndef _DEX_EXTERN
29 # define _DEX_EXTERN extern
30 #endif
31
32 #define DEX_VERSION_CUR_STABLE (G_ENCODE_VERSION (DEX_MAJOR_VERSION, DEX_MINOR_VERSION))
33
34 #ifdef DEX_DISABLE_DEPRECATION_WARNINGS
35 # define DEX_DEPRECATED _DEX_EXTERN
36 # define DEX_DEPRECATED_FOR(f) _DEX_EXTERN
37 # define DEX_UNAVAILABLE(maj,min) _DEX_EXTERN
38 #else
39 # define DEX_DEPRECATED G_DEPRECATED _DEX_EXTERN
40 # define DEX_DEPRECATED_FOR(f) G_DEPRECATED_FOR (f) _DEX_EXTERN
41 # define DEX_UNAVAILABLE(maj,min) G_UNAVAILABLE (maj, min) _DEX_EXTERN
42 #endif
43
44 #define DEX_VERSION_1_0 (G_ENCODE_VERSION (1, 0))
45 #define DEX_VERSION_1_1 (G_ENCODE_VERSION (1, 1))
46 #define DEX_VERSION_1_2 (G_ENCODE_VERSION (1, 2))
47
48 #if DEX_MAJOR_VERSION == DEX_VERSION_1_0
49 # define DEX_VERSION_PREV_STABLE (DEX_VERSION_1_0)
50 #else
51 # define DEX_VERSION_PREV_STABLE (G_ENCODE_VERSION (DEX_MAJOR_VERSION, DEX_MINOR_VERSION - 1))
52 #endif
53
54 /**
55 * DEX_VERSION_MIN_REQUIRED:
56 *
57 * A macro that should be defined by the user prior to including
58 * the dex.h header.
59 *
60 * The definition should be one of the predefined DEX version
61 * macros: %DEX_VERSION_1_0, ...
62 *
63 * This macro defines the lower bound for the Builder API to use.
64 *
65 * If a function has been deprecated in a newer version of Builder,
66 * it is possible to use this symbol to avoid the compiler warnings
67 * without disabling warning for every deprecated function.
68 */
69 #ifndef DEX_VERSION_MIN_REQUIRED
70 # define DEX_VERSION_MIN_REQUIRED (DEX_VERSION_CUR_STABLE)
71 #endif
72
73 /**
74 * DEX_VERSION_MAX_ALLOWED:
75 *
76 * A macro that should be defined by the user prior to including
77 * the dex.h header.
78
79 * The definition should be one of the predefined Builder version
80 * macros: %DEX_VERSION_1_0, %DEX_VERSION_1_2,...
81 *
82 * This macro defines the upper bound for the DEX API to use.
83 *
84 * If a function has been introduced in a newer version of Builder,
85 * it is possible to use this symbol to get compiler warnings when
86 * trying to use that function.
87 */
88 #ifndef DEX_VERSION_MAX_ALLOWED
89 # if DEX_VERSION_MIN_REQUIRED > DEX_VERSION_PREV_STABLE
90 # define DEX_VERSION_MAX_ALLOWED (DEX_VERSION_MIN_REQUIRED)
91 # else
92 # define DEX_VERSION_MAX_ALLOWED (DEX_VERSION_CUR_STABLE)
93 # endif
94 #endif
95
96 #define DEX_AVAILABLE_IN_ALL _DEX_EXTERN
97
98 #if DEX_VERSION_MIN_REQUIRED >= DEX_VERSION_1_0
99 # define DEX_DEPRECATED_IN_1_0 DEX_DEPRECATED
100 # define DEX_DEPRECATED_IN_1_0_FOR(f) DEX_DEPRECATED_FOR(f)
101 #else
102 # define DEX_DEPRECATED_IN_1_0 _DEX_EXTERN
103 # define DEX_DEPRECATED_IN_1_0_FOR(f) _DEX_EXTERN
104 #endif
105 #if DEX_VERSION_MAX_ALLOWED < DEX_VERSION_1_0
106 # define DEX_AVAILABLE_IN_1_0 DEX_UNAVAILABLE(1, 0)
107 #else
108 # define DEX_AVAILABLE_IN_1_0 _DEX_EXTERN
109 #endif
110
111 #if DEX_VERSION_MIN_REQUIRED >= DEX_VERSION_1_1
112 # define DEX_DEPRECATED_IN_1_1 DEX_DEPRECATED
113 # define DEX_DEPRECATED_IN_1_1_FOR(f) DEX_DEPRECATED_FOR(f)
114 #else
115 # define DEX_DEPRECATED_IN_1_1 _DEX_EXTERN
116 # define DEX_DEPRECATED_IN_1_1_FOR(f) _DEX_EXTERN
117 #endif
118 #if DEX_VERSION_MAX_ALLOWED < DEX_VERSION_1_1
119 # define DEX_AVAILABLE_IN_1_1 DEX_UNAVAILABLE(1, 1)
120 #else
121 # define DEX_AVAILABLE_IN_1_1 _DEX_EXTERN
122 #endif
123
124 #if DEX_VERSION_MIN_REQUIRED >= DEX_VERSION_1_2
125 # define DEX_DEPRECATED_IN_1_2 DEX_DEPRECATED
126 # define DEX_DEPRECATED_IN_1_2_FOR(f) DEX_DEPRECATED_FOR(f)
127 #else
128 # define DEX_DEPRECATED_IN_1_2 _DEX_EXTERN
129 # define DEX_DEPRECATED_IN_1_2_FOR(f) _DEX_EXTERN
130 #endif
131 #if DEX_VERSION_MAX_ALLOWED < DEX_VERSION_1_2
132 # define DEX_AVAILABLE_IN_1_2 DEX_UNAVAILABLE(1, 2)
133 #else
134 # define DEX_AVAILABLE_IN_1_2 _DEX_EXTERN
135 #endif
136
137 G_BEGIN_DECLS
138
139 DEX_AVAILABLE_IN_1_1
140 int dex_get_major_version (void);
141 DEX_AVAILABLE_IN_1_1
142 int dex_get_minor_version (void);
143 DEX_AVAILABLE_IN_1_1
144 int dex_get_micro_version (void);
145
146 G_END_DECLS