2  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 
   3  *  Copyright (C) 2003, 2008 Apple Inc. All rights reserved. 
   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. 
  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. 
  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 
  22 #include "BooleanConstructor.h" 
  24 #include "BooleanPrototype.h" 
  25 #include "JSGlobalObject.h" 
  29 ASSERT_CLASS_FITS_IN_CELL(BooleanConstructor
); 
  31 BooleanConstructor::BooleanConstructor(ExecState
* exec
, JSGlobalObject
* globalObject
, Structure
* structure
, BooleanPrototype
* booleanPrototype
) 
  32     : InternalFunction(&exec
->globalData(), globalObject
, structure
, Identifier(exec
, booleanPrototype
->classInfo()->className
)) 
  34     putDirectWithoutTransition(exec
->globalData(), exec
->propertyNames().prototype
, booleanPrototype
, DontEnum 
| DontDelete 
| ReadOnly
); 
  36     // no. of arguments for constructor 
  37     putDirectWithoutTransition(exec
->globalData(), exec
->propertyNames().length
, jsNumber(1), ReadOnly 
| DontDelete 
| DontEnum
); 
  41 JSObject
* constructBoolean(ExecState
* exec
, const ArgList
& args
) 
  43     BooleanObject
* obj 
= new (exec
) BooleanObject(exec
->globalData(), asInternalFunction(exec
->callee())->globalObject()->booleanObjectStructure()); 
  44     obj
->setInternalValue(exec
->globalData(), jsBoolean(args
.at(0).toBoolean(exec
))); 
  48 static EncodedJSValue JSC_HOST_CALL 
constructWithBooleanConstructor(ExecState
* exec
) 
  51     return JSValue::encode(constructBoolean(exec
, args
)); 
  54 ConstructType 
BooleanConstructor::getConstructData(ConstructData
& constructData
) 
  56     constructData
.native
.function 
= constructWithBooleanConstructor
; 
  57     return ConstructTypeHost
; 
  61 static EncodedJSValue JSC_HOST_CALL 
callBooleanConstructor(ExecState
* exec
) 
  63     return JSValue::encode(jsBoolean(exec
->argument(0).toBoolean(exec
))); 
  66 CallType 
BooleanConstructor::getCallData(CallData
& callData
) 
  68     callData
.native
.function 
= callBooleanConstructor
; 
  72 JSObject
* constructBooleanFromImmediateBoolean(ExecState
* exec
, JSGlobalObject
* globalObject
, JSValue immediateBooleanValue
) 
  74     BooleanObject
* obj 
= new (exec
) BooleanObject(exec
->globalData(), globalObject
->booleanObjectStructure()); 
  75     obj
->setInternalValue(exec
->globalData(), immediateBooleanValue
);