File indexing completed on 2024-05-12 15:43:19
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 ERROR_OBJECT_H_ 0022 #define ERROR_OBJECT_H_ 0023 0024 #include "function_object.h" 0025 0026 namespace KJS 0027 { 0028 0029 class ErrorInstance : public JSObject 0030 { 0031 public: 0032 ErrorInstance(JSObject *proto); 0033 0034 const ClassInfo *classInfo() const override 0035 { 0036 return &info; 0037 } 0038 static const ClassInfo info; 0039 }; 0040 0041 class ErrorPrototype : public ErrorInstance 0042 { 0043 public: 0044 ErrorPrototype(ExecState *exec, 0045 ObjectPrototype *objectProto, 0046 FunctionPrototype *funcProto); 0047 }; 0048 0049 class ErrorProtoFunc : public InternalFunctionImp 0050 { 0051 public: 0052 ErrorProtoFunc(ExecState *, FunctionPrototype *, const Identifier &); 0053 JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) override; 0054 }; 0055 0056 class ErrorObjectImp : public InternalFunctionImp 0057 { 0058 public: 0059 ErrorObjectImp(ExecState *exec, FunctionPrototype *funcProto, 0060 ErrorPrototype *errorProto); 0061 0062 bool implementsConstruct() const override; 0063 using KJS::JSObject::construct; 0064 JSObject *construct(ExecState *exec, const List &args) override; 0065 0066 JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) override; 0067 }; 0068 0069 class NativeErrorPrototype : public JSObject 0070 { 0071 public: 0072 NativeErrorPrototype(ExecState *exec, ErrorPrototype *errorProto, 0073 ErrorType et, UString name, UString message); 0074 private: 0075 ErrorType errType; 0076 }; 0077 0078 class NativeErrorImp : public InternalFunctionImp 0079 { 0080 public: 0081 NativeErrorImp(ExecState *exec, FunctionPrototype *funcProto, 0082 JSObject *prot); 0083 0084 bool implementsConstruct() const override; 0085 using KJS::JSObject::construct; 0086 JSObject *construct(ExecState *exec, const List &args) override; 0087 JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) override; 0088 0089 void mark() override; 0090 0091 const ClassInfo *classInfo() const override 0092 { 0093 return &info; 0094 } 0095 static const ClassInfo info; 0096 private: 0097 JSObject *proto; 0098 }; 0099 0100 } // namespace 0101 0102 #endif