diff options
-rw-r--r-- | Libraries/LibJS/Runtime/ArrayPrototype.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibJS/Runtime/GlobalObject.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibJS/Runtime/MathObject.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibJS/Runtime/Object.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibJS/Runtime/Object.h | 2 | ||||
-rw-r--r-- | Libraries/LibJS/Runtime/ObjectConstructor.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibJS/Runtime/ObjectPrototype.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibJS/Runtime/StringPrototype.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/DocumentWrapper.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/EventTargetWrapper.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibWeb/Bindings/WindowObject.cpp | 6 | ||||
-rw-r--r-- | Userland/js.cpp | 4 |
14 files changed, 25 insertions, 23 deletions
diff --git a/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 1fb33347b0..e46be323cd 100644 --- a/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -37,7 +37,7 @@ ArrayPrototype::ArrayPrototype() { put_native_function("shift", shift); put_native_function("pop", pop); - put_native_function("push", push); + put_native_function("push", push, 1); } ArrayPrototype::~ArrayPrototype() diff --git a/Libraries/LibJS/Runtime/GlobalObject.cpp b/Libraries/LibJS/Runtime/GlobalObject.cpp index 335001127f..452877f78d 100644 --- a/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -16,7 +16,7 @@ namespace JS { GlobalObject::GlobalObject() { put_native_function("gc", gc); - put_native_function("isNaN", is_nan); + put_native_function("isNaN", is_nan, 1); // FIXME: These are read-only in ES5 put("NaN", js_nan()); diff --git a/Libraries/LibJS/Runtime/MathObject.cpp b/Libraries/LibJS/Runtime/MathObject.cpp index 225d2005b3..c35d254177 100644 --- a/Libraries/LibJS/Runtime/MathObject.cpp +++ b/Libraries/LibJS/Runtime/MathObject.cpp @@ -34,7 +34,7 @@ namespace JS { MathObject::MathObject() { - put_native_function("abs", abs); + put_native_function("abs", abs, 1); put_native_function("random", random); put("E", Value(M_E)); diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp index b9f400de63..c29c7f85d1 100644 --- a/Libraries/LibJS/Runtime/Object.cpp +++ b/Libraries/LibJS/Runtime/Object.cpp @@ -155,9 +155,11 @@ void Object::put(const FlyString& property_name, Value value) put_own_property(*this, property_name, value); } -void Object::put_native_function(const FlyString& property_name, AK::Function<Value(Interpreter&)> native_function) +void Object::put_native_function(const FlyString& property_name, AK::Function<Value(Interpreter&)> native_function, i32 length) { - put(property_name, heap().allocate<NativeFunction>(move(native_function))); + auto* function = heap().allocate<NativeFunction>(move(native_function)); + function->put("length", Value(length)); + put(property_name, function); } void Object::put_native_property(const FlyString& property_name, AK::Function<Value(Interpreter&)> getter, AK::Function<void(Interpreter&, Value)> setter) diff --git a/Libraries/LibJS/Runtime/Object.h b/Libraries/LibJS/Runtime/Object.h index 17fd7f1e62..f47b35ac72 100644 --- a/Libraries/LibJS/Runtime/Object.h +++ b/Libraries/LibJS/Runtime/Object.h @@ -49,7 +49,7 @@ public: virtual Optional<Value> get_own_property(const Object& this_object, const FlyString& property_name) const; virtual bool put_own_property(Object& this_object, const FlyString& property_name, Value); - void put_native_function(const FlyString& property_name, AK::Function<Value(Interpreter&)>); + void put_native_function(const FlyString& property_name, AK::Function<Value(Interpreter&)>, i32 length = 0); void put_native_property(const FlyString& property_name, AK::Function<Value(Interpreter&)> getter, AK::Function<void(Interpreter&, Value)> setter); virtual bool is_array() const { return false; } diff --git a/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Libraries/LibJS/Runtime/ObjectConstructor.cpp index d6a8808dac..41376b5cbc 100644 --- a/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -37,9 +37,9 @@ ObjectConstructor::ObjectConstructor() { put("prototype", interpreter().object_prototype()); - put_native_function("getOwnPropertyNames", get_own_property_names); - put_native_function("getPrototypeOf", get_prototype_of); - put_native_function("setPrototypeOf", set_prototype_of); + put_native_function("getOwnPropertyNames", get_own_property_names, 1); + put_native_function("getPrototypeOf", get_prototype_of, 1); + put_native_function("setPrototypeOf", set_prototype_of, 2); } ObjectConstructor::~ObjectConstructor() diff --git a/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Libraries/LibJS/Runtime/ObjectPrototype.cpp index 8884056e90..92e06048b2 100644 --- a/Libraries/LibJS/Runtime/ObjectPrototype.cpp +++ b/Libraries/LibJS/Runtime/ObjectPrototype.cpp @@ -37,7 +37,7 @@ ObjectPrototype::ObjectPrototype() { set_prototype(nullptr); - put_native_function("hasOwnProperty", has_own_property); + put_native_function("hasOwnProperty", has_own_property, 1); put_native_function("toString", to_string); put_native_function("valueOf", value_of); } diff --git a/Libraries/LibJS/Runtime/StringPrototype.cpp b/Libraries/LibJS/Runtime/StringPrototype.cpp index 0d98a4f535..c9d729414e 100644 --- a/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -39,9 +39,9 @@ namespace JS { StringPrototype::StringPrototype() { put_native_property("length", length_getter, nullptr); - put_native_function("charAt", char_at); - put_native_function("repeat", repeat); - put_native_function("startsWith", starts_with); + put_native_function("charAt", char_at, 1); + put_native_function("repeat", repeat, 1); + put_native_function("startsWith", starts_with, 1); } StringPrototype::~StringPrototype() diff --git a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp index 995d72c817..5af008f98a 100644 --- a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp +++ b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp @@ -44,7 +44,7 @@ CanvasRenderingContext2DWrapper::CanvasRenderingContext2DWrapper(CanvasRendering : m_impl(impl) { put_native_property("fillStyle", fill_style_getter, fill_style_setter); - put_native_function("fillRect", fill_rect); + put_native_function("fillRect", fill_rect, 4); } CanvasRenderingContext2DWrapper::~CanvasRenderingContext2DWrapper() diff --git a/Libraries/LibWeb/Bindings/DocumentWrapper.cpp b/Libraries/LibWeb/Bindings/DocumentWrapper.cpp index 110c2986ea..6e9b76176c 100644 --- a/Libraries/LibWeb/Bindings/DocumentWrapper.cpp +++ b/Libraries/LibWeb/Bindings/DocumentWrapper.cpp @@ -40,8 +40,8 @@ namespace Bindings { DocumentWrapper::DocumentWrapper(Document& document) : NodeWrapper(document) { - put_native_function("getElementById", get_element_by_id); - put_native_function("querySelectorAll", query_selector_all); + put_native_function("getElementById", get_element_by_id, 1); + put_native_function("querySelectorAll", query_selector_all, 1); } DocumentWrapper::~DocumentWrapper() diff --git a/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp b/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp index 8a5ef26891..46d24ca454 100644 --- a/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp +++ b/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp @@ -39,7 +39,7 @@ namespace Bindings { EventTargetWrapper::EventTargetWrapper(EventTarget& impl) : m_impl(impl) { - put_native_function("addEventListener", add_event_listener); + put_native_function("addEventListener", add_event_listener, 2); } EventTargetWrapper::~EventTargetWrapper() diff --git a/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp b/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp index b80c15d4d6..b6f584df76 100644 --- a/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp +++ b/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp @@ -40,7 +40,7 @@ namespace Bindings { HTMLCanvasElementWrapper::HTMLCanvasElementWrapper(HTMLCanvasElement& element) : ElementWrapper(element) { - put_native_function("getContext", get_context); + put_native_function("getContext", get_context, 1); put_native_property("width", width_getter, nullptr); put_native_property("height", height_getter, nullptr); diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp index 2ffce1a88d..537363f6fb 100644 --- a/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -43,9 +43,9 @@ WindowObject::WindowObject(Window& impl) { put_native_property("document", document_getter, document_setter); put_native_function("alert", alert); - put_native_function("setInterval", set_interval); - put_native_function("requestAnimationFrame", request_animation_frame); - put_native_function("cancelAnimationFrame", cancel_animation_frame); + put_native_function("setInterval", set_interval, 1); + put_native_function("requestAnimationFrame", request_animation_frame, 1); + put_native_function("cancelAnimationFrame", cancel_animation_frame, 1); put("navigator", heap().allocate<NavigatorObject>()); } diff --git a/Userland/js.cpp b/Userland/js.cpp index 91ab6beddb..e5cbfcffa5 100644 --- a/Userland/js.cpp +++ b/Userland/js.cpp @@ -243,8 +243,8 @@ ReplObject::ReplObject() { put_native_function("exit", exit_interpreter); put_native_function("help", repl_help); - put_native_function("load", load_file); - put_native_function("save", save_to_file); + put_native_function("load", load_file, 1); + put_native_function("save", save_to_file, 1); } ReplObject::~ReplObject() |