#include "config.h"
#include "StringObject.h"
#include "PropertyNameArray.h"
namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(StringObject);
const ClassInfo StringObject::info = { "String", 0, 0, 0 };
StringObject::StringObject(ExecState* exec, PassRefPtr<Structure> structure)
: JSWrapperObject(structure)
{
setInternalValue(jsEmptyString(exec));
}
StringObject::StringObject(PassRefPtr<Structure> structure, JSString* string)
: JSWrapperObject(structure)
{
setInternalValue(string);
}
StringObject::StringObject(ExecState* exec, PassRefPtr<Structure> structure, const UString& string)
: JSWrapperObject(structure)
{
setInternalValue(jsString(exec, string));
}
bool StringObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
if (internalValue()->getStringPropertySlot(exec, propertyName, slot))
return true;
return JSObject::getOwnPropertySlot(exec, propertyName, slot);
}
bool StringObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
{
if (internalValue()->getStringPropertySlot(exec, propertyName, slot))
return true;
return JSObject::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
}
void StringObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
if (propertyName == exec->propertyNames().length)
return;
JSObject::put(exec, propertyName, value, slot);
}
bool StringObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
{
if (propertyName == exec->propertyNames().length)
return false;
return JSObject::deleteProperty(exec, propertyName);
}
void StringObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
{
int size = internalValue()->value().size();
for (int i = 0; i < size; ++i)
propertyNames.add(Identifier(exec, UString::from(i)));
return JSObject::getPropertyNames(exec, propertyNames);
}
UString StringObject::toString(ExecState*) const
{
return internalValue()->value();
}
UString StringObject::toThisString(ExecState*) const
{
return internalValue()->value();
}
JSString* StringObject::toThisJSString(ExecState*)
{
return internalValue();
}
}