[gjs: 6/13] build: Introduce "used only in debug" annotations
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 6/13] build: Introduce "used only in debug" annotations
- Date: Wed, 8 May 2019 13:44:33 +0000 (UTC)
commit 531464bd72779a7b7bf45b461ca67301b95e6ba9
Author: Philip Chimento <philip chimento gmail com>
Date: Wed Mar 27 21:43:33 2019 -0700
build: Introduce "used only in debug" annotations
In some places we have function arguments that are used only in a
gjs_debug_foo() call which is normally #ifdef'd out unless using verbose
debug logging. In order to avoid "unused parameter" warnings, we
introduce annotations to mark that these arguments are only used during
verbose debug logging.
gi/closure.cpp | 3 ++-
gi/object.cpp | 6 ++----
gi/toggle.h | 3 ++-
gi/wrapperutils.h | 16 ++++++++------
gjs/jsapi-util-root.h | 4 +---
util/log.h | 60 +++++++++++++++++++++++++++++++++++----------------
6 files changed, 59 insertions(+), 33 deletions(-)
---
diff --git a/gi/closure.cpp b/gi/closure.cpp
index 6f3885e1..ee67d531 100644
--- a/gi/closure.cpp
+++ b/gi/closure.cpp
@@ -288,7 +288,8 @@ gjs_closure_trace(GClosure *closure,
}
GClosure* gjs_closure_new(JSContext* context, JSFunction* callable,
- const char* description, bool root_function) {
+ const char* description GJS_USED_VERBOSE_GCLOSURE,
+ bool root_function) {
GjsClosure *gc;
Closure *c;
diff --git a/gi/object.cpp b/gi/object.cpp
index ad9ee655..5fc80350 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1020,10 +1020,8 @@ bool ObjectPrototype::props_to_g_parameters(JSContext* context,
return true;
}
-static void
-wrapped_gobj_dispose_notify(gpointer data,
- GObject *where_the_object_was)
-{
+static void wrapped_gobj_dispose_notify(
+ void* data, GObject* where_the_object_was GJS_USED_VERBOSE_LIFECYCLE) {
auto *priv = static_cast<ObjectInstance *>(data);
priv->gobj_dispose_notify();
gjs_debug_lifecycle(GJS_DEBUG_GOBJECT, "Wrapped GObject %p disposed",
diff --git a/gi/toggle.h b/gi/toggle.h
index 7699bf58..d2da51cd 100644
--- a/gi/toggle.h
+++ b/gi/toggle.h
@@ -61,7 +61,8 @@ private:
Handler m_toggle_handler;
/* No-op unless GJS_VERBOSE_ENABLE_LIFECYCLE is defined to 1. */
- inline void debug(const char *did, const void *what) const {
+ inline void debug(const char* did GJS_USED_VERBOSE_LIFECYCLE,
+ const void* what GJS_USED_VERBOSE_LIFECYCLE) {
gjs_debug_lifecycle(GJS_DEBUG_GOBJECT, "ToggleQueue %s %p", did, what);
}
diff --git a/gi/wrapperutils.h b/gi/wrapperutils.h
index 42f8fb9b..ab2a30f1 100644
--- a/gi/wrapperutils.h
+++ b/gi/wrapperutils.h
@@ -290,20 +290,22 @@ class GIWrapperBase {
// Debug methods
protected:
- void debug_lifecycle(const char* message) const {
+ void debug_lifecycle(const char* message GJS_USED_VERBOSE_LIFECYCLE) const {
gjs_debug_lifecycle(
Base::debug_topic, "[%p: %s pointer %p - %s.%s (%s)] %s", this,
Base::debug_tag, ptr_addr(), ns(), name(), type_name(), message);
}
- void debug_lifecycle(const JSObject* obj, const char* message) const {
+ void debug_lifecycle(const JSObject* obj GJS_USED_VERBOSE_LIFECYCLE,
+ const char* message GJS_USED_VERBOSE_LIFECYCLE) const {
gjs_debug_lifecycle(
Base::debug_topic,
"[%p: %s pointer %p - JS wrapper %p - %s.%s (%s)] %s", this,
Base::debug_tag, ptr_addr(), obj, ns(), name(), type_name(),
message);
}
- void debug_jsprop(const char* message, const char* id,
- const JSObject* obj) const {
+ void debug_jsprop(const char* message GJS_USED_VERBOSE_PROPS,
+ const char* id GJS_USED_VERBOSE_PROPS,
+ const JSObject* obj GJS_USED_VERBOSE_PROPS) const {
gjs_debug_jsprop(
Base::debug_topic,
"[%p: %s pointer %p - JS wrapper %p - %s.%s (%s)] %s '%s'", this,
@@ -317,8 +319,10 @@ class GIWrapperBase {
const JSObject* obj) const {
debug_jsprop(message, gjs_debug_string(id).c_str(), obj);
}
- static void debug_jsprop_static(const char* message, jsid id,
- const JSObject* obj) {
+ static void debug_jsprop_static(const char* message GJS_USED_VERBOSE_PROPS,
+ jsid id GJS_USED_VERBOSE_PROPS,
+ const JSObject* obj
+ GJS_USED_VERBOSE_PROPS) {
gjs_debug_jsprop(Base::debug_topic,
"[%s JS wrapper %p] %s '%s', no instance associated",
Base::debug_tag, obj, message,
diff --git a/gjs/jsapi-util-root.h b/gjs/jsapi-util-root.h
index 25b09db8..506e154e 100644
--- a/gjs/jsapi-util-root.h
+++ b/gjs/jsapi-util-root.h
@@ -130,9 +130,7 @@ private:
void *m_data;
/* No-op unless GJS_VERBOSE_ENABLE_LIFECYCLE is defined to 1. */
- inline void
- debug(const char *what)
- {
+ inline void debug(const char* what GJS_USED_VERBOSE_LIFECYCLE) {
gjs_debug_lifecycle(GJS_DEBUG_KEEP_ALIVE, "GjsMaybeOwned %p %s", this,
what);
}
diff --git a/util/log.h b/util/log.h
index a88b8786..69da1428 100644
--- a/util/log.h
+++ b/util/log.h
@@ -103,45 +103,69 @@ typedef enum {
#endif
#if GJS_VERBOSE_ENABLE_PROPS
-#define gjs_debug_jsprop(topic, ...) \
- do { gjs_debug(topic, __VA_ARGS__); } while(0)
+# define GJS_USED_VERBOSE_PROPS
+# define gjs_debug_jsprop(topic, ...) \
+ do { \
+ gjs_debug(topic, __VA_ARGS__); \
+ } while (0)
#else
-#define gjs_debug_jsprop(topic, ...) ((void)0)
+# define GJS_USED_VERBOSE_PROPS G_GNUC_UNUSED
+# define gjs_debug_jsprop(topic, ...) ((void)0)
#endif
#if GJS_VERBOSE_ENABLE_MARSHAL
-#define gjs_debug_marshal(topic, ...) \
- do { gjs_debug(topic, __VA_ARGS__); } while(0)
+# define GJS_USED_VERBOSE_MARSHAL
+# define gjs_debug_marshal(topic, ...) \
+ do { \
+ gjs_debug(topic, __VA_ARGS__); \
+ } while (0)
#else
-#define gjs_debug_marshal(topic, ...) ((void)0)
+# define GJS_USED_VERBOSE_MARSHAL G_GNUC_UNUSED
+# define gjs_debug_marshal(topic, ...) ((void)0)
#endif
#if GJS_VERBOSE_ENABLE_LIFECYCLE
-#define gjs_debug_lifecycle(topic, ...) \
- do { gjs_debug(topic, __VA_ARGS__); } while(0)
+# define GJS_USED_VERBOSE_LIFECYCLE
+# define gjs_debug_lifecycle(topic, ...) \
+ do { \
+ gjs_debug(topic, __VA_ARGS__); \
+ } while (0)
#else
-#define gjs_debug_lifecycle(topic, ...) ((void)0)
+# define GJS_USED_VERBOSE_LIFECYCLE G_GNUC_UNUSED
+# define gjs_debug_lifecycle(topic, ...) ((void)0)
#endif
#if GJS_VERBOSE_ENABLE_GI_USAGE
-#define gjs_debug_gi_usage(...) \
- do { gjs_debug(GJS_DEBUG_GI_USAGE, __VA_ARGS__); } while(0)
+# define GJS_USED_VERBOSE_GI_USAGE
+# define gjs_debug_gi_usage(...) \
+ do { \
+ gjs_debug(GJS_DEBUG_GI_USAGE, __VA_ARGS__); \
+ } while (0)
#else
-#define gjs_debug_gi_usage(...) ((void)0)
+# define GJS_USED_VERBOSE_GI_USAGE G_GNUC_UNUSED
+# define gjs_debug_gi_usage(...) ((void)0)
#endif
#if GJS_VERBOSE_ENABLE_GCLOSURE
-#define gjs_debug_closure(...) \
- do { gjs_debug(GJS_DEBUG_GCLOSURE, __VA_ARGS__); } while(0)
+# define GJS_USED_VERBOSE_GCLOSURE
+# define gjs_debug_closure(...) \
+ do { \
+ gjs_debug(GJS_DEBUG_GCLOSURE, __VA_ARGS__); \
+ } while (0)
#else
-#define gjs_debug_closure(...) ((void)0)
+# define GJS_USED_VERBOSE_GCLOSURE G_GNUC_UNUSED
+# define gjs_debug_closure(...) ((void)0)
#endif
#if GJS_VERBOSE_ENABLE_GSIGNAL
-#define gjs_debug_gsignal(...) \
- do { gjs_debug(GJS_DEBUG_GOBJECT, __VA_ARGS__); } while(0)
+# define GJS_USED_VERBOSE_GSIGNAL
+# define gjs_debug_gsignal(...) \
+ do { \
+ gjs_debug(GJS_DEBUG_GOBJECT, __VA_ARGS__); \
+ } while (0)
#else
-#define gjs_debug_gsignal(...) ((void)0)
+# define GJS_USED_VERBOSE_GSIGNAL G_GNUC_UNUSED
+# define gjs_debug_gsignal(...) ((void)0)
#endif
void gjs_debug(GjsDebugTopic topic,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]