Source code

Revision control

Other Tools

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/. */
6
7
#ifndef builtin_intl_Locale_h
8
#define builtin_intl_Locale_h
9
10
#include <stdint.h>
11
12
#include "builtin/SelfHostingDefines.h"
13
#include "js/Class.h"
14
#include "vm/NativeObject.h"
15
16
namespace js {
17
18
class LocaleObject : public NativeObject {
19
public:
20
static const JSClass class_;
21
static const JSClass& protoClass_;
22
23
static constexpr uint32_t LANGUAGE_TAG_SLOT = 0;
24
static constexpr uint32_t BASENAME_SLOT = 1;
25
static constexpr uint32_t UNICODE_EXTENSION_SLOT = 2;
26
static constexpr uint32_t SLOT_COUNT = 3;
27
28
/**
29
* Returns the complete language tag, including any extensions and privateuse
30
* subtags.
31
*/
32
JSString* languageTag() const {
33
return getFixedSlot(LANGUAGE_TAG_SLOT).toString();
34
}
35
36
/**
37
* Returns the basename subtags, i.e. excluding any extensions and privateuse
38
* subtags.
39
*/
40
JSString* baseName() const { return getFixedSlot(BASENAME_SLOT).toString(); }
41
42
const Value& unicodeExtension() const {
43
return getFixedSlot(UNICODE_EXTENSION_SLOT);
44
}
45
46
private:
47
static const ClassSpec classSpec_;
48
};
49
50
extern MOZ_MUST_USE bool intl_ValidateAndCanonicalizeLanguageTag(JSContext* cx,
51
unsigned argc,
52
Value* vp);
53
54
extern MOZ_MUST_USE bool intl_TryValidateAndCanonicalizeLanguageTag(
55
JSContext* cx, unsigned argc, Value* vp);
56
57
extern MOZ_MUST_USE bool intl_ValidateAndCanonicalizeUnicodeExtensionType(
58
JSContext* cx, unsigned argc, Value* vp);
59
60
} // namespace js
61
62
#endif /* builtin_intl_Locale_h */