1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:37:34 +00:00

LibWeb: Make HostDefined and Intrinsics free functions [[nodiscard]]

Hopefully no one else will forget to call set_prototype with the cached
prototype they just retrieved from a realm and spend a long time
wondering why their object has no properties...
This commit is contained in:
Andrew Kaster 2022-10-08 21:27:21 -06:00 committed by Andreas Kling
parent 2d5bee256e
commit 07b950d8a6
2 changed files with 5 additions and 5 deletions

View file

@ -60,24 +60,24 @@ private:
JS::NonnullGCPtr<JS::Realm> m_realm;
};
inline Intrinsics& host_defined_intrinsics(JS::Realm& realm)
[[nodiscard]] inline Intrinsics& host_defined_intrinsics(JS::Realm& realm)
{
return *verify_cast<HostDefined>(realm.host_defined())->intrinsics;
}
template<typename T>
JS::Object& ensure_web_prototype(JS::Realm& realm, String const& class_name)
[[nodiscard]] JS::Object& ensure_web_prototype(JS::Realm& realm, String const& class_name)
{
return host_defined_intrinsics(realm).ensure_web_prototype<T>(class_name);
}
template<typename T>
JS::NativeFunction& ensure_web_constructor(JS::Realm& realm, String const& class_name)
[[nodiscard]] JS::NativeFunction& ensure_web_constructor(JS::Realm& realm, String const& class_name)
{
return host_defined_intrinsics(realm).ensure_web_constructor<T>(class_name);
}
inline JS::Object& cached_web_prototype(JS::Realm& realm, String const& class_name)
[[nodiscard]] inline JS::Object& cached_web_prototype(JS::Realm& realm, String const& class_name)
{
return host_defined_intrinsics(realm).cached_web_prototype(class_name);
}