]>
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); | |
6fe7ccc8 | 30 | ASSERT_HAS_TRIVIAL_DESTRUCTOR(BooleanConstructor); |
9dae56ea | 31 | |
6fe7ccc8 A |
32 | const ClassInfo BooleanConstructor::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(BooleanConstructor) }; |
33 | ||
34 | BooleanConstructor::BooleanConstructor(JSGlobalObject* globalObject, Structure* structure) | |
35 | : InternalFunction(globalObject, structure) | |
36 | { | |
37 | } | |
38 | ||
39 | void BooleanConstructor::finishCreation(ExecState* exec, BooleanPrototype* booleanPrototype) | |
9dae56ea | 40 | { |
6fe7ccc8 | 41 | Base::finishCreation(exec->globalData(), Identifier(exec, booleanPrototype->classInfo()->className)); |
14957cd0 | 42 | putDirectWithoutTransition(exec->globalData(), exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly); |
9dae56ea A |
43 | |
44 | // no. of arguments for constructor | |
14957cd0 | 45 | putDirectWithoutTransition(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); |
9dae56ea A |
46 | } |
47 | ||
48 | // ECMA 15.6.2 | |
49 | JSObject* constructBoolean(ExecState* exec, const ArgList& args) | |
50 | { | |
6fe7ccc8 | 51 | BooleanObject* obj = BooleanObject::create(exec->globalData(), asInternalFunction(exec->callee())->globalObject()->booleanObjectStructure()); |
14957cd0 | 52 | obj->setInternalValue(exec->globalData(), jsBoolean(args.at(0).toBoolean(exec))); |
9dae56ea A |
53 | return obj; |
54 | } | |
55 | ||
14957cd0 | 56 | static EncodedJSValue JSC_HOST_CALL constructWithBooleanConstructor(ExecState* exec) |
9dae56ea | 57 | { |
14957cd0 A |
58 | ArgList args(exec); |
59 | return JSValue::encode(constructBoolean(exec, args)); | |
9dae56ea A |
60 | } |
61 | ||
6fe7ccc8 | 62 | ConstructType BooleanConstructor::getConstructData(JSCell*, ConstructData& constructData) |
9dae56ea A |
63 | { |
64 | constructData.native.function = constructWithBooleanConstructor; | |
65 | return ConstructTypeHost; | |
66 | } | |
67 | ||
68 | // ECMA 15.6.1 | |
14957cd0 | 69 | static EncodedJSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec) |
9dae56ea | 70 | { |
14957cd0 | 71 | return JSValue::encode(jsBoolean(exec->argument(0).toBoolean(exec))); |
9dae56ea A |
72 | } |
73 | ||
6fe7ccc8 | 74 | CallType BooleanConstructor::getCallData(JSCell*, CallData& callData) |
9dae56ea A |
75 | { |
76 | callData.native.function = callBooleanConstructor; | |
77 | return CallTypeHost; | |
78 | } | |
79 | ||
14957cd0 | 80 | JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSGlobalObject* globalObject, JSValue immediateBooleanValue) |
9dae56ea | 81 | { |
6fe7ccc8 | 82 | BooleanObject* obj = BooleanObject::create(exec->globalData(), globalObject->booleanObjectStructure()); |
14957cd0 | 83 | obj->setInternalValue(exec->globalData(), immediateBooleanValue); |
9dae56ea A |
84 | return obj; |
85 | } | |
86 | ||
87 | } // namespace JSC |