File indexing completed on 2024-05-12 15:43:15
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 BOOL_OBJECT_H_ 0022 #define BOOL_OBJECT_H_ 0023 0024 #include "internal.h" 0025 #include "function_object.h" 0026 #include "JSWrapperObject.h" 0027 0028 namespace KJS 0029 { 0030 0031 class BooleanInstance : public JSWrapperObject 0032 { 0033 public: 0034 BooleanInstance(JSObject *proto); 0035 0036 JSObject *valueClone(Interpreter *targetCtx) const override; 0037 0038 const ClassInfo *classInfo() const override 0039 { 0040 return &info; 0041 } 0042 static const ClassInfo info; 0043 }; 0044 0045 /** 0046 * @internal 0047 * 0048 * The initial value of Boolean.prototype (and thus all objects created 0049 * with the Boolean constructor 0050 */ 0051 class BooleanPrototype : public BooleanInstance 0052 { 0053 public: 0054 BooleanPrototype(ExecState *exec, 0055 ObjectPrototype *objectProto, 0056 FunctionPrototype *funcProto); 0057 }; 0058 0059 /** 0060 * @internal 0061 * 0062 * Class to implement all methods that are properties of the 0063 * Boolean.prototype object 0064 */ 0065 class BooleanProtoFunc : public InternalFunctionImp 0066 { 0067 public: 0068 BooleanProtoFunc(ExecState *, FunctionPrototype *, int i, int len, const Identifier &); 0069 0070 JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) override; 0071 0072 enum { ToString, ValueOf }; 0073 private: 0074 int id; 0075 }; 0076 0077 /** 0078 * @internal 0079 * 0080 * The initial value of the global variable's "Boolean" property 0081 */ 0082 class BooleanObjectImp : public InternalFunctionImp 0083 { 0084 friend class BooleanProtoFunc; 0085 public: 0086 BooleanObjectImp(ExecState *exec, FunctionPrototype *funcProto, 0087 BooleanPrototype *booleanProto); 0088 0089 bool implementsConstruct() const override; 0090 using KJS::JSObject::construct; 0091 JSObject *construct(ExecState *exec, const List &args) override; 0092 0093 JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) override; 0094 }; 0095 0096 } // namespace 0097 0098 #endif