summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-07-06 01:12:54 +0300
committerLinus Groh <mail@linusgroh.de>2021-07-06 14:20:30 +0100
commit53f70e520889a58a75e243cb93ed14f08416cf8a (patch)
tree3054922ec60641a56e3ecdc2e8442fa746ad6a0b /Userland/Libraries
parenta6b8291a9b3f72c6c70141dafb85d380a68ebdd0 (diff)
downloadserenity-53f70e520889a58a75e243cb93ed14f08416cf8a.zip
LibJS: Remove the default length & attributes from define_native_*
These are usually incorrect, and people sometimes forget to add the correct values as a result of them being optional, so they should just be specified explicitly.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp21
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.h6
-rw-r--r--Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/WindowObject.cpp23
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp2
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp4
6 files changed, 30 insertions, 28 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
index 02e4f3ae0c..06778dd99f 100644
--- a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
@@ -21,16 +21,17 @@ void ConsoleObject::initialize(GlobalObject& global_object)
{
auto& vm = this->vm();
Object::initialize(global_object);
- define_native_function(vm.names.log, log);
- define_native_function(vm.names.debug, debug);
- define_native_function(vm.names.info, info);
- define_native_function(vm.names.warn, warn);
- define_native_function(vm.names.error, error);
- define_native_function(vm.names.trace, trace);
- define_native_function(vm.names.count, count);
- define_native_function(vm.names.countReset, count_reset);
- define_native_function(vm.names.clear, clear);
- define_native_function(vm.names.assert, assert_);
+ u8 attr = Attribute::Writable | Attribute::Enumerable | Attribute::Configurable;
+ define_native_function(vm.names.log, log, 0, attr);
+ define_native_function(vm.names.debug, debug, 0, attr);
+ define_native_function(vm.names.info, info, 0, attr);
+ define_native_function(vm.names.warn, warn, 0, attr);
+ define_native_function(vm.names.error, error, 0, attr);
+ define_native_function(vm.names.trace, trace, 0, attr);
+ define_native_function(vm.names.count, count, 0, attr);
+ define_native_function(vm.names.countReset, count_reset, 0, attr);
+ define_native_function(vm.names.clear, clear, 0, attr);
+ define_native_function(vm.names.assert, assert_, 0, attr);
}
ConsoleObject::~ConsoleObject()
diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h
index 9510e2084c..d36a117089 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.h
+++ b/Userland/Libraries/LibJS/Runtime/Object.h
@@ -131,9 +131,9 @@ public:
void define_direct_property(PropertyName const& property_name, Value value, PropertyAttributes attributes) { storage_set(property_name, { value, attributes }); };
void define_direct_accessor(PropertyName const&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes);
- void define_native_function(PropertyName const&, Function<Value(VM&, GlobalObject&)>, i32 length = 0, PropertyAttributes attributes = default_attributes);
- void define_native_property(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<void(VM&, GlobalObject&, Value)> setter, PropertyAttributes attributes = default_attributes);
- void define_native_accessor(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attributes = default_attributes);
+ void define_native_function(PropertyName const&, Function<Value(VM&, GlobalObject&)>, i32 length, PropertyAttributes attributes);
+ void define_native_property(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<void(VM&, GlobalObject&, Value)> setter, PropertyAttributes attributes);
+ void define_native_accessor(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attributes);
virtual bool is_array() const { return false; }
virtual bool is_function() const { return false; }
diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp
index a7269eae65..3503d1bd36 100644
--- a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp
@@ -33,7 +33,7 @@ void NavigatorObject::initialize(JS::GlobalObject& global_object)
define_direct_property("platform", js_string(heap, "SerenityOS"), attr);
define_direct_property("product", js_string(heap, "Gecko"), attr);
- define_native_accessor("userAgent", user_agent_getter, {});
+ define_native_accessor("userAgent", user_agent_getter, {}, JS::Attribute::Configurable | JS::Attribute::Enumerable);
}
NavigatorObject::~NavigatorObject()
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp
index 8fef8a4eca..ef18f4a861 100644
--- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -57,17 +57,18 @@ void WindowObject::initialize_global_object()
define_native_accessor("screen", screen_getter, {}, JS::Attribute::Enumerable);
define_native_accessor("innerWidth", inner_width_getter, {}, JS::Attribute::Enumerable);
define_native_accessor("innerHeight", inner_height_getter, {}, JS::Attribute::Enumerable);
- define_native_function("alert", alert);
- define_native_function("confirm", confirm);
- define_native_function("prompt", prompt);
- define_native_function("setInterval", set_interval, 1);
- define_native_function("setTimeout", set_timeout, 1);
- define_native_function("clearInterval", clear_interval, 1);
- define_native_function("clearTimeout", clear_timeout, 1);
- define_native_function("requestAnimationFrame", request_animation_frame, 1);
- define_native_function("cancelAnimationFrame", cancel_animation_frame, 1);
- define_native_function("atob", atob, 1);
- define_native_function("btoa", btoa, 1);
+ u8 attr = JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable;
+ define_native_function("alert", alert, 0, attr);
+ define_native_function("confirm", confirm, 0, attr);
+ define_native_function("prompt", prompt, 0, attr);
+ define_native_function("setInterval", set_interval, 1, attr);
+ define_native_function("setTimeout", set_timeout, 1, attr);
+ define_native_function("clearInterval", clear_interval, 1, attr);
+ define_native_function("clearTimeout", clear_timeout, 1, attr);
+ define_native_function("requestAnimationFrame", request_animation_frame, 1, attr);
+ define_native_function("cancelAnimationFrame", cancel_animation_frame, 1, attr);
+ define_native_function("atob", atob, 1, attr);
+ define_native_function("btoa", btoa, 1, attr);
// Legacy
define_native_accessor("event", event_getter, {}, JS::Attribute::Enumerable);
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp
index 8eaf4e1251..91fe6541ac 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp
@@ -12,7 +12,7 @@ namespace Web::Bindings {
void WebAssemblyInstancePrototype::initialize(JS::GlobalObject& global_object)
{
Object::initialize(global_object);
- define_native_accessor("exports", exports_getter, {});
+ define_native_accessor("exports", exports_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
}
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyInstancePrototype::exports_getter)
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp
index d98b384636..0655cdcc3a 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp
@@ -13,8 +13,8 @@ namespace Web::Bindings {
void WebAssemblyMemoryPrototype::initialize(JS::GlobalObject& global_object)
{
Object::initialize(global_object);
- define_native_accessor("buffer", buffer_getter, {});
- define_native_function("grow", grow);
+ define_native_accessor("buffer", buffer_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
+ define_native_function("grow", grow, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable);
}
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::grow)