[gjs: 2/3] wrapper: Change type of debug addresses to void*
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/3] wrapper: Change type of debug addresses to void*
- Date: Mon, 10 Feb 2020 00:26:39 +0000 (UTC)
commit 738fdb52447f3b99bcd8c063c844e0704c9e7ad2
Author: Philip Chimento <philip chimento gmail com>
Date: Tue Feb 4 15:23:18 2020 +0100
wrapper: Change type of debug addresses to void*
This is in order to make it clear that these pointers are only to be
printed out, not to be accessed.
gi/closure.cpp | 3 ++-
gi/object.cpp | 2 +-
gi/object.h | 2 +-
gi/wrapperutils.h | 11 +++++------
gjs/jsapi-util-root.h | 4 ++--
5 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/gi/closure.cpp b/gi/closure.cpp
index ac162da3..0528062a 100644
--- a/gi/closure.cpp
+++ b/gi/closure.cpp
@@ -281,7 +281,8 @@ gjs_closure_trace(GClosure *closure,
return;
c->func.trace(tracer, "signal connection");
- closure->data = c->func.debug_addr(); // update in case GC moved it
+ // update the saved address (for comparison only) in case GC moved it
+ closure->data = const_cast<void*>(c->func.debug_addr());
}
GClosure* gjs_closure_new(JSContext* context, JSFunction* callable,
diff --git a/gi/object.cpp b/gi/object.cpp
index 5f88df4b..3be5275e 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -174,7 +174,7 @@ void ObjectInstance::unlink(void) {
m_instance_link.unlink();
}
-const JSObject* ObjectBase::jsobj_addr(void) const {
+const void* ObjectBase::jsobj_addr(void) const {
if (is_prototype())
return nullptr;
return to_instance()->m_wrapper.debug_addr();
diff --git a/gi/object.h b/gi/object.h
index 8995e437..4fefc91d 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -127,7 +127,7 @@ class ObjectBase
private:
// This is used in debug methods only.
- GJS_USE const JSObject* jsobj_addr(void) const;
+ GJS_USE const void* jsobj_addr(void) const;
/* Helper methods */
diff --git a/gi/wrapperutils.h b/gi/wrapperutils.h
index 1c3252ef..bcb3203a 100644
--- a/gi/wrapperutils.h
+++ b/gi/wrapperutils.h
@@ -316,7 +316,7 @@ class GIWrapperBase {
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 GJS_USED_VERBOSE_LIFECYCLE,
+ void debug_lifecycle(const void* obj GJS_USED_VERBOSE_LIFECYCLE,
const char* message GJS_USED_VERBOSE_LIFECYCLE) const {
gjs_debug_lifecycle(
Base::debug_topic,
@@ -326,24 +326,23 @@ class GIWrapperBase {
}
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 {
+ const void* 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,
Base::debug_tag, ptr_addr(), obj, ns(), name(), type_name(),
message, id);
}
- void debug_jsprop(const char* message, jsid id, const JSObject* obj) const {
+ void debug_jsprop(const char* message, jsid id, const void* obj) const {
debug_jsprop(message, gjs_debug_id(id).c_str(), obj);
}
void debug_jsprop(const char* message, JSString* id,
- const JSObject* obj) const {
+ const void* obj) const {
debug_jsprop(message, gjs_debug_string(id).c_str(), 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) {
+ const void* 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 5534919a..f8ce4cfc 100644
--- a/gjs/jsapi-util-root.h
+++ b/gjs/jsapi-util-root.h
@@ -203,8 +203,8 @@ class GjsMaybeOwned {
/* Use debug_addr() only for debug logging, because it is unbarriered. */
template <typename U = T>
- GJS_USE const T
- debug_addr(std::enable_if_t<std::is_pointer<U>::value>* = nullptr) const {
+ GJS_USE const void* debug_addr(
+ std::enable_if_t<std::is_pointer<U>::value>* = nullptr) const {
return m_root ? m_root->get() : m_heap.unbarrieredGet();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]