File indexing completed on 2024-05-12 15:43:31
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 _OBJECT_OBJECT_H_ 0022 #define _OBJECT_OBJECT_H_ 0023 0024 #include "function.h" 0025 0026 namespace KJS 0027 { 0028 0029 class FunctionPrototype; 0030 0031 /** 0032 * @internal 0033 * 0034 * The initial value of Object.prototype (and thus all objects created 0035 * with the Object constructor 0036 */ 0037 class KJS_EXPORT ObjectPrototype : public JSObject 0038 { 0039 public: 0040 ObjectPrototype(ExecState *exec, FunctionPrototype *funcProto); 0041 0042 // Returns the lexical default object prototype for the given interpreter. 0043 // This is just an alias for exec->lexicalInterpreter()->builtinObjectPrototype() 0044 // for uniformity with custom prototypes. 0045 static JSObject *self(ExecState *exec); 0046 }; 0047 0048 /** 0049 * @internal 0050 * 0051 * Class to implement all methods that are properties of the 0052 * Object.prototype object 0053 */ 0054 class ObjectProtoFunc : public InternalFunctionImp 0055 { 0056 public: 0057 ObjectProtoFunc(ExecState *exec, FunctionPrototype *funcProto, int i, int len, const Identifier &); 0058 0059 JSValue *callAsFunction(ExecState *, JSObject *, const List &args) override; 0060 0061 enum { ToString, ToLocaleString, ValueOf, HasOwnProperty, IsPrototypeOf, PropertyIsEnumerable, 0062 DefineGetter, DefineSetter, LookupGetter, LookupSetter 0063 }; 0064 private: 0065 int id; 0066 }; 0067 0068 /** 0069 * @internal 0070 * 0071 * The initial value of the global variable's "Object" property 0072 */ 0073 class ObjectObjectImp : public InternalFunctionImp 0074 { 0075 public: 0076 0077 ObjectObjectImp(ExecState *exec, 0078 ObjectPrototype *objProto, 0079 FunctionPrototype *funcProto); 0080 0081 bool implementsConstruct() const override; 0082 using KJS::JSObject::construct; 0083 JSObject *construct(ExecState *, const List &args) override; 0084 JSValue *callAsFunction(ExecState *, JSObject *, const List &args) override; 0085 }; 0086 0087 } // namespace 0088 0089 #endif