1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef builtin_intl_Locale_h
8 #define builtin_intl_Locale_h
13 #include "vm/NativeObject.h"
17 class LocaleObject
: public NativeObject
{
19 static const JSClass class_
;
20 static const JSClass
& protoClass_
;
22 static constexpr uint32_t LANGUAGE_TAG_SLOT
= 0;
23 static constexpr uint32_t BASENAME_SLOT
= 1;
24 static constexpr uint32_t UNICODE_EXTENSION_SLOT
= 2;
25 static constexpr uint32_t SLOT_COUNT
= 3;
28 * Returns the complete language tag, including any extensions and privateuse
31 JSString
* languageTag() const {
32 return getFixedSlot(LANGUAGE_TAG_SLOT
).toString();
36 * Returns the basename subtags, i.e. excluding any extensions and privateuse
39 JSString
* baseName() const { return getFixedSlot(BASENAME_SLOT
).toString(); }
41 const Value
& unicodeExtension() const {
42 return getFixedSlot(UNICODE_EXTENSION_SLOT
);
46 static const ClassSpec classSpec_
;
49 [[nodiscard
]] extern bool intl_ValidateAndCanonicalizeLanguageTag(JSContext
* cx
,
53 [[nodiscard
]] extern bool intl_TryValidateAndCanonicalizeLanguageTag(
54 JSContext
* cx
, unsigned argc
, Value
* vp
);
56 [[nodiscard
]] extern bool intl_ValidateAndCanonicalizeUnicodeExtensionType(
57 JSContext
* cx
, unsigned argc
, Value
* vp
);
61 #endif /* builtin_intl_Locale_h */