From 20163c058485dc524402c46f21bbe65a860bf9c5 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Tue, 19 Oct 2021 20:18:01 +0300 Subject: LibJS: Add ThrowCompletionOr versions of the JS native function macros The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all native functions were converted to the new format. --- .../LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp | 2 +- .../LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h | 2 +- .../Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp | 4 ++-- .../Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h | 4 ++-- Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp | 6 +++--- Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h | 6 +++--- .../Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp | 8 ++++---- Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h | 8 ++++---- 8 files changed, 20 insertions(+), 20 deletions(-) (limited to 'Userland/Libraries/LibWeb/WebAssembly') diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp index 1db0997d0f..0d2f71f6af 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp @@ -16,7 +16,7 @@ void WebAssemblyInstancePrototype::initialize(JS::GlobalObject& global_object) define_native_accessor("exports", exports_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable); } -JS_DEFINE_NATIVE_FUNCTION(WebAssemblyInstancePrototype::exports_getter) +JS_DEFINE_OLD_NATIVE_FUNCTION(WebAssemblyInstancePrototype::exports_getter) { auto this_value = vm.this_value(global_object); auto* this_object = TRY_OR_DISCARD(this_value.to_object(global_object)); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h index fff25310e1..4417787135 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h @@ -25,7 +25,7 @@ public: virtual void initialize(JS::GlobalObject&) override; private: - JS_DECLARE_NATIVE_FUNCTION(exports_getter); + JS_DECLARE_OLD_NATIVE_FUNCTION(exports_getter); static JS::Handle s_instance; }; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp index bc4020ce7a..ec85d245bd 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp @@ -17,7 +17,7 @@ void WebAssemblyMemoryPrototype::initialize(JS::GlobalObject& global_object) define_native_function("grow", grow, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); } -JS_DEFINE_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::grow) +JS_DEFINE_OLD_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::grow) { auto page_count = TRY_OR_DISCARD(vm.argument(0).to_u32(global_object)); auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); @@ -40,7 +40,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::grow) return JS::Value(static_cast(previous_size)); } -JS_DEFINE_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::buffer_getter) +JS_DEFINE_OLD_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::buffer_getter) { auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); if (!is(this_object)) { diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h index 74fd7b0322..00f54c8692 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h @@ -27,8 +27,8 @@ public: virtual void initialize(JS::GlobalObject&) override; private: - JS_DECLARE_NATIVE_FUNCTION(grow); - JS_DECLARE_NATIVE_FUNCTION(buffer_getter); + JS_DECLARE_OLD_NATIVE_FUNCTION(grow); + JS_DECLARE_OLD_NATIVE_FUNCTION(buffer_getter); }; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp index 51e21fbdde..1c4b72c4c2 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp @@ -87,7 +87,7 @@ void WebAssemblyObject::visit_edges(Visitor& visitor) } } -JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::validate) +JS_DEFINE_OLD_NATIVE_FUNCTION(WebAssemblyObject::validate) { // FIXME: Implement this once module validation is implemented in LibWasm. dbgln("Hit WebAssemblyObject::validate() stub!"); @@ -127,7 +127,7 @@ Result parse_module(JS::GlobalObject& global_object, JS::Obje return WebAssemblyObject::s_compiled_modules.size() - 1; } -JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::compile) +JS_DEFINE_OLD_NATIVE_FUNCTION(WebAssemblyObject::compile) { // FIXME: This shouldn't block! auto buffer_or_error = vm.argument(0).to_object(global_object); @@ -308,7 +308,7 @@ Result WebAssemblyObject::instantiate_module(Wasm::Module con return s_instantiated_modules.size() - 1; } -JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::instantiate) +JS_DEFINE_OLD_NATIVE_FUNCTION(WebAssemblyObject::instantiate) { // FIXME: This shouldn't block! auto buffer_or_error = vm.argument(0).to_object(global_object); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h index 2c0eae4349..4bc959472f 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h @@ -60,9 +60,9 @@ public: static Wasm::AbstractMachine s_abstract_machine; private: - JS_DECLARE_NATIVE_FUNCTION(validate); - JS_DECLARE_NATIVE_FUNCTION(compile); - JS_DECLARE_NATIVE_FUNCTION(instantiate); + JS_DECLARE_OLD_NATIVE_FUNCTION(validate); + JS_DECLARE_OLD_NATIVE_FUNCTION(compile); + JS_DECLARE_OLD_NATIVE_FUNCTION(instantiate); }; class WebAssemblyMemoryObject final : public JS::Object { diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp index 7493579e2e..ffc0d8b3d8 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp @@ -19,7 +19,7 @@ void WebAssemblyTablePrototype::initialize(JS::GlobalObject& global_object) define_native_function("set", set, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); } -JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::grow) +JS_DEFINE_OLD_NATIVE_FUNCTION(WebAssemblyTablePrototype::grow) { auto delta = TRY_OR_DISCARD(vm.argument(0).to_u32(global_object)); @@ -56,7 +56,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::grow) return JS::Value(static_cast(initial_size)); } -JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::get) +JS_DEFINE_OLD_NATIVE_FUNCTION(WebAssemblyTablePrototype::get) { auto index = TRY_OR_DISCARD(vm.argument(0).to_u32(global_object)); @@ -84,7 +84,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::get) return to_js_value(wasm_value, global_object); } -JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::set) +JS_DEFINE_OLD_NATIVE_FUNCTION(WebAssemblyTablePrototype::set) { auto index = TRY_OR_DISCARD(vm.argument(0).to_u32(global_object)); @@ -121,7 +121,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::set) return JS::js_undefined(); } -JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::length_getter) +JS_DEFINE_OLD_NATIVE_FUNCTION(WebAssemblyTablePrototype::length_getter) { auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object)); if (!is(this_object)) { diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h index e3075c63ae..9e034e70c0 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h @@ -27,10 +27,10 @@ public: virtual void initialize(JS::GlobalObject& global_object) override; private: - JS_DECLARE_NATIVE_FUNCTION(grow); - JS_DECLARE_NATIVE_FUNCTION(get); - JS_DECLARE_NATIVE_FUNCTION(set); - JS_DECLARE_NATIVE_FUNCTION(length_getter); + JS_DECLARE_OLD_NATIVE_FUNCTION(grow); + JS_DECLARE_OLD_NATIVE_FUNCTION(get); + JS_DECLARE_OLD_NATIVE_FUNCTION(set); + JS_DECLARE_OLD_NATIVE_FUNCTION(length_getter); }; } -- cgit v1.2.3