1 /* 2 * This file is part of the KDE libraries 3 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * 19 */ 20 21 #ifndef _OBJECT_OBJECT_H_ 22 #define _OBJECT_OBJECT_H_ 23 24 #include "function.h" 25 26 namespace KJS 27 { 28 29 class FunctionPrototype; 30 31 /** 32 * @internal 33 * 34 * The initial value of Object.prototype (and thus all objects created 35 * with the Object constructor 36 */ 37 class KJS_EXPORT ObjectPrototype : public JSObject 38 { 39 public: 40 ObjectPrototype(ExecState *exec, FunctionPrototype *funcProto); 41 42 // Returns the lexical default object prototype for the given interpreter. 43 // This is just an alias for exec->lexicalInterpreter()->builtinObjectPrototype() 44 // for uniformity with custom prototypes. 45 static JSObject *self(ExecState *exec); 46 }; 47 48 /** 49 * @internal 50 * 51 * Class to implement all methods that are properties of the 52 * Object.prototype object 53 */ 54 class ObjectProtoFunc : public InternalFunctionImp 55 { 56 public: 57 ObjectProtoFunc(ExecState *exec, FunctionPrototype *funcProto, int i, int len, const Identifier &); 58 59 JSValue *callAsFunction(ExecState *, JSObject *, const List &args) override; 60 61 enum { ToString, ToLocaleString, ValueOf, HasOwnProperty, IsPrototypeOf, PropertyIsEnumerable, 62 DefineGetter, DefineSetter, LookupGetter, LookupSetter 63 }; 64 private: 65 int id; 66 }; 67 68 /** 69 * @internal 70 * 71 * The initial value of the global variable's "Object" property 72 */ 73 class ObjectObjectImp : public InternalFunctionImp 74 { 75 public: 76 77 ObjectObjectImp(ExecState *exec, 78 ObjectPrototype *objProto, 79 FunctionPrototype *funcProto); 80 81 bool implementsConstruct() const override; 82 using KJS::JSObject::construct; 83 JSObject *construct(ExecState *, const List &args) override; 84 JSValue *callAsFunction(ExecState *, JSObject *, const List &args) override; 85 }; 86 87 } // namespace 88 89 #endif 90