]>
Commit | Line | Data |
---|---|---|
9dae56ea A |
1 | /* |
2 | * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) | |
3 | * Copyright (C) 2003, 2008 Apple Inc. All rights reserved. | |
4 | * | |
5 | * This library is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU Lesser 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 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this library; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | * | |
19 | */ | |
20 | ||
21 | #include "config.h" | |
22 | #include "BooleanConstructor.h" | |
23 | ||
24 | #include "BooleanPrototype.h" | |
25 | #include "JSGlobalObject.h" | |
26 | ||
27 | namespace JSC { | |
28 | ||
29 | ASSERT_CLASS_FITS_IN_CELL(BooleanConstructor); | |
30 | ||
31 | BooleanConstructor::BooleanConstructor(ExecState* exec, PassRefPtr<Structure> structure, BooleanPrototype* booleanPrototype) | |
32 | : InternalFunction(&exec->globalData(), structure, Identifier(exec, booleanPrototype->classInfo()->className)) | |
33 | { | |
34 | putDirectWithoutTransition(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly); | |
35 | ||
36 | // no. of arguments for constructor | |
37 | putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum); | |
38 | } | |
39 | ||
40 | // ECMA 15.6.2 | |
41 | JSObject* constructBoolean(ExecState* exec, const ArgList& args) | |
42 | { | |
43 | BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanObjectStructure()); | |
44 | obj->setInternalValue(jsBoolean(args.at(exec, 0).toBoolean(exec))); | |
45 | return obj; | |
46 | } | |
47 | ||
48 | static JSObject* constructWithBooleanConstructor(ExecState* exec, JSObject*, const ArgList& args) | |
49 | { | |
50 | return constructBoolean(exec, args); | |
51 | } | |
52 | ||
53 | ConstructType BooleanConstructor::getConstructData(ConstructData& constructData) | |
54 | { | |
55 | constructData.native.function = constructWithBooleanConstructor; | |
56 | return ConstructTypeHost; | |
57 | } | |
58 | ||
59 | // ECMA 15.6.1 | |
60 | static JSValuePtr callBooleanConstructor(ExecState* exec, JSObject*, JSValuePtr, const ArgList& args) | |
61 | { | |
62 | return jsBoolean(args.at(exec, 0).toBoolean(exec)); | |
63 | } | |
64 | ||
65 | CallType BooleanConstructor::getCallData(CallData& callData) | |
66 | { | |
67 | callData.native.function = callBooleanConstructor; | |
68 | return CallTypeHost; | |
69 | } | |
70 | ||
71 | JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSValuePtr immediateBooleanValue) | |
72 | { | |
73 | BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanObjectStructure()); | |
74 | obj->setInternalValue(immediateBooleanValue); | |
75 | return obj; | |
76 | } | |
77 | ||
78 | } // namespace JSC |