1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:28:11 +00:00

LibJS: Convert NativeFunction callback to ThrowCompletionOr

This commit is contained in:
Idan Horowitz 2021-10-19 22:53:27 +03:00 committed by Linus Groh
parent 20163c0584
commit ca27e5eff5
13 changed files with 91 additions and 65 deletions

View file

@ -13,7 +13,7 @@
namespace JS {
NativeFunction* NativeFunction::create(GlobalObject& global_object, const FlyString& name, Function<Value(VM&, GlobalObject&)> function)
NativeFunction* NativeFunction::create(GlobalObject& global_object, const FlyString& name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> function)
{
return global_object.heap().allocate<NativeFunction>(global_object, name, move(function), *global_object.function_prototype());
}
@ -28,7 +28,7 @@ NativeFunction::NativeFunction(Object& prototype)
{
}
NativeFunction::NativeFunction(FlyString name, Function<Value(VM&, GlobalObject&)> native_function, Object& prototype)
NativeFunction::NativeFunction(FlyString name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> native_function, Object& prototype)
: FunctionObject(prototype)
, m_name(move(name))
, m_native_function(move(native_function))
@ -186,7 +186,7 @@ ThrowCompletionOr<Object*> NativeFunction::internal_construct(MarkedValueList ar
Value NativeFunction::call()
{
return m_native_function(vm(), global_object());
return TRY_OR_DISCARD(m_native_function(vm(), global_object()));
}
Value NativeFunction::construct(FunctionObject&)