Bug 1885489 - Part 5: Add SnapshotIterator::readInt32(). r=iain
[gecko.git] / js / src / builtin / intl / Locale.h
blob93b618528a545d3c095fe3ffcc937adea4424d40
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
10 #include <stdint.h>
12 #include "js/Class.h"
13 #include "vm/NativeObject.h"
15 namespace js {
17 class LocaleObject : public NativeObject {
18 public:
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;
27 /**
28 * Returns the complete language tag, including any extensions and privateuse
29 * subtags.
31 JSString* languageTag() const {
32 return getFixedSlot(LANGUAGE_TAG_SLOT).toString();
35 /**
36 * Returns the basename subtags, i.e. excluding any extensions and privateuse
37 * subtags.
39 JSString* baseName() const { return getFixedSlot(BASENAME_SLOT).toString(); }
41 const Value& unicodeExtension() const {
42 return getFixedSlot(UNICODE_EXTENSION_SLOT);
45 private:
46 static const ClassSpec classSpec_;
49 [[nodiscard]] extern bool intl_ValidateAndCanonicalizeLanguageTag(JSContext* cx,
50 unsigned argc,
51 Value* vp);
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);
59 } // namespace js
61 #endif /* builtin_intl_Locale_h */