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 _OBJECT_OBJECT_H_ |
23 | #define _OBJECT_OBJECT_H_ |
24 | |
25 | #include "function.h" |
26 | |
27 | namespace KJS { |
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 | public: |
39 | ObjectPrototype(ExecState *exec, FunctionPrototype *funcProto); |
40 | |
41 | // Returns the lexical default object prototype for the given interpreter. |
42 | // This is just an alias for exec->lexicalInterpreter()->builtinObjectPrototype() |
43 | // for uniformity with custom prototypes. |
44 | static JSObject* self(ExecState* exec); |
45 | }; |
46 | |
47 | /** |
48 | * @internal |
49 | * |
50 | * Class to implement all methods that are properties of the |
51 | * Object.prototype object |
52 | */ |
53 | class ObjectProtoFunc : public InternalFunctionImp { |
54 | public: |
55 | ObjectProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier&); |
56 | |
57 | virtual JSValue *callAsFunction(ExecState *, JSObject *, const List &args); |
58 | |
59 | enum { ToString, ToLocaleString, ValueOf, HasOwnProperty, IsPrototypeOf, PropertyIsEnumerable, |
60 | DefineGetter, DefineSetter, LookupGetter, LookupSetter }; |
61 | private: |
62 | int id; |
63 | }; |
64 | |
65 | /** |
66 | * @internal |
67 | * |
68 | * The initial value of the global variable's "Object" property |
69 | */ |
70 | class ObjectObjectImp : public InternalFunctionImp { |
71 | public: |
72 | |
73 | ObjectObjectImp(ExecState *exec, |
74 | ObjectPrototype *objProto, |
75 | FunctionPrototype *funcProto); |
76 | |
77 | virtual bool implementsConstruct() const; |
78 | using KJS::JSObject::construct; |
79 | virtual JSObject *construct(ExecState *, const List &args); |
80 | virtual JSValue *callAsFunction(ExecState *, JSObject *, const List &args); |
81 | }; |
82 | |
83 | } // namespace |
84 | |
85 | #endif |
86 | |