[gjs: 3/12] maint: Replace G_GNUC_... macros with C++ attributes
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 3/12] maint: Replace G_GNUC_... macros with C++ attributes
- Date: Sun, 11 Apr 2021 23:22:50 +0000 (UTC)
commit d0183c3ced3a96171a00876bb8d3d2a574df7fa7
Author: Philip Chimento <philip chimento gmail com>
Date: Fri Mar 12 12:04:11 2021 -0800
maint: Replace G_GNUC_... macros with C++ attributes
Since C++17, the compiler will ignore attributes in a namespace that it
does not care about, so we don't need to use the conditionally defined
macros from GLib.
gjs/global.cpp | 3 ++-
gjs/jsapi-util-error.cpp | 11 +++--------
gjs/jsapi-util.h | 14 ++++++--------
util/log.cpp | 2 ++
util/log.h | 7 ++-----
5 files changed, 15 insertions(+), 22 deletions(-)
---
diff --git a/gjs/global.cpp b/gjs/global.cpp
index 95a39399..1883c445 100644
--- a/gjs/global.cpp
+++ b/gjs/global.cpp
@@ -300,7 +300,8 @@ class GjsInternalGlobal : GjsBaseGlobal {
static bool define_properties(JSContext* cx, JS::HandleObject global,
const char* realm_name,
- const char* bootstrap_script G_GNUC_UNUSED) {
+ const char* bootstrap_script
+ [[maybe_unused]]) {
JS::Realm* realm = JS::GetObjectRealmOrNull(global);
g_assert(realm && "Global object must be associated with a realm");
// const_cast is allowed here if we never free the realm data
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index 28038fec..a966f0f8 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -33,14 +33,9 @@
* So here is an awful hack inspired by
* http://egachine.berlios.de/embedding-sm-best-practice/embedding-sm-best-practice.html#error-handling
*/
-static void
-G_GNUC_PRINTF(4, 0)
-gjs_throw_valist(JSContext *context,
- JSProtoKey error_kind,
- const char *error_name,
- const char *format,
- va_list args)
-{
+[[gnu::format(printf, 4, 0)]] static void gjs_throw_valist(
+ JSContext* context, JSProtoKey error_kind, const char* error_name,
+ const char* format, va_list args) {
char *s;
bool result;
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index a6b66261..933e80a8 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -404,14 +404,12 @@ JSObject* gjs_define_string_array(JSContext* cx, JS::HandleObject obj,
const std::vector<std::string>& strings,
unsigned attrs);
-void gjs_throw (JSContext *context,
- const char *format,
- ...) G_GNUC_PRINTF (2, 3);
-void gjs_throw_custom (JSContext *context,
- JSProtoKey error_kind,
- const char *error_name,
- const char *format,
- ...) G_GNUC_PRINTF (4, 5);
+[[gnu::format(printf, 2, 3)]] void gjs_throw(JSContext* cx, const char* format,
+ ...);
+[[gnu::format(printf, 4, 5)]] void gjs_throw_custom(JSContext* cx,
+ JSProtoKey error_kind,
+ const char* error_name,
+ const char* format, ...);
void gjs_throw_literal (JSContext *context,
const char *string);
bool gjs_throw_gerror_message(JSContext* cx, GError* error);
diff --git a/util/log.cpp b/util/log.cpp
index 728d4c50..c515aab8 100644
--- a/util/log.cpp
+++ b/util/log.cpp
@@ -17,6 +17,8 @@
# include <unistd.h> // for getpid
#endif
+#include <glib.h>
+
#include "util/log.h"
#include "util/misc.h"
diff --git a/util/log.h b/util/log.h
index 9dd1f43f..10e34444 100644
--- a/util/log.h
+++ b/util/log.h
@@ -5,8 +5,6 @@
#ifndef UTIL_LOG_H_
#define UTIL_LOG_H_
-#include <glib.h>
-
/* The idea of this is to be able to have one big log file for the entire
* environment, and grep out what you care about. So each module or app
* should have its own entry in the enum. Be sure to add new enum entries
@@ -149,8 +147,7 @@ typedef enum {
# define gjs_debug_gsignal(...) ((void)0)
#endif
-void gjs_debug(GjsDebugTopic topic,
- const char *format,
- ...) G_GNUC_PRINTF (2, 3);
+[[gnu::format(printf, 2, 3)]] void gjs_debug(GjsDebugTopic topic,
+ const char* format, ...);
#endif // UTIL_LOG_H_
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]