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 BOOL_OBJECT_H_
23#define BOOL_OBJECT_H_
24
25#include "internal.h"
26#include "function_object.h"
27#include "JSWrapperObject.h"
28
29namespace KJS {
30
31 class BooleanInstance : public JSWrapperObject {
32 public:
33 BooleanInstance(JSObject *proto);
34
35 virtual JSObject* valueClone(Interpreter* targetCtx) const;
36
37 virtual const ClassInfo *classInfo() const { return &info; }
38 static const ClassInfo info;
39 };
40
41 /**
42 * @internal
43 *
44 * The initial value of Boolean.prototype (and thus all objects created
45 * with the Boolean constructor
46 */
47 class BooleanPrototype : public BooleanInstance {
48 public:
49 BooleanPrototype(ExecState *exec,
50 ObjectPrototype *objectProto,
51 FunctionPrototype *funcProto);
52 };
53
54 /**
55 * @internal
56 *
57 * Class to implement all methods that are properties of the
58 * Boolean.prototype object
59 */
60 class BooleanProtoFunc : public InternalFunctionImp {
61 public:
62 BooleanProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&);
63
64 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
65
66 enum { ToString, ValueOf };
67 private:
68 int id;
69 };
70
71 /**
72 * @internal
73 *
74 * The initial value of the global variable's "Boolean" property
75 */
76 class BooleanObjectImp : public InternalFunctionImp {
77 friend class BooleanProtoFunc;
78 public:
79 BooleanObjectImp(ExecState *exec, FunctionPrototype *funcProto,
80 BooleanPrototype *booleanProto);
81
82 virtual bool implementsConstruct() const;
83 using KJS::JSObject::construct;
84 virtual JSObject *construct(ExecState *exec, const List &args);
85
86 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
87 };
88
89} // namespace
90
91#endif
92