From 0c18ec5e5d197a91a1743eeabc4906d51f3d5a0b Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Mon, 26 May 2025 15:10:59 +0200 Subject: [PATCH] Desc: Add obj_desc() / obj_desc_short() overloads for IntrusivePtr When using these helpers in code, one barely has raw pointers and the repeated `.get()` call cumbersome and noisy. --- src/Desc.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Desc.h b/src/Desc.h index ed092cb0b3..b2f4bb56fa 100644 --- a/src/Desc.h +++ b/src/Desc.h @@ -7,6 +7,7 @@ #include #include +#include "zeek/IntrusivePtr.h" #include "zeek/ZeekString.h" // for byte_vec #include "zeek/util.h" // for zeek_int_t @@ -211,13 +212,13 @@ protected: }; // Returns a string representation of an object's description. Used for -// debugging and error messages. takes a bare pointer rather than an -// IntrusivePtr because the latter is harder to deal with when making -// calls from a debugger like lldb, which is the main use of this function. +// debugging and error messages. class Obj; std::string obj_desc(const Obj* o); +inline std::string obj_desc(const IntrusivePtr& o) { return obj_desc(o.get()); } // Same as obj_desc(), but ensure it is short and don't include location info. std::string obj_desc_short(const Obj* o); +inline std::string obj_desc_short(const IntrusivePtr& o) { return obj_desc_short(o.get()); } } // namespace zeek