ladybird/Userland/Libraries/LibJS/Runtime/Array.h
Linus Groh 0ba81dc0b7 LibJS: Remove Object::is_array() in favor of Value::is_array() and RTTI
It's way too easy to get this wrong: for the IsArray abstract operation,
Value::is_array() needs to be called. Since we have RTTI, the virtual
Object::is_array() method is not needed anymore - if we need to know
whether something is *actually* a JS::Array (we currently check in more
cases than we should, I think) and not a Proxy with an Array target, we
should do that in a way that doesn't look like an abstract operation.
2021-07-06 14:26:18 +01:00

31 lines
680 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Runtime/Object.h>
namespace JS {
class Array : public Object {
JS_OBJECT(Array, Object);
public:
static Array* create(GlobalObject&, size_t length, Object* prototype = nullptr);
static Array* create_from(GlobalObject&, Vector<Value> const&);
explicit Array(Object& prototype);
virtual void initialize(GlobalObject&) override;
virtual ~Array() override;
static Array* typed_this(VM&, GlobalObject&);
private:
JS_DECLARE_NATIVE_GETTER(length_getter);
JS_DECLARE_NATIVE_SETTER(length_setter);
};
}