IntlCollatorConstructor.cpp [plain text]
#include "config.h"
#include "IntlCollatorConstructor.h"
#if ENABLE(INTL)
#include "Error.h"
#include "IntlCollator.h"
#include "IntlCollatorPrototype.h"
#include "IntlObject.h"
#include "JSCJSValueInlines.h"
#include "JSCellInlines.h"
#include "Lookup.h"
#include "SlotVisitorInlines.h"
#include "StructureInlines.h"
namespace JSC {
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(IntlCollatorConstructor);
static EncodedJSValue JSC_HOST_CALL IntlCollatorConstructorFuncSupportedLocalesOf(ExecState*);
}
#include "IntlCollatorConstructor.lut.h"
namespace JSC {
const ClassInfo IntlCollatorConstructor::s_info = { "Function", &InternalFunction::s_info, &collatorConstructorTable, CREATE_METHOD_TABLE(IntlCollatorConstructor) };
IntlCollatorConstructor* IntlCollatorConstructor::create(VM& vm, Structure* structure, IntlCollatorPrototype* collatorPrototype, Structure* collatorStructure)
{
IntlCollatorConstructor* constructor = new (NotNull, allocateCell<IntlCollatorConstructor>(vm.heap)) IntlCollatorConstructor(vm, structure);
constructor->finishCreation(vm, collatorPrototype, collatorStructure);
return constructor;
}
Structure* IntlCollatorConstructor::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
}
IntlCollatorConstructor::IntlCollatorConstructor(VM& vm, Structure* structure)
: InternalFunction(vm, structure)
{
}
void IntlCollatorConstructor::finishCreation(VM& vm, IntlCollatorPrototype* collatorPrototype, Structure* collatorStructure)
{
Base::finishCreation(vm, ASCIILiteral("Collator"));
putDirectWithoutTransition(vm, vm.propertyNames->prototype, collatorPrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete);
m_collatorStructure.set(vm, this, collatorStructure);
}
static EncodedJSValue JSC_HOST_CALL constructIntlCollator(ExecState* state)
{
Structure* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), jsCast<IntlCollatorConstructor*>(state->callee())->collatorStructure());
if (state->hadException())
return JSValue::encode(jsUndefined());
IntlCollator* collator = IntlCollator::create(state->vm(), structure);
ASSERT(collator);
collator->initializeCollator(*state, state->argument(0), state->argument(1));
return JSValue::encode(collator);
}
static EncodedJSValue JSC_HOST_CALL callIntlCollator(ExecState* state)
{
VM& vm = state->vm();
IntlCollatorConstructor* callee = jsCast<IntlCollatorConstructor*>(state->callee());
IntlCollator* collator = IntlCollator::create(vm, callee->collatorStructure());
ASSERT(collator);
collator->initializeCollator(*state, state->argument(0), state->argument(1));
return JSValue::encode(collator);
}
ConstructType IntlCollatorConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructIntlCollator;
return ConstructType::Host;
}
CallType IntlCollatorConstructor::getCallData(JSCell*, CallData& callData)
{
callData.native.function = callIntlCollator;
return CallType::Host;
}
EncodedJSValue JSC_HOST_CALL IntlCollatorConstructorFuncSupportedLocalesOf(ExecState* state)
{
Vector<String> requestedLocales = canonicalizeLocaleList(*state, state->argument(0));
if (state->hadException())
return JSValue::encode(jsUndefined());
JSGlobalObject* globalObject = state->callee()->globalObject();
return JSValue::encode(supportedLocales(*state, globalObject->intlCollatorAvailableLocales(), requestedLocales, state->argument(1)));
}
void IntlCollatorConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
IntlCollatorConstructor* thisObject = jsCast<IntlCollatorConstructor*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
visitor.append(&thisObject->m_collatorStructure);
}
}
#endif // ENABLE(INTL)