[gjs: 14/21] maint: Use C++ attributes where available
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 14/21] maint: Use C++ attributes where available
- Date: Sun, 9 Jun 2019 17:03:20 +0000 (UTC)
commit b2e1a39dc0438bd3269492e8fdcf0228e3e55341
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Jun 1 10:25:02 2019 -0700
maint: Use C++ attributes where available
The attributes available in C++14 are [[noreturn]],
[[carries_dependency]], and [[deprecated()]]. We can use these built-in
attributes instead of relying on the platform-specific defines in GLib.
It would be nice to be able to use future attributes such as
[[fallthrough]] and let them take effect as compilers implement them; or
use custom attributes such as [[gjs::jsapi_return_convention]]; but in
C++14, unknown attributes are not yet guaranteed to be ignored. That
happens in C++17.
gi/interface.h | 4 ++--
installed-tests/minijasmine.cpp | 6 +-----
2 files changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/gi/interface.h b/gi/interface.h
index e10bf561..c67dcc3a 100644
--- a/gi/interface.h
+++ b/gi/interface.h
@@ -121,11 +121,11 @@ class InterfaceInstance
friend class GIWrapperBase<InterfaceBase, InterfacePrototype,
InterfaceInstance>;
- G_GNUC_NORETURN InterfaceInstance(JSContext* cx, JS::HandleObject obj)
+ [[noreturn]] InterfaceInstance(JSContext* cx, JS::HandleObject obj)
: GIWrapperInstance(cx, obj) {
g_assert_not_reached();
}
- G_GNUC_NORETURN ~InterfaceInstance(void) { g_assert_not_reached(); }
+ [[noreturn]] ~InterfaceInstance(void) { g_assert_not_reached(); }
};
GJS_JSAPI_RETURN_CONVENTION
diff --git a/installed-tests/minijasmine.cpp b/installed-tests/minijasmine.cpp
index 52960cce..b02a6eb0 100644
--- a/installed-tests/minijasmine.cpp
+++ b/installed-tests/minijasmine.cpp
@@ -31,11 +31,7 @@
#include <gjs/gjs.h>
-G_GNUC_NORETURN
-static void
-bail_out(GjsContext *gjs_context,
- const char *msg)
-{
+[[noreturn]] static void bail_out(GjsContext* gjs_context, const char* msg) {
g_object_unref(gjs_context);
g_print("Bail out! %s\n", msg);
exit(1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]