#pragma once
#if ENABLE(INTL)
#include "JSObject.h"
struct UCollator;
namespace JSC {
class IntlCollatorConstructor;
class JSBoundFunction;
class IntlCollator final : public JSNonFinalObject {
public:
using Base = JSNonFinalObject;
static constexpr bool needsDestruction = true;
static void destroy(JSCell* cell)
{
static_cast<IntlCollator*>(cell)->IntlCollator::~IntlCollator();
}
template<typename CellType, SubspaceAccess mode>
static IsoSubspace* subspaceFor(VM& vm)
{
return vm.intlCollatorSpace<mode>();
}
static IntlCollator* create(VM&, Structure*);
static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
DECLARE_INFO;
void initializeCollator(JSGlobalObject*, JSValue locales, JSValue optionsValue);
JSValue compareStrings(JSGlobalObject*, StringView, StringView);
JSObject* resolvedOptions(JSGlobalObject*);
JSBoundFunction* boundCompare() const { return m_boundCompare.get(); }
void setBoundCompare(VM&, JSBoundFunction*);
protected:
IntlCollator(VM&, Structure*);
void finishCreation(VM&);
static void visitChildren(JSCell*, SlotVisitor&);
private:
enum class Usage : uint8_t { Sort, Search };
enum class Sensitivity : uint8_t { Base, Accent, Case, Variant };
enum class CaseFirst : uint8_t { Upper, Lower, False };
struct UCollatorDeleter {
void operator()(UCollator*) const;
};
void createCollator(JSGlobalObject*);
static ASCIILiteral usageString(Usage);
static ASCIILiteral sensitivityString(Sensitivity);
static ASCIILiteral caseFirstString(CaseFirst);
String m_locale;
String m_collation;
WriteBarrier<JSBoundFunction> m_boundCompare;
std::unique_ptr<UCollator, UCollatorDeleter> m_collator;
Usage m_usage;
Sensitivity m_sensitivity;
CaseFirst m_caseFirst;
bool m_numeric;
bool m_ignorePunctuation;
bool m_initializedCollator { false };
};
}
#endif // ENABLE(INTL)