mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibJS: Add the same Object::invoke() overloads as VM::call()
This commit is contained in:
committed by
Andreas Kling
parent
6cf8e3c980
commit
6d2d8d091f
Notes:
sideshowbarker
2024-07-18 21:22:36 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/6d2d8d091fa Pull-request: https://github.com/SerenityOS/serenity/pull/5781
@@ -133,7 +133,19 @@ public:
|
||||
IndexedProperties& indexed_properties() { return m_indexed_properties; }
|
||||
void set_indexed_property_elements(Vector<Value>&& values) { m_indexed_properties = IndexedProperties(move(values)); }
|
||||
|
||||
Value invoke(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments = {});
|
||||
[[nodiscard]] Value invoke_internal(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments);
|
||||
|
||||
template<typename... Args>
|
||||
[[nodiscard]] ALWAYS_INLINE Value invoke(const StringOrSymbol& property_name, Args... args)
|
||||
{
|
||||
if constexpr (sizeof...(Args) > 0) {
|
||||
MarkedValueList arglist { heap() };
|
||||
(..., arglist.append(move(args)));
|
||||
return invoke(property_name, move(arglist));
|
||||
}
|
||||
|
||||
return invoke(property_name);
|
||||
}
|
||||
|
||||
void ensure_shape_is_unique();
|
||||
|
||||
@@ -165,4 +177,13 @@ private:
|
||||
IndexedProperties m_indexed_properties;
|
||||
};
|
||||
|
||||
template<>
|
||||
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(const StringOrSymbol& property_name, MarkedValueList arguments) { return invoke_internal(property_name, move(arguments)); }
|
||||
|
||||
template<>
|
||||
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments) { return invoke_internal(property_name, move(arguments)); }
|
||||
|
||||
template<>
|
||||
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(const StringOrSymbol& property_name) { return invoke(property_name, Optional<MarkedValueList> {}); }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user