mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:57:35 +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:
parent
2d5bee256e
commit
07b950d8a6
2 changed files with 5 additions and 5 deletions
|
@ -27,7 +27,7 @@ struct HostDefined : public JS::Realm::HostDefined {
|
||||||
JS::NonnullGCPtr<Intrinsics> intrinsics;
|
JS::NonnullGCPtr<Intrinsics> intrinsics;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline HTML::EnvironmentSettingsObject& host_defined_environment_settings_object(JS::Realm& realm)
|
[[nodiscard]] inline HTML::EnvironmentSettingsObject& host_defined_environment_settings_object(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
return *verify_cast<HostDefined>(realm.host_defined())->environment_settings_object;
|
return *verify_cast<HostDefined>(realm.host_defined())->environment_settings_object;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,24 +60,24 @@ private:
|
||||||
JS::NonnullGCPtr<JS::Realm> m_realm;
|
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;
|
return *verify_cast<HostDefined>(realm.host_defined())->intrinsics;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
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);
|
return host_defined_intrinsics(realm).ensure_web_prototype<T>(class_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
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);
|
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);
|
return host_defined_intrinsics(realm).cached_web_prototype(class_name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue