1 | /* |
2 | * This file is part of the KDE libraries |
3 | * Copyright (C) 2006-2007 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 Library 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 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public License |
16 | * along with this library; see the file COPYING.LIB. If not, write to |
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | * |
20 | */ |
21 | |
22 | #ifndef KJS_PACKAGE_H |
23 | #define KJS_PACKAGE_H |
24 | |
25 | #include "global.h" |
26 | #include "identifier.h" |
27 | #include "object.h" |
28 | |
29 | namespace KJS { |
30 | |
31 | class Package; |
32 | |
33 | class KJS_EXPORT Package |
34 | { |
35 | public: |
36 | Package(Package* p, const Identifier& n) : prnt(p), nm(n) { } |
37 | virtual ~Package() { } |
38 | |
39 | const Package* parent() const { return prnt; } |
40 | Package* parent() { return prnt; } |
41 | |
42 | Identifier name() const { return nm; } |
43 | |
44 | virtual Package* loadSubPackage(const Identifier& n, |
45 | UString* err); |
46 | virtual void loadSymbol(ExecState* exec, JSObject* obj, |
47 | const Identifier& n); |
48 | virtual void loadAllSymbols(ExecState* exec, JSObject* obj); |
49 | |
50 | private: |
51 | Package* prnt; |
52 | Identifier nm; |
53 | }; |
54 | |
55 | class KJS_EXPORT StandardGlobalPackage : public Package |
56 | { |
57 | public: |
58 | StandardGlobalPackage(); |
59 | virtual Package* loadSubPackage(const Identifier& n, |
60 | UString* err); |
61 | }; |
62 | |
63 | class KJS_EXPORT PackageObject : public JSObject |
64 | { |
65 | public: |
66 | PackageObject(Package *p) : pkg(p) { } |
67 | |
68 | Package* package() { return pkg; } |
69 | |
70 | virtual const ClassInfo *classInfo() const { return &info; } |
71 | static const ClassInfo info; |
72 | |
73 | private: |
74 | Package* pkg; |
75 | }; |
76 | } |
77 | |
78 | #endif |
79 | |
80 | |