LibJS: Remove old Native Functions
Now that all the usages were updated to the new ThrowCompletionOr based version we can remove the legacy version.
This commit is contained in:
parent
9d1fb85f93
commit
2eaed880b1
Notes:
sideshowbarker
2024-07-18 01:40:41 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/2eaed880b11 Pull-request: https://github.com/SerenityOS/serenity/pull/10728
3 changed files with 0 additions and 44 deletions
|
@ -6,12 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define JS_DECLARE_OLD_NATIVE_FUNCTION(name) \
|
||||
static JS::Value name(JS::VM&, JS::GlobalObject&)
|
||||
|
||||
#define JS_DEFINE_OLD_NATIVE_FUNCTION(name) \
|
||||
JS::Value name([[maybe_unused]] JS::VM& vm, [[maybe_unused]] JS::GlobalObject& global_object)
|
||||
|
||||
#define JS_DECLARE_NATIVE_FUNCTION(name) \
|
||||
static JS::ThrowCompletionOr<JS::Value> name(JS::VM&, JS::GlobalObject&)
|
||||
|
||||
|
|
|
@ -1045,29 +1045,6 @@ void Object::set_prototype(Object* new_prototype)
|
|||
m_shape = shape.create_prototype_transition(new_prototype);
|
||||
}
|
||||
|
||||
void Object::define_old_native_accessor(PropertyKey const& property_name, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attribute)
|
||||
{
|
||||
Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> completion_getter = {};
|
||||
if (getter) {
|
||||
completion_getter = [getter = move(getter)](auto& vm, auto& global_object) -> ThrowCompletionOr<Value> {
|
||||
auto result = getter(vm, global_object);
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
return result;
|
||||
};
|
||||
}
|
||||
Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> completion_setter = {};
|
||||
if (setter) {
|
||||
completion_setter = [setter = move(setter)](auto& vm, auto& global_object) -> ThrowCompletionOr<Value> {
|
||||
auto result = setter(vm, global_object);
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
return result;
|
||||
};
|
||||
}
|
||||
define_native_accessor(property_name, move(completion_getter), move(completion_setter), attribute);
|
||||
}
|
||||
|
||||
void Object::define_native_accessor(PropertyKey const& property_name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> getter, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> setter, PropertyAttributes attribute)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
|
@ -1134,17 +1111,6 @@ Value Object::get_without_side_effects(const PropertyKey& property_name) const
|
|||
return {};
|
||||
}
|
||||
|
||||
void Object::define_old_native_function(PropertyKey const& property_name, Function<Value(VM&, GlobalObject&)> native_function, i32 length, PropertyAttributes attribute)
|
||||
{
|
||||
auto completion_native_function = [native_function = move(native_function), property_name](auto& vm, auto& global_object) -> ThrowCompletionOr<Value> {
|
||||
auto result = native_function(vm, global_object);
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
return result;
|
||||
};
|
||||
define_native_function(property_name, move(completion_native_function), length, attribute);
|
||||
}
|
||||
|
||||
void Object::define_native_function(PropertyKey const& property_name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> native_function, i32 length, PropertyAttributes attribute)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
|
|
|
@ -148,10 +148,6 @@ public:
|
|||
void define_direct_property(PropertyKey const& property_name, Value value, PropertyAttributes attributes) { storage_set(property_name, { value, attributes }); };
|
||||
void define_direct_accessor(PropertyKey const&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes);
|
||||
|
||||
// Legacy methods - Remove once JS_DECLARE_OLD_NATIVE_FUNCTION is removed
|
||||
void define_old_native_function(PropertyKey const&, Function<Value(VM&, GlobalObject&)>, i32 length, PropertyAttributes attributes);
|
||||
void define_old_native_accessor(PropertyKey const&, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attributes);
|
||||
|
||||
void define_native_function(PropertyKey const&, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>, i32 length, PropertyAttributes attributes);
|
||||
void define_native_accessor(PropertyKey const&, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> getter, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> setter, PropertyAttributes attributes);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue