summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Array.h
blob: 077a2ad29b9b822d4e5e89e9c9ce41135a885eda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * 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:
    virtual bool is_array() const override { return true; }

    JS_DECLARE_NATIVE_GETTER(length_getter);
    JS_DECLARE_NATIVE_SETTER(length_setter);
};

}