From f0fb7b77a13e5fc9a5053f0b11264d1af9a853cc Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 27 May 2019 19:29:07 +0100 Subject: [PATCH] glib, gobject: Annotate deprecated types and enumerators Use the new `GLIB_DEPRECATED_{TYPE,ENUMERATOR}*` macros to annotate types and enumerators as deprecated, rather than using `G_DISABLE_DEPRECATED`. Signed-off-by: Philip Withnall --- glib/deprecated/gcache.h | 12 ++++++------ glib/deprecated/gthread.h | 28 ++++++++++++---------------- glib/gspawn.h | 6 ++---- glib/gutils.c | 2 ++ glib/gutils.h | 12 ++++++------ gobject/gparam.h | 4 +--- 6 files changed, 29 insertions(+), 35 deletions(-) diff --git a/glib/deprecated/gcache.h b/glib/deprecated/gcache.h index 2885697f9..e1c1f2cde 100644 --- a/glib/deprecated/gcache.h +++ b/glib/deprecated/gcache.h @@ -33,13 +33,13 @@ G_BEGIN_DECLS -#ifndef G_DISABLE_DEPRECATED +typedef struct _GCache GCache GLIB_DEPRECATED_TYPE_IN_2_26_FOR(GHashTable); -typedef struct _GCache GCache; +typedef gpointer (*GCacheNewFunc) (gpointer key) GLIB_DEPRECATED_TYPE_IN_2_26; +typedef gpointer (*GCacheDupFunc) (gpointer value) GLIB_DEPRECATED_TYPE_IN_2_26; +typedef void (*GCacheDestroyFunc) (gpointer value) GLIB_DEPRECATED_TYPE_IN_2_26; -typedef gpointer (*GCacheNewFunc) (gpointer key); -typedef gpointer (*GCacheDupFunc) (gpointer value); -typedef void (*GCacheDestroyFunc) (gpointer value); +G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* Caches */ @@ -68,7 +68,7 @@ void g_cache_value_foreach (GCache *cache, GHFunc func, gpointer user_data); -#endif +G_GNUC_END_IGNORE_DEPRECATIONS G_END_DECLS diff --git a/glib/deprecated/gthread.h b/glib/deprecated/gthread.h index c544bbca0..33b422240 100644 --- a/glib/deprecated/gthread.h +++ b/glib/deprecated/gthread.h @@ -33,7 +33,7 @@ G_BEGIN_DECLS -#ifndef G_DISABLE_DEPRECATED +G_GNUC_BEGIN_IGNORE_DEPRECATIONS typedef enum { @@ -41,9 +41,7 @@ typedef enum G_THREAD_PRIORITY_NORMAL, G_THREAD_PRIORITY_HIGH, G_THREAD_PRIORITY_URGENT -} GThreadPriority; - -#endif +} GThreadPriority GLIB_DEPRECATED_TYPE_IN_2_32; struct _GThread { @@ -54,9 +52,7 @@ struct _GThread GThreadPriority priority; }; -#ifndef G_DISABLE_DEPRECATED - -typedef struct _GThreadFunctions GThreadFunctions; +typedef struct _GThreadFunctions GThreadFunctions GLIB_DEPRECATED_TYPE_IN_2_32; struct _GThreadFunctions { GMutex* (*mutex_new) (void); @@ -93,7 +89,7 @@ struct _GThreadFunctions void (*thread_self) (gpointer thread); gboolean (*thread_equal) (gpointer thread1, gpointer thread2); -}; +} GLIB_DEPRECATED_TYPE_IN_2_32; GLIB_VAR GThreadFunctions g_thread_functions_for_glib_use; GLIB_VAR gboolean g_thread_use_default_impl; @@ -137,7 +133,7 @@ typedef struct /* only for ABI compatibility reasons */ pthread_mutex_t unused; #endif -} GStaticMutex; +} GStaticMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GMutex); #define g_static_mutex_lock(mutex) \ g_mutex_lock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_lock) @@ -153,7 +149,7 @@ void g_static_mutex_free (GStaticMutex *mutex); GLIB_DEPRECATED_IN_2_32_FOR(GMutex) GMutex *g_static_mutex_get_mutex_impl (GStaticMutex *mutex); -typedef struct _GStaticRecMutex GStaticRecMutex; +typedef struct _GStaticRecMutex GStaticRecMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex); struct _GStaticRecMutex { /*< private >*/ @@ -169,7 +165,7 @@ struct _GStaticRecMutex #endif gdouble dummy; } unused; -}; +} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex); #define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT, 0, { 0 } } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rec_mutex_init) GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_init) @@ -194,7 +190,7 @@ guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex); GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_free) void g_static_rec_mutex_free (GStaticRecMutex *mutex); -typedef struct _GStaticRWLock GStaticRWLock; +typedef struct _GStaticRWLock GStaticRWLock GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock); struct _GStaticRWLock { /*< private >*/ @@ -205,7 +201,7 @@ struct _GStaticRWLock gboolean have_writer; guint want_to_read; guint want_to_write; -}; +} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock); #define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, 0, 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rw_lock_init) @@ -236,12 +232,12 @@ void g_static_rw_lock_free (GStaticRWLock *lock); GLIB_DEPRECATED_IN_2_32 GPrivate * g_private_new (GDestroyNotify notify); -typedef struct _GStaticPrivate GStaticPrivate; +typedef struct _GStaticPrivate GStaticPrivate GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate); struct _GStaticPrivate { /*< private >*/ guint index; -}; +} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate); #define G_STATIC_PRIVATE_INIT { 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(G_PRIVATE_INIT) GLIB_DEPRECATED_IN_2_32 @@ -286,7 +282,7 @@ gboolean g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *timeval); -#endif +G_GNUC_END_IGNORE_DEPRECATIONS G_END_DECLS diff --git a/glib/gspawn.h b/glib/gspawn.h index d6b0be7d0..240aae768 100644 --- a/glib/gspawn.h +++ b/glib/gspawn.h @@ -46,7 +46,7 @@ G_BEGIN_DECLS * @G_SPAWN_ERROR_ACCES: execv() returned `EACCES` * @G_SPAWN_ERROR_PERM: execv() returned `EPERM` * @G_SPAWN_ERROR_TOO_BIG: execv() returned `E2BIG` - * @G_SPAWN_ERROR_2BIG: deprecated alias for %G_SPAWN_ERROR_TOO_BIG + * @G_SPAWN_ERROR_2BIG: deprecated alias for %G_SPAWN_ERROR_TOO_BIG (deprecated since GLib 2.32) * @G_SPAWN_ERROR_NOEXEC: execv() returned `ENOEXEC` * @G_SPAWN_ERROR_NAMETOOLONG: execv() returned `ENAMETOOLONG` * @G_SPAWN_ERROR_NOENT: execv() returned `ENOENT` @@ -73,9 +73,7 @@ typedef enum G_SPAWN_ERROR_ACCES, /* execv() returned EACCES */ G_SPAWN_ERROR_PERM, /* execv() returned EPERM */ G_SPAWN_ERROR_TOO_BIG,/* execv() returned E2BIG */ -#ifndef G_DISABLE_DEPRECATED - G_SPAWN_ERROR_2BIG = G_SPAWN_ERROR_TOO_BIG, -#endif + G_SPAWN_ERROR_2BIG GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(G_SPAWN_ERROR_TOO_BIG) = G_SPAWN_ERROR_TOO_BIG, G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */ G_SPAWN_ERROR_NAMETOOLONG, /* "" "" ENAMETOOLONG */ G_SPAWN_ERROR_NOENT, /* "" "" ENOENT */ diff --git a/glib/gutils.c b/glib/gutils.c index 9e2f0b0b7..87db6a1f3 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -218,6 +218,7 @@ _glib_get_dll_directory (void) * * Deprecated:2.32: It is best to avoid g_atexit(). */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS void g_atexit (GVoidFunc func) { @@ -232,6 +233,7 @@ g_atexit (GVoidFunc func) g_strerror (errsv)); } } +G_GNUC_END_IGNORE_DEPRECATIONS /* Based on execvp() from GNU Libc. * Some of this code is cut-and-pasted into gspawn.c diff --git a/glib/gutils.h b/glib/gutils.h index 055ca4605..560a84e3a 100644 --- a/glib/gutils.h +++ b/glib/gutils.h @@ -198,7 +198,6 @@ gchar *g_format_size_for_display (goffset size); #define g_memmove(dest,src,len) \ G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_40_FOR(memmove) -#ifndef G_DISABLE_DEPRECATED /** * GVoidFunc: * @@ -206,10 +205,13 @@ gchar *g_format_size_for_display (goffset size); * and has no return value. It is used to specify the type * function passed to g_atexit(). */ -typedef void (*GVoidFunc) (void); -#define ATEXIT(proc) g_ATEXIT(proc) +typedef void (*GVoidFunc) (void) GLIB_DEPRECATED_TYPE_IN_2_32; +#define ATEXIT(proc) g_ATEXIT(proc) GLIB_DEPRECATED_MACRO_IN_2_32 + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS GLIB_DEPRECATED void g_atexit (GVoidFunc func); +G_GNUC_END_IGNORE_DEPRECATIONS #ifdef G_OS_WIN32 /* It's a bad idea to wrap atexit() on Windows. If the GLib DLL calls @@ -221,9 +223,7 @@ void g_atexit (GVoidFunc func); #if (defined(__MINGW_H) && !defined(_STDLIB_H_)) || (defined(_MSC_VER) && !defined(_INC_STDLIB)) int atexit (void (*)(void)); #endif -#define g_atexit(func) atexit(func) -#endif - +#define g_atexit(func) atexit(func) GLIB_DEPRECATED_MACRO_IN_2_32 #endif diff --git a/gobject/gparam.h b/gobject/gparam.h index 535b98035..97a90dbe4 100644 --- a/gobject/gparam.h +++ b/gobject/gparam.h @@ -156,9 +156,7 @@ typedef enum G_PARAM_CONSTRUCT_ONLY = 1 << 3, G_PARAM_LAX_VALIDATION = 1 << 4, G_PARAM_STATIC_NAME = 1 << 5, -#ifndef G_DISABLE_DEPRECATED - G_PARAM_PRIVATE = G_PARAM_STATIC_NAME, -#endif + G_PARAM_PRIVATE GLIB_DEPRECATED_ENUMERATOR_IN_2_26 = G_PARAM_STATIC_NAME, G_PARAM_STATIC_NICK = 1 << 6, G_PARAM_STATIC_BLURB = 1 << 7, /* User defined flags go here */