6#error Internationalization is expected to be enabled.
23#include "unicode/brkiter.h"
32 std::shared_ptr<icu::BreakIterator> break_iterator{
33 segmenter->icu_break_iterator()->raw()->clone()};
48 segments->set_flags(0);
51 segments->set_icu_break_iterator(*managed_break_iterator);
52 segments->set_granularity(segmenter->granularity());
55 segments->set_raw_string(*
string);
66 int32_t len = segments->unicode_string()->raw()->length();
69 if (n_double < 0 || n_double >= len) {
70 return isolate->factory()->undefined_value();
73 int32_t n =
static_cast<int32_t
>(n_double);
75 n = segments->unicode_string()->raw()->getChar32Start(n);
77 icu::BreakIterator* break_iterator = segments->icu_break_iterator()->raw();
80 break_iterator->isBoundary(n) ?
n : break_iterator->preceding(n);
83 int32_t end_index = break_iterator->following(n);
88 isolate, segments->granularity(), break_iterator,
90 *(segments->unicode_string()->raw()), start_index, end_index);
95bool CurrentSegmentIsWordLike(icu::BreakIterator* break_iterator) {
96 int32_t rule_status = break_iterator->getRuleStatus();
97 return (rule_status >= UBRK_WORD_NUMBER &&
98 rule_status < UBRK_WORD_NUMBER_LIMIT) ||
99 (rule_status >= UBRK_WORD_LETTER &&
100 rule_status < UBRK_WORD_LETTER_LIMIT) ||
101 (rule_status >= UBRK_WORD_KANA &&
102 rule_status < UBRK_WORD_KANA_LIMIT) ||
103 (rule_status >= UBRK_WORD_IDEO && rule_status < UBRK_WORD_IDEO_LIMIT);
114 Factory* factory = isolate->factory();
127 ? isolate->native_context()->intl_segment_data_object_wordlike_map()
128 : isolate->native_context()->intl_segment_data_object_map(),
145 raw->set_segment(*segment);
147 raw->set_index(*index);
149 raw->set_input(*input_string);
157 factory->
ToBoolean(CurrentSegmentIsWordLike(break_iterator));
Handle< Boolean > ToBoolean(bool value)
Handle< Number > NewNumberFromInt(int32_t value)
Handle< JSObject > NewJSObjectFromMap(DirectHandle< Map > map, AllocationType allocation=AllocationType::kYoung, DirectHandle< AllocationSite > allocation_site=DirectHandle< AllocationSite >::null(), NewJSObjectType=NewJSObjectType::kNoAPIWrapper)
static V8_WARN_UNUSED_RESULT MaybeHandle< String > ToString(Isolate *isolate, const icu::UnicodeString &string)
static DirectHandle< Managed< icu::UnicodeString > > SetTextToBreakIterator(Isolate *isolate, DirectHandle< String > text, icu::BreakIterator *break_iterator)
static Handle< String > GetGranularityString(Isolate *isolate, Granularity granularity)
JSSegmenter::Granularity granularity() const
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSSegmentDataObject > CreateSegmentDataObject(Isolate *isolate, JSSegmenter::Granularity granularity, icu::BreakIterator *break_iterator, DirectHandle< String > input_string, const icu::UnicodeString &unicode_string, int32_t start_index, int32_t end_index)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > Containing(Isolate *isolate, DirectHandle< JSSegments > segments_holder, double n)
Handle< String > GranularityAsString(Isolate *isolate) const
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSSegments > Create(Isolate *isolate, DirectHandle< JSSegmenter > segmenter, DirectHandle< String > string)
static DirectHandle< Managed< CppType > > From(Isolate *isolate, size_t estimated_size, std::shared_ptr< CppType > shared_ptr, AllocationType allocation_type=AllocationType::kYoung)
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
ZoneVector< RpoNumber > & result
V8_INLINE DirectHandle< T > direct_handle(Tagged< T > object, Isolate *isolate)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define DCHECK_LE(v1, v2)
#define DCHECK_NOT_NULL(val)
#define DCHECK_GE(v1, v2)
#define DCHECK_LT(v1, v2)