Skip to content

wrapperutils: Use native ostringstream pointer to string conversion

Marco Trevisan requested to merge 3v1n0/gjs:fix-objects-address into master

We were casting the object pointers to integer values and then printing as such. So we were never printing the actual object addresses in hex form (as the prefix suggested).

Add a test checking this.


Another option was to instead do:

diff --git a/gi/wrapperutils.cpp b/gi/wrapperutils.cpp
index 88f8330c..e350987b 100644
--- a/gi/wrapperutils.cpp
+++ b/gi/wrapperutils.cpp
@@ -37,9 +37,9 @@ bool gjs_wrapper_to_string_func(JSContext* context, JSObject* this_obj,
         out << " GType:" << g_type_name(gtype);
     }
 
-    out << " jsobj@0x" << uintptr_t(this_obj);
+    out << " jsobj@0x" << std::hex << uintptr_t(this_obj);
     if (native_address)
-        out << " native@0x" << uintptr_t(native_address);
+        out << " native@0x" << std::hex << uintptr_t(native_address);
 
     out << ']';
 

But I'm not sure there's any need for this, as I guess all the implementations will care will always print pointers as 0x<HEX-value>.

Merge request reports