summaryrefslogtreecommitdiff
path: root/Libraries/LibCore/Object.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-05 14:40:47 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-05 14:40:47 +0100
commitd16f8214d89348062c19908d8651ac94d13c5aa9 (patch)
tree7fcba8afe7ea37927cdf5c23428987d2d10c409c /Libraries/LibCore/Object.cpp
parent37c71bad8a4a0ce158e45a08010c1adfce454766 (diff)
downloadserenity-d16f8214d89348062c19908d8651ac94d13c5aa9.zip
LibCore: Allow RPC clients to specify the currently inspected object
Add a SetInspectedObject call that tells us which Core::Object a remote client is currently looking it. Objects get notified when they gain their first inspector, and when they lose their last one.
Diffstat (limited to 'Libraries/LibCore/Object.cpp')
-rw-r--r--Libraries/LibCore/Object.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/Libraries/LibCore/Object.cpp b/Libraries/LibCore/Object.cpp
index eccdbc967e..ff7e7150ac 100644
--- a/Libraries/LibCore/Object.cpp
+++ b/Libraries/LibCore/Object.cpp
@@ -25,6 +25,7 @@
*/
#include <AK/Assertions.h>
+#include <AK/Badge.h>
#include <AK/JsonObject.h>
#include <LibCore/Event.h>
#include <LibCore/EventLoop.h>
@@ -167,9 +168,9 @@ void Object::deferred_invoke(Function<void(Object&)> invokee)
void Object::save_to(JsonObject& json)
{
json.set("class_name", class_name());
- json.set("address", String::format("%p", this));
+ json.set("address", (uintptr_t)this);
json.set("name", name());
- json.set("parent", String::format("%p", parent()));
+ json.set("parent", (uintptr_t)parent());
}
bool Object::is_ancestor_of(const Object& other) const
@@ -205,6 +206,20 @@ bool Object::is_visible_for_timer_purposes() const
return true;
}
+void Object::increment_inspector_count(Badge<RPCClient>)
+{
+ ++m_inspector_count;
+ if (m_inspector_count == 1)
+ did_begin_inspection();
+}
+
+void Object::decrement_inspector_count(Badge<RPCClient>)
+{
+ --m_inspector_count;
+ if (!m_inspector_count)
+ did_end_inspection();
+}
+
const LogStream& operator<<(const LogStream& stream, const Object& object)
{
return stream << object.class_name() << '{' << &object << '}';