summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLenny Maiorani <lenny@serenityos.org>2022-03-16 18:26:49 -0600
committerLinus Groh <mail@linusgroh.de>2022-03-19 00:20:46 +0000
commita0367aa43b89b9714a86475407aef5702ae9e79d (patch)
tree5314c918b0698750b0ac1bab1948b370bbfdc363 /Userland
parent5b7a5b3c01007b1ba332310ed1b669bd8b4edebc (diff)
downloadserenity-a0367aa43b89b9714a86475407aef5702ae9e79d.zip
DevTools+LibJS+LibWeb: Change class_name to use StringView
This helps make the overall codebase consistent. `class_name()` in `Kernel` is always `StringView`, but not elsewhere. Additionally, this results in the `strlen` (which needs to be done when printing or other operations) always being computed at compile-time.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h3
-rw-r--r--Userland/Libraries/LibJS/Heap/Cell.h3
-rw-r--r--Userland/Libraries/LibJS/Heap/HeapBlock.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/Accessor.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/BigInt.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/Environment.h5
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.h5
-rw-r--r--Userland/Libraries/LibJS/Runtime/PrimitiveString.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseReaction.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h5
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/Realm.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/Shape.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/Symbol.h3
-rw-r--r--Userland/Libraries/LibWeb/Bindings/AudioConstructor.h3
-rw-r--r--Userland/Libraries/LibWeb/Bindings/ImageConstructor.h3
17 files changed, 37 insertions, 20 deletions
diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h
index 817d014c0d..c44c0e907d 100644
--- a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h
+++ b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h
@@ -9,6 +9,7 @@
#pragma once
#include "DebuggerGlobalJSObject.h"
+#include <AK/StringView.h>
#include <LibDebug/DebugInfo.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Object.h>
@@ -24,7 +25,7 @@ public:
DebuggerVariableJSObject(const Debug::DebugInfo::VariableInfo& variable_info, JS::Object& prototype);
virtual ~DebuggerVariableJSObject() override = default;
- virtual const char* class_name() const override { return m_variable_info.type_name.characters(); }
+ virtual StringView class_name() const override { return m_variable_info.type_name; }
JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override;
diff --git a/Userland/Libraries/LibJS/Heap/Cell.h b/Userland/Libraries/LibJS/Heap/Cell.h
index 295c11b82b..be2d63dfff 100644
--- a/Userland/Libraries/LibJS/Heap/Cell.h
+++ b/Userland/Libraries/LibJS/Heap/Cell.h
@@ -9,6 +9,7 @@
#include <AK/Format.h>
#include <AK/Forward.h>
#include <AK/Noncopyable.h>
+#include <AK/StringView.h>
#include <LibJS/Forward.h>
namespace JS {
@@ -32,7 +33,7 @@ public:
State state() const { return m_state; }
void set_state(State state) { m_state = state; }
- virtual const char* class_name() const = 0;
+ virtual StringView class_name() const = 0;
class Visitor {
public:
diff --git a/Userland/Libraries/LibJS/Heap/HeapBlock.h b/Userland/Libraries/LibJS/Heap/HeapBlock.h
index 03b202317a..750394862c 100644
--- a/Userland/Libraries/LibJS/Heap/HeapBlock.h
+++ b/Userland/Libraries/LibJS/Heap/HeapBlock.h
@@ -8,6 +8,7 @@
#include <AK/IntrusiveList.h>
#include <AK/Platform.h>
+#include <AK/StringView.h>
#include <AK/Types.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>
@@ -98,7 +99,7 @@ private:
struct FreelistEntry final : public Cell {
FreelistEntry* next { nullptr };
- virtual const char* class_name() const override { return "FreelistEntry"; }
+ virtual StringView class_name() const override { return "FreelistEntry"sv; }
};
Cell* cell(size_t index)
diff --git a/Userland/Libraries/LibJS/Runtime/Accessor.h b/Userland/Libraries/LibJS/Runtime/Accessor.h
index 208590a3e1..bd46a87ac8 100644
--- a/Userland/Libraries/LibJS/Runtime/Accessor.h
+++ b/Userland/Libraries/LibJS/Runtime/Accessor.h
@@ -7,6 +7,7 @@
#pragma once
+#include <AK/StringView.h>
#include <LibJS/Runtime/FunctionObject.h>
#include <LibJS/Runtime/VM.h>
@@ -38,7 +39,7 @@ public:
}
private:
- const char* class_name() const override { return "Accessor"; };
+ StringView class_name() const override { return "Accessor"sv; };
FunctionObject* m_getter { nullptr };
FunctionObject* m_setter { nullptr };
diff --git a/Userland/Libraries/LibJS/Runtime/BigInt.h b/Userland/Libraries/LibJS/Runtime/BigInt.h
index 4f74b85f8b..bdba742c50 100644
--- a/Userland/Libraries/LibJS/Runtime/BigInt.h
+++ b/Userland/Libraries/LibJS/Runtime/BigInt.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/StringView.h>
#include <LibCrypto/BigInt/SignedBigInteger.h>
#include <LibJS/Heap/Cell.h>
@@ -20,7 +21,7 @@ public:
const String to_string() const { return String::formatted("{}n", m_big_integer.to_base(10)); }
private:
- virtual const char* class_name() const override { return "BigInt"; }
+ virtual StringView class_name() const override { return "BigInt"sv; }
Crypto::SignedBigInteger m_big_integer;
};
diff --git a/Userland/Libraries/LibJS/Runtime/Environment.h b/Userland/Libraries/LibJS/Runtime/Environment.h
index f6254b7239..62b0618a76 100644
--- a/Userland/Libraries/LibJS/Runtime/Environment.h
+++ b/Userland/Libraries/LibJS/Runtime/Environment.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/StringView.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Object.h>
@@ -19,7 +20,7 @@ struct Variable {
#define JS_ENVIRONMENT(class_, base_class) \
public: \
using Base = base_class; \
- virtual char const* class_name() const override { return #class_; }
+ virtual StringView class_name() const override { return #class_; }
class Environment : public Cell {
public:
@@ -47,7 +48,7 @@ public:
template<typename T>
bool fast_is() const = delete;
- virtual char const* class_name() const override { return "Environment"; }
+ virtual StringView class_name() const override { return "Environment"sv; }
// This flag is set on the entire variable environment chain when direct eval() is performed.
// It is used to disable non-local variable access caching.
diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h
index 430acc243c..01012537c5 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.h
+++ b/Userland/Libraries/LibJS/Runtime/Object.h
@@ -10,6 +10,7 @@
#include <AK/Badge.h>
#include <AK/HashMap.h>
#include <AK/String.h>
+#include <AK/StringView.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/MarkedVector.h>
@@ -27,7 +28,7 @@ namespace JS {
#define JS_OBJECT(class_, base_class) \
public: \
using Base = base_class; \
- virtual const char* class_name() const override { return #class_; }
+ virtual StringView class_name() const override { return #class_; }
struct PrivateElement {
enum class Kind {
@@ -166,7 +167,7 @@ public:
bool has_parameter_map() const { return m_has_parameter_map; }
void set_has_parameter_map() { m_has_parameter_map = true; }
- virtual const char* class_name() const override { return "Object"; }
+ virtual StringView class_name() const override { return "Object"sv; }
virtual void visit_edges(Cell::Visitor&) override;
Value get_direct(size_t index) const { return m_storage[index]; }
diff --git a/Userland/Libraries/LibJS/Runtime/PrimitiveString.h b/Userland/Libraries/LibJS/Runtime/PrimitiveString.h
index 5eaae45562..49b136bcd6 100644
--- a/Userland/Libraries/LibJS/Runtime/PrimitiveString.h
+++ b/Userland/Libraries/LibJS/Runtime/PrimitiveString.h
@@ -7,6 +7,7 @@
#pragma once
#include <AK/String.h>
+#include <AK/StringView.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Runtime/Utf16String.h>
@@ -33,7 +34,7 @@ public:
Optional<Value> get(GlobalObject&, PropertyKey const&) const;
private:
- virtual const char* class_name() const override { return "PrimitiveString"; }
+ virtual StringView class_name() const override { return "PrimitiveString"sv; }
mutable String m_utf8_string;
mutable bool m_has_utf8_string { false };
diff --git a/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h b/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h
index 2c129f2d05..70ea1ab68d 100644
--- a/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h
+++ b/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h
@@ -7,6 +7,7 @@
#pragma once
#include <AK/FlyString.h>
+#include <AK/StringView.h>
#include <AK/Vector.h>
#include <LibJS/Heap/Cell.h>
@@ -35,7 +36,7 @@ public:
void add_private_name(Badge<ClassExpression>, FlyString description);
private:
- virtual char const* class_name() const override { return "PrivateEnvironment"; }
+ virtual StringView class_name() const override { return "PrivateEnvironment"sv; }
virtual void visit_edges(Visitor&) override;
auto find_private_name(FlyString const& description) const
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseReaction.h b/Userland/Libraries/LibJS/Runtime/PromiseReaction.h
index 5640843513..71f1905fc6 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseReaction.h
+++ b/Userland/Libraries/LibJS/Runtime/PromiseReaction.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/StringView.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/JobCallback.h>
#include <LibJS/Runtime/VM.h>
@@ -79,7 +80,7 @@ public:
const Optional<JobCallback>& handler() const { return m_handler; }
private:
- virtual const char* class_name() const override { return "PromiseReaction"; }
+ virtual StringView class_name() const override { return "PromiseReaction"sv; }
virtual void visit_edges(Visitor&) override;
Type m_type;
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h
index cddac8f192..093d4ef605 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h
+++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/StringView.h>
#include <LibJS/Runtime/NativeFunction.h>
#include <LibJS/Runtime/PromiseReaction.h>
@@ -19,7 +20,7 @@ struct RemainingElements final : public Cell {
{
}
- virtual const char* class_name() const override { return "RemainingElements"; }
+ virtual StringView class_name() const override { return "RemainingElements"sv; }
u64 value { 0 };
};
@@ -34,7 +35,7 @@ public:
Vector<Value> const& values() const { return m_values; }
private:
- virtual const char* class_name() const override { return "PromiseValueList"; }
+ virtual StringView class_name() const override { return "PromiseValueList"sv; }
virtual void visit_edges(Visitor&) override;
Vector<Value> m_values;
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h
index b200b0b068..32f732c157 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h
+++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/StringView.h>
#include <LibJS/Runtime/NativeFunction.h>
namespace JS {
@@ -13,7 +14,7 @@ namespace JS {
struct AlreadyResolved final : public Cell {
bool value { false };
- virtual const char* class_name() const override { return "AlreadyResolved"; }
+ virtual StringView class_name() const override { return "AlreadyResolved"sv; }
protected:
// Allocated cells must be >= sizeof(FreelistEntry), which is 24 bytes -
diff --git a/Userland/Libraries/LibJS/Runtime/Realm.h b/Userland/Libraries/LibJS/Runtime/Realm.h
index 551b9675b7..21762ec8e3 100644
--- a/Userland/Libraries/LibJS/Runtime/Realm.h
+++ b/Userland/Libraries/LibJS/Runtime/Realm.h
@@ -8,6 +8,7 @@
#pragma once
#include <AK/OwnPtr.h>
+#include <AK/StringView.h>
#include <AK/Weakable.h>
#include <LibJS/Heap/Cell.h>
@@ -35,7 +36,7 @@ public:
void set_host_defined(OwnPtr<HostDefined> host_defined) { m_host_defined = move(host_defined); }
private:
- virtual char const* class_name() const override { return "Realm"; }
+ virtual StringView class_name() const override { return "Realm"sv; }
virtual void visit_edges(Visitor&) override;
GlobalObject* m_global_object { nullptr }; // [[GlobalObject]]
diff --git a/Userland/Libraries/LibJS/Runtime/Shape.h b/Userland/Libraries/LibJS/Runtime/Shape.h
index ad87ae0d12..a4221c7c49 100644
--- a/Userland/Libraries/LibJS/Runtime/Shape.h
+++ b/Userland/Libraries/LibJS/Runtime/Shape.h
@@ -8,6 +8,7 @@
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
+#include <AK/StringView.h>
#include <AK/WeakPtr.h>
#include <AK/Weakable.h>
#include <LibJS/Forward.h>
@@ -86,7 +87,7 @@ public:
void reconfigure_property_in_unique_shape(const StringOrSymbol& property_key, PropertyAttributes attributes);
private:
- virtual const char* class_name() const override { return "Shape"; }
+ virtual StringView class_name() const override { return "Shape"sv; }
virtual void visit_edges(Visitor&) override;
Shape* get_or_prune_cached_forward_transition(TransitionKey const&);
diff --git a/Userland/Libraries/LibJS/Runtime/Symbol.h b/Userland/Libraries/LibJS/Runtime/Symbol.h
index de42c38c6b..955e3fde56 100644
--- a/Userland/Libraries/LibJS/Runtime/Symbol.h
+++ b/Userland/Libraries/LibJS/Runtime/Symbol.h
@@ -7,6 +7,7 @@
#pragma once
#include <AK/String.h>
+#include <AK/StringView.h>
#include <LibJS/Heap/Cell.h>
namespace JS {
@@ -25,7 +26,7 @@ public:
String to_string() const { return String::formatted("Symbol({})", description()); }
private:
- virtual const char* class_name() const override { return "Symbol"; }
+ virtual StringView class_name() const override { return "Symbol"sv; }
Optional<String> m_description;
bool m_is_global;
diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h
index 7aca1ea916..ee9d825b3d 100644
--- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h
+++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/StringView.h>
#include <LibJS/Runtime/NativeFunction.h>
namespace Web::Bindings {
@@ -21,7 +22,7 @@ public:
private:
virtual bool has_constructor() const override { return true; }
- virtual const char* class_name() const override { return "AudioConstructor"; }
+ virtual StringView class_name() const override { return "AudioConstructor"sv; }
};
}
diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h
index 65cb94b706..a7ecfd75be 100644
--- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h
+++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/StringView.h>
#include <LibJS/Runtime/NativeFunction.h>
namespace Web::Bindings {
@@ -21,7 +22,7 @@ public:
private:
virtual bool has_constructor() const override { return true; }
- virtual const char* class_name() const override { return "ImageConstructor"; }
+ virtual StringView class_name() const override { return "ImageConstructor"sv; }
};
}