1 | // -*- c-basic-offset: 2 -*- |
2 | /* |
3 | * This file is part of the KDE libraries |
4 | * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Lesser General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Lesser General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public |
17 | * License along with this library; if not, write to the Free Software |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | * |
20 | */ |
21 | |
22 | #ifndef ARRAY_OBJECT_H_ |
23 | #define ARRAY_OBJECT_H_ |
24 | |
25 | #include "array_instance.h" |
26 | #include "internal.h" |
27 | #include "function_object.h" |
28 | |
29 | namespace KJS { |
30 | |
31 | class ArrayPrototype : public ArrayInstance { |
32 | public: |
33 | ArrayPrototype(ExecState *exec, |
34 | ObjectPrototype *objProto); |
35 | using KJS::ArrayInstance::getOwnPropertySlot; |
36 | bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); |
37 | virtual const ClassInfo *classInfo() const { return &info; } |
38 | static const ClassInfo info; |
39 | }; |
40 | |
41 | class ArrayProtoFunc : public InternalFunctionImp { |
42 | public: |
43 | ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier& name); |
44 | |
45 | virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); |
46 | |
47 | enum { ToString, ToLocaleString, Concat, Join, Pop, Push, |
48 | Reverse, Shift, Slice, Sort, Splice, UnShift, |
49 | Every, ForEach, Some, IndexOf, Filter, Map, LastIndexOf, |
50 | Reduce, ReduceRight }; |
51 | private: |
52 | int id; |
53 | }; |
54 | |
55 | class ArrayObjectImp : public InternalFunctionImp { |
56 | public: |
57 | ArrayObjectImp(ExecState *exec, |
58 | FunctionPrototype *funcProto, |
59 | ArrayPrototype *arrayProto); |
60 | |
61 | virtual bool implementsConstruct() const; |
62 | using KJS::JSObject::construct; |
63 | virtual JSObject *construct(ExecState *exec, const List &args); |
64 | virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); |
65 | |
66 | }; |
67 | |
68 | } // namespace |
69 | |
70 | #endif |
71 | |