File indexing completed on 2024-05-12 15:43:32
0001 /* 0002 * This file is part of the KDE libraries 0003 * Copyright (C) 2006-2007 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 Library 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 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 * 0020 */ 0021 0022 #ifndef KJS_PACKAGE_H 0023 #define KJS_PACKAGE_H 0024 0025 #include "global.h" 0026 #include "identifier.h" 0027 #include "object.h" 0028 0029 namespace KJS 0030 { 0031 0032 class Package; 0033 0034 class KJS_EXPORT Package 0035 { 0036 public: 0037 Package(Package *p, const Identifier &n) : prnt(p), nm(n) { } 0038 virtual ~Package() { } 0039 0040 const Package *parent() const 0041 { 0042 return prnt; 0043 } 0044 Package *parent() 0045 { 0046 return prnt; 0047 } 0048 0049 Identifier name() const 0050 { 0051 return nm; 0052 } 0053 0054 virtual Package *loadSubPackage(const Identifier &n, 0055 UString *err); 0056 virtual void loadSymbol(ExecState *exec, JSObject *obj, 0057 const Identifier &n); 0058 virtual void loadAllSymbols(ExecState *exec, JSObject *obj); 0059 0060 private: 0061 Package *prnt; 0062 Identifier nm; 0063 }; 0064 0065 class KJS_EXPORT StandardGlobalPackage : public Package 0066 { 0067 public: 0068 StandardGlobalPackage(); 0069 Package *loadSubPackage(const Identifier &n, 0070 UString *err) override; 0071 }; 0072 0073 class KJS_EXPORT PackageObject : public JSObject 0074 { 0075 public: 0076 PackageObject(Package *p) : pkg(p) { } 0077 0078 Package *package() 0079 { 0080 return pkg; 0081 } 0082 0083 const ClassInfo *classInfo() const override 0084 { 0085 return &info; 0086 } 0087 static const ClassInfo info; 0088 0089 private: 0090 Package *pkg; 0091 }; 0092 } 0093 0094 #endif 0095