File indexing completed on 2024-05-12 15:43:15
0001 /* 0002 * This file is part of the KDE libraries 0003 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Lesser General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Lesser General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Lesser General Public 0016 * License along with this library; if not, write to the Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0018 * 0019 */ 0020 0021 #ifndef ARRAY_OBJECT_H_ 0022 #define ARRAY_OBJECT_H_ 0023 0024 #include "array_instance.h" 0025 #include "internal.h" 0026 #include "function_object.h" 0027 0028 namespace KJS 0029 { 0030 0031 class ArrayPrototype : public ArrayInstance 0032 { 0033 public: 0034 ArrayPrototype(ExecState *exec, 0035 ObjectPrototype *objProto); 0036 using KJS::ArrayInstance::getOwnPropertySlot; 0037 bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override; 0038 const ClassInfo *classInfo() const override 0039 { 0040 return &info; 0041 } 0042 static const ClassInfo info; 0043 }; 0044 0045 class ArrayProtoFunc : public InternalFunctionImp 0046 { 0047 public: 0048 ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier &name); 0049 0050 JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) override; 0051 0052 enum { ToString, ToLocaleString, Concat, Join, Pop, Push, 0053 Reverse, Shift, Slice, Sort, Splice, UnShift, 0054 Every, ForEach, Some, IndexOf, Filter, Map, LastIndexOf, 0055 Reduce, ReduceRight 0056 }; 0057 private: 0058 int id; 0059 }; 0060 0061 class ArrayObjectImp : public InternalFunctionImp 0062 { 0063 public: 0064 ArrayObjectImp(ExecState *exec, 0065 FunctionPrototype *funcProto, 0066 ArrayPrototype *arrayProto); 0067 0068 bool implementsConstruct() const override; 0069 using KJS::JSObject::construct; 0070 JSObject *construct(ExecState *exec, const List &args) override; 0071 JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) override; 0072 0073 }; 0074 0075 } // namespace 0076 0077 #endif