IntlDisplayNames.h [plain text]
#pragma once
#include "JSObject.h"
#include <unicode/uldnames.h>
#include <wtf/unicode/icu/ICUHelpers.h>
namespace JSC {
#if !defined(HAVE_ICU_U_LOCALE_DISPLAY_NAMES)
#if U_ICU_VERSION_MAJOR_NUM >= 61
#define HAVE_ICU_U_LOCALE_DISPLAY_NAMES 1
#endif
#endif
enum class RelevantExtensionKey : uint8_t;
class IntlDisplayNames final : public JSNonFinalObject {
public:
using Base = JSNonFinalObject;
static constexpr bool needsDestruction = true;
static void destroy(JSCell* cell)
{
static_cast<IntlDisplayNames*>(cell)->IntlDisplayNames::~IntlDisplayNames();
}
template<typename CellType, SubspaceAccess mode>
static IsoSubspace* subspaceFor(VM& vm)
{
return vm.intlDisplayNamesSpace<mode>();
}
static IntlDisplayNames* create(VM&, Structure*);
static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
DECLARE_INFO;
void initializeDisplayNames(JSGlobalObject*, JSValue localesValue, JSValue optionsValue);
JSValue of(JSGlobalObject*, JSValue) const;
JSObject* resolvedOptions(JSGlobalObject*) const;
private:
IntlDisplayNames(VM&, Structure*);
void finishCreation(VM&);
enum class Style : uint8_t { Narrow, Short, Long };
enum class Type : uint8_t { Language, Region, Script, Currency };
enum class Fallback : uint8_t { Code, None };
static ASCIILiteral styleString(Style);
static ASCIILiteral typeString(Type);
static ASCIILiteral fallbackString(Fallback);
using ULocaleDisplayNamesDeleter = ICUDeleter<uldn_close>;
std::unique_ptr<ULocaleDisplayNames, ULocaleDisplayNamesDeleter> m_displayNames;
String m_locale;
CString m_localeCString;
Style m_style { Style::Long };
Type m_type { Type::Language };
Fallback m_fallback { Fallback::Code };
};
}