v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-segmenter.h
Go to the documentation of this file.
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_OBJECTS_JS_SEGMENTER_H_
6#define V8_OBJECTS_JS_SEGMENTER_H_
7
8#ifndef V8_INTL_SUPPORT
9#error Internationalization is expected to be enabled.
10#endif // V8_INTL_SUPPORT
11
12#include <set>
13#include <string>
14
15#include "src/base/bit-field.h"
17#include "src/heap/factory.h"
18#include "src/objects/managed.h"
19#include "src/objects/objects.h"
20#include "unicode/uversion.h"
21
22// Has to be the last include (doesn't have include guards):
24
25namespace U_ICU_NAMESPACE {
26class BreakIterator;
27} // namespace U_ICU_NAMESPACE
28
29namespace v8 {
30namespace internal {
31
32#include "torque-generated/src/objects/js-segmenter-tq.inc"
33
34class JSSegmenter : public TorqueGeneratedJSSegmenter<JSSegmenter, JSObject> {
35 public:
36 // Creates segmenter object with properties derived from input locales and
37 // options.
39 Isolate* isolate, DirectHandle<Map> map, DirectHandle<Object> locales,
40 DirectHandle<Object> options);
41
43 Isolate* isolate, DirectHandle<JSSegmenter> segmenter_holder);
44
45 V8_EXPORT_PRIVATE static const std::set<std::string>& GetAvailableLocales();
46
48
49 // Segmenter accessors.
51
52 // Granularity: identifying the segmenter used.
53 //
54 // ecma402 #sec-segmenter-internal-slots
55 enum class Granularity {
56 GRAPHEME, // for character-breaks
57 WORD, // for word-breaks
58 SENTENCE // for sentence-breaks
59 };
61 inline Granularity granularity() const;
62
65
66 // Bit positions in |flags|.
67 DEFINE_TORQUE_GENERATED_JS_SEGMENTER_FLAGS()
68
69 static_assert(GranularityBits::is_valid(Granularity::GRAPHEME));
70 static_assert(GranularityBits::is_valid(Granularity::WORD));
71 static_assert(GranularityBits::is_valid(Granularity::SENTENCE));
72
74
76};
77
78} // namespace internal
79} // namespace v8
80
81#include "src/objects/object-macros-undef.h"
82
83#endif // V8_OBJECTS_JS_SEGMENTER_H_
static Handle< String > GetGranularityString(Isolate *isolate, Granularity granularity)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSSegmenter > New(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Object > locales, DirectHandle< Object > options)
void set_granularity(Granularity granularity)
static V8_EXPORT_PRIVATE const std::set< std::string > & GetAvailableLocales()
Granularity granularity() const
Handle< String > GranularityAsString(Isolate *isolate) const
static V8_WARN_UNUSED_RESULT DirectHandle< JSObject > ResolvedOptions(Isolate *isolate, DirectHandle< JSSegmenter > segmenter_holder)
#define DECL_ACCESSORS(name,...)
#define DECL_PRINTER(Name)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671