Skip to content

Commit ef8347b

Browse files
Update existing deprecation attributes and formatting
- Replace use of `BSON_GNUC_DEPRECATED...` with `BSON_DEPRECATED...` - Reformat attribute macros as attributes according to clang-format. - Give dense API listings in public headers some breathing room.
1 parent c17b30f commit ef8347b

22 files changed

+776
-388
lines changed

src/libbson/src/bson/bson-atomic.h

+92-80
Large diffs are not rendered by default.

src/libbson/src/bson/bson-cmp.h

+48-37
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#define BSON_BEGIN_IGNORE_DEPRECATIONS \
4040
_Pragma ("clang diagnostic push") _Pragma ("clang diagnostic ignored \"-Wdeprecated-declarations\"")
4141
#define BSON_END_IGNORE_DEPRECATIONS _Pragma ("clang diagnostic pop")
42+
#elif defined(_MSC_VER)
43+
#define BSON_BEGIN_IGNORE_DEPRECATIONS __pragma (warning (push)) __pragma (warning (disable : 4996))
44+
#define BSON_END_IGNORE_DEPRECATIONS __pragma (warning (pop))
4245
#else
4346
#define BSON_BEGIN_IGNORE_DEPRECATIONS
4447
#define BSON_END_IGNORE_DEPRECATIONS
@@ -70,25 +73,29 @@ BSON_BEGIN_DECLS
7073
* recommended.
7174
*/
7275

73-
#define BSON_CMP_SET(op, ss, uu, su, us) \
74-
static BSON_INLINE bool BSON_GNUC_DEPRECATED BSON_CONCAT3 (bson_cmp_, op, _ss) (int64_t t, int64_t u) \
75-
{ \
76-
return (ss); \
77-
} \
78-
\
79-
static BSON_INLINE bool BSON_GNUC_DEPRECATED BSON_CONCAT3 (bson_cmp_, op, _uu) (uint64_t t, uint64_t u) \
80-
{ \
81-
return (uu); \
82-
} \
83-
\
84-
static BSON_INLINE bool BSON_GNUC_DEPRECATED BSON_CONCAT3 (bson_cmp_, op, _su) (int64_t t, uint64_t u) \
85-
{ \
86-
return (su); \
87-
} \
88-
\
89-
static BSON_INLINE bool BSON_GNUC_DEPRECATED BSON_CONCAT3 (bson_cmp_, op, _us) (uint64_t t, int64_t u) \
90-
{ \
91-
return (us); \
76+
#define BSON_CMP_SET(op, ss, uu, su, us) \
77+
static BSON_INLINE BSON_DEPRECATED ("<bson/bson-cmp.h> APIs are deprecated") bool BSON_CONCAT3 ( \
78+
bson_cmp_, op, _ss) (int64_t t, int64_t u) \
79+
{ \
80+
return (ss); \
81+
} \
82+
\
83+
static BSON_INLINE BSON_DEPRECATED ("<bson/bson-cmp.h> APIs are deprecated") bool BSON_CONCAT3 ( \
84+
bson_cmp_, op, _uu) (uint64_t t, uint64_t u) \
85+
{ \
86+
return (uu); \
87+
} \
88+
\
89+
static BSON_INLINE BSON_DEPRECATED ("<bson/bson-cmp.h> APIs are deprecated") bool BSON_CONCAT3 ( \
90+
bson_cmp_, op, _su) (int64_t t, uint64_t u) \
91+
{ \
92+
return (su); \
93+
} \
94+
\
95+
static BSON_INLINE BSON_DEPRECATED ("<bson/bson-cmp.h> APIs are deprecated") bool BSON_CONCAT3 ( \
96+
bson_cmp_, op, _us) (uint64_t t, int64_t u) \
97+
{ \
98+
return (us); \
9299
}
93100

94101
BSON_CMP_SET (equal, t == u, t == u, t < 0 ? false : (uint64_t) (t) == u, u < 0 ? false : t == (uint64_t) (u))
@@ -121,28 +128,32 @@ BSON_CMP_SET (greater_equal,
121128

122129
/* Return true if the given value is within the range of the corresponding
123130
* signed type. The suffix must match the signedness of the given value. */
124-
#define BSON_IN_RANGE_SET_SIGNED(Type, min, max) \
125-
static BSON_INLINE bool BSON_GNUC_DEPRECATED BSON_CONCAT3 (bson_in_range, _##Type, _signed) (int64_t value) \
126-
{ \
127-
return bson_cmp_greater_equal_ss (value, min) && bson_cmp_less_equal_ss (value, max); \
128-
} \
129-
\
130-
static BSON_INLINE bool BSON_GNUC_DEPRECATED BSON_CONCAT3 (bson_in_range, _##Type, _unsigned) (uint64_t value) \
131-
{ \
132-
return bson_cmp_greater_equal_us (value, min) && bson_cmp_less_equal_us (value, max); \
131+
#define BSON_IN_RANGE_SET_SIGNED(Type, min, max) \
132+
static BSON_INLINE BSON_DEPRECATED ("<bson/bson-cmp.h> APIs are deprecated") bool BSON_CONCAT3 ( \
133+
bson_in_range, _##Type, _signed) (int64_t value) \
134+
{ \
135+
return bson_cmp_greater_equal_ss (value, min) && bson_cmp_less_equal_ss (value, max); \
136+
} \
137+
\
138+
static BSON_INLINE BSON_DEPRECATED ("<bson/bson-cmp.h> APIs are deprecated") bool BSON_CONCAT3 ( \
139+
bson_in_range, _##Type, _unsigned) (uint64_t value) \
140+
{ \
141+
return bson_cmp_greater_equal_us (value, min) && bson_cmp_less_equal_us (value, max); \
133142
}
134143

135144
/* Return true if the given value is within the range of the corresponding
136145
* unsigned type. The suffix must match the signedness of the given value. */
137-
#define BSON_IN_RANGE_SET_UNSIGNED(Type, max) \
138-
static BSON_INLINE bool BSON_GNUC_DEPRECATED BSON_CONCAT3 (bson_in_range, _##Type, _signed) (int64_t value) \
139-
{ \
140-
return bson_cmp_greater_equal_su (value, 0u) && bson_cmp_less_equal_su (value, max); \
141-
} \
142-
\
143-
static BSON_INLINE bool BSON_GNUC_DEPRECATED BSON_CONCAT3 (bson_in_range, _##Type, _unsigned) (uint64_t value) \
144-
{ \
145-
return bson_cmp_less_equal_uu (value, max); \
146+
#define BSON_IN_RANGE_SET_UNSIGNED(Type, max) \
147+
static BSON_INLINE BSON_DEPRECATED ("<bson/bson-cmp.h> APIs are deprecated") bool BSON_CONCAT3 ( \
148+
bson_in_range, _##Type, _signed) (int64_t value) \
149+
{ \
150+
return bson_cmp_greater_equal_su (value, 0u) && bson_cmp_less_equal_su (value, max); \
151+
} \
152+
\
153+
static BSON_INLINE BSON_DEPRECATED ("<bson/bson-cmp.h> APIs are deprecated") bool BSON_CONCAT3 ( \
154+
bson_in_range, _##Type, _unsigned) (uint64_t value) \
155+
{ \
156+
return bson_cmp_less_equal_uu (value, max); \
146157
}
147158

148159
BSON_IN_RANGE_SET_SIGNED (signed_char, SCHAR_MIN, SCHAR_MAX)

src/libbson/src/bson/bson-md5.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ typedef struct {
7373
} bson_md5_t;
7474

7575

76-
BSON_EXPORT (void)
77-
bson_md5_init (bson_md5_t *pms) BSON_GNUC_DEPRECATED;
78-
BSON_EXPORT (void)
79-
bson_md5_append (bson_md5_t *pms, const uint8_t *data, uint32_t nbytes) BSON_GNUC_DEPRECATED;
80-
BSON_EXPORT (void)
81-
bson_md5_finish (bson_md5_t *pms, uint8_t digest[16]) BSON_GNUC_DEPRECATED;
76+
BSON_DEPRECATED ("<bson/bson-md5.h> APIs are deprecated") BSON_EXPORT (void) bson_md5_init (bson_md5_t *pms);
77+
78+
BSON_DEPRECATED ("<bson/bson-md5.h> APIs are deprecated")
79+
BSON_EXPORT (void) bson_md5_append (bson_md5_t *pms, const uint8_t *data, uint32_t nbytes);
80+
81+
BSON_DEPRECATED ("<bson/bson-md5.h> APIs are deprecated")
82+
BSON_EXPORT (void) bson_md5_finish (bson_md5_t *pms, uint8_t digest[16]);
8283

8384

8485
BSON_END_DECLS

src/libbson/src/bson/bson-oid.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ BSON_EXPORT (void)
5050
bson_oid_init_from_data (bson_oid_t *oid, const uint8_t *data);
5151
BSON_EXPORT (void)
5252
bson_oid_init_from_string (bson_oid_t *oid, const char *str);
53-
BSON_EXPORT (void)
54-
bson_oid_init_sequence (bson_oid_t *oid, bson_context_t *context) BSON_GNUC_DEPRECATED_FOR (bson_oid_init);
53+
BSON_DEPRECATED_FOR (bson_oid_init)
54+
BSON_EXPORT (void) bson_oid_init_sequence (bson_oid_t *oid, bson_context_t *context);
5555
BSON_EXPORT (void)
5656
bson_oid_to_string (const bson_oid_t *oid, char str[25]);
5757

src/libbson/src/bson/bson-string.h

+31-14
Original file line numberDiff line numberDiff line change
@@ -37,42 +37,59 @@ typedef struct {
3737
} bson_string_t;
3838

3939

40-
BSON_EXPORT (bson_string_t *)
41-
bson_string_new (const char *str) BSON_GNUC_DEPRECATED;
42-
BSON_EXPORT (char *)
43-
bson_string_free (bson_string_t *string, bool free_segment) BSON_GNUC_DEPRECATED;
44-
BSON_EXPORT (void)
45-
bson_string_append (bson_string_t *string, const char *str) BSON_GNUC_DEPRECATED;
46-
BSON_EXPORT (void)
47-
bson_string_append_c (bson_string_t *string, char str) BSON_GNUC_DEPRECATED;
48-
BSON_EXPORT (void)
49-
bson_string_append_unichar (bson_string_t *string, bson_unichar_t unichar) BSON_GNUC_DEPRECATED;
50-
BSON_EXPORT (void)
51-
bson_string_append_printf (bson_string_t *string, const char *format, ...) BSON_GNUC_PRINTF (2, 3) BSON_GNUC_DEPRECATED;
52-
BSON_EXPORT (void)
53-
bson_string_truncate (bson_string_t *string, uint32_t len) BSON_GNUC_DEPRECATED;
40+
BSON_DEPRECATED ("bson_string_t APIs are deprecated") BSON_EXPORT (bson_string_t *) bson_string_new (const char *str);
41+
42+
BSON_DEPRECATED ("bson_string_t APIs are deprecated")
43+
BSON_EXPORT (char *) bson_string_free (bson_string_t *string, bool free_segment);
44+
45+
BSON_DEPRECATED ("bson_string_t APIs are deprecated")
46+
BSON_EXPORT (void) bson_string_append (bson_string_t *string, const char *str);
47+
48+
BSON_DEPRECATED ("bson_string_t APIs are deprecated")
49+
BSON_EXPORT (void) bson_string_append_c (bson_string_t *string, char str);
50+
51+
BSON_DEPRECATED ("bson_string_t APIs are deprecated")
52+
BSON_EXPORT (void) bson_string_append_unichar (bson_string_t *string, bson_unichar_t unichar);
53+
54+
BSON_DEPRECATED ("bson_string_t APIs are deprecated")
55+
BSON_EXPORT (void) bson_string_append_printf (bson_string_t *string, const char *format, ...) BSON_GNUC_PRINTF (2, 3);
56+
57+
BSON_DEPRECATED ("bson_string_t APIs are deprecated")
58+
BSON_EXPORT (void) bson_string_truncate (bson_string_t *string, uint32_t len);
59+
5460
BSON_EXPORT (char *)
5561
bson_strdup (const char *str);
62+
5663
BSON_EXPORT (char *)
5764
bson_strdup_printf (const char *format, ...) BSON_GNUC_PRINTF (1, 2);
65+
5866
BSON_EXPORT (char *)
5967
bson_strdupv_printf (const char *format, va_list args) BSON_GNUC_PRINTF (1, 0);
68+
6069
BSON_EXPORT (char *)
6170
bson_strndup (const char *str, size_t n_bytes);
71+
6272
BSON_EXPORT (void)
6373
bson_strncpy (char *dst, const char *src, size_t size);
74+
6475
BSON_EXPORT (int)
6576
bson_vsnprintf (char *str, size_t size, const char *format, va_list ap) BSON_GNUC_PRINTF (3, 0);
77+
6678
BSON_EXPORT (int)
6779
bson_snprintf (char *str, size_t size, const char *format, ...) BSON_GNUC_PRINTF (3, 4);
80+
6881
BSON_EXPORT (void)
6982
bson_strfreev (char **strv);
83+
7084
BSON_EXPORT (size_t)
7185
bson_strnlen (const char *s, size_t maxlen);
86+
7287
BSON_EXPORT (int64_t)
7388
bson_ascii_strtoll (const char *str, char **endptr, int base);
89+
7490
BSON_EXPORT (int)
7591
bson_strcasecmp (const char *s1, const char *s2);
92+
7693
BSON_EXPORT (bool)
7794
bson_isspace (int c);
7895

src/libbson/src/bson/bson.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ bson_copy_to (const bson_t *src, bson_t *dst);
302302
* more fields in a bson_t. Note that bson_init() will be called
303303
* on dst.
304304
*/
305+
BSON_DEPRECATED_FOR (bson_copy_to_excluding_noinit)
305306
BSON_EXPORT (void)
306-
bson_copy_to_excluding (const bson_t *src, bson_t *dst, const char *first_exclude, ...) BSON_GNUC_NULL_TERMINATED
307-
BSON_GNUC_DEPRECATED_FOR (bson_copy_to_excluding_noinit);
307+
bson_copy_to_excluding (const bson_t *src, bson_t *dst, const char *first_exclude, ...) BSON_GNUC_NULL_TERMINATED;
308308

309309
/**
310310
* bson_copy_to_excluding_noinit:
@@ -532,7 +532,7 @@ bson_as_canonical_extended_json (const bson_t *bson, size_t *length);
532532
* Returns: A newly allocated string that should be freed with bson_free().
533533
*/
534534
BSON_EXPORT (char *)
535-
bson_as_json (const bson_t *bson, size_t *length) BSON_GNUC_DEPRECATED_FOR (bson_as_legacy_extended_json);
535+
bson_as_json (const bson_t *bson, size_t *length);
536536

537537
// `bson_as_legacy_extended_json` is a non-deprecated form of `bson_as_json`.
538538
BSON_EXPORT (char *)
@@ -562,8 +562,8 @@ bson_as_relaxed_extended_json (const bson_t *bson, size_t *length);
562562

563563

564564
/* like bson_as_json() but for outermost arrays. */
565-
BSON_EXPORT (char *)
566-
bson_array_as_json (const bson_t *bson, size_t *length) BSON_GNUC_DEPRECATED_FOR (bson_array_as_legacy_extended_json);
565+
BSON_DEPRECATED_FOR (bson_array_as_legacy_extended_json)
566+
BSON_EXPORT (char *) bson_array_as_json (const bson_t *bson, size_t *length);
567567

568568
// `bson_array_as_legacy_extended_json` is a non-deprecated form of `bson_array_as_json`.
569569
BSON_EXPORT (char *)

0 commit comments

Comments
 (0)