Lines Matching defs:thread

107 void JSDateTimeFormat::SetIcuLocale(JSThread *thread, JSHandle<JSDateTimeFormat> obj,
110 EcmaVM *ecmaVm = thread->GetEcmaVM();
117 native->ResetExternalPointer(thread, icuPointer);
121 obj->SetLocaleIcu(thread, pointer.GetTaggedValue());
144 void JSDateTimeFormat::SetIcuSimpleDateFormat(JSThread *thread, JSHandle<JSDateTimeFormat> obj,
147 EcmaVM *ecmaVm = thread->GetEcmaVM();
155 native->ResetExternalPointer(thread, icuPointer);
162 obj->SetSimpleDateTimeFormatIcu(thread, pointer.GetTaggedValue());
177 JSHandle<EcmaString> JSDateTimeFormat::ToValueString(JSThread *thread, const Value value)
179 auto globalConst = thread->GlobalConstants();
180 JSMutableHandle<EcmaString> result(thread, JSTaggedValue::Undefined());
328 JSHandle<JSDateTimeFormat> JSDateTimeFormat::InitializeDateTimeFormat(JSThread *thread,
334 EcmaVM *ecmaVm = thread->GetEcmaVM();
336 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
339 JSHandle<TaggedArray> requestedLocales = intl::LocaleHelper::CanonicalizeLocaleList(thread, locales);
340 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
347 dateTimeOptions = JSTaggedValue::ToObject(thread, options);
348 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
353 thread, dateTimeOptions, globalConst->GetHandledLocaleMatcherString(),
356 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
360 JSLocale::GetOption(thread, dateTimeOptions, globalConst->GetHandledCalendarString(), OptionType::STRING,
362 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
363 dateTimeFormat->SetCalendar(thread, calendar);
372 THROW_RANGE_ERROR_AND_RETURN(thread, "invalid calendar", dateTimeFormat);
378 JSLocale::GetOption(thread, dateTimeOptions, globalConst->GetHandledNumberingSystemString(), OptionType::STRING,
380 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
381 dateTimeFormat->SetNumberingSystem(thread, numberingSystem);
391 THROW_RANGE_ERROR_AND_RETURN(thread, "invalid numberingSystem", dateTimeFormat);
397 JSLocale::GetOption(thread, dateTimeOptions, globalConst->GetHandledHour12String(), OptionType::BOOLEAN,
399 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
403 thread, dateTimeOptions, globalConst->GetHandledHourCycleString(),
406 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
416 GainAvailableLocales(thread);
421 JSLocale::ResolveLocale(thread, availableLocales, requestedLocales, matcher, RELEVANT_EXTENSION_KEYS);
431 dateTimeFormat->SetNumberingSystem(thread, result);
447 JSObject::GetProperty(thread, dateTimeOptions, globalConst->GetHandledTimeZoneString());
448 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
449 dateTimeFormat->SetTimeZone(thread, operationResult.GetValue());
457 JSHandle<EcmaString> timezone = JSTaggedValue::ToString(thread, operationResult.GetValue());
458 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
461 THROW_RANGE_ERROR_AND_RETURN(thread, "invalid timeZone", dateTimeFormat);
472 ThreadNativeScope nativeScope(thread);
477 THROW_REFERENCE_ERROR_AND_RETURN(thread, "can not find icu data resources", dateTimeFormat);
479 THROW_RANGE_ERROR_AND_RETURN(thread, "create icu::DateTimePatternGenerator failed", dateTimeFormat);
537 int secondDigitsString = JSLocale::GetNumberOption(thread, dateTimeOptions,
548 JSHandle<JSTaggedValue> property(thread, factory->NewFromStdString(item.property).GetTaggedValue());
550 bool isFind = JSLocale::GetOptionOfString(thread, dateTimeOptions, property, item.allowedValues, &value);
551 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
563 thread, dateTimeOptions, globalConst->GetHandledFormatMatcherString(),
566 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
571 thread, dateTimeOptions, globalConst->GetHandledDateStyleString(),
574 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
580 thread, dateTimeOptions, globalConst->GetHandledTimeStyleString(),
583 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
595 ToDateTimeSkeleton(thread, skeletonOpts, skeleton, hc, RequiredOption::ANY, DefaultsOption::DATE);
596 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
612 JSDateTimeFormat::SetIcuLocale(thread, dateTimeFormat, icuLocale, JSDateTimeFormat::FreeIcuLocale);
624 THROW_TYPE_ERROR_AND_RETURN(thread, "Invalid option : option", dateTimeFormat);
641 thread->GetCurrentEcmaContext()->SetIcuFormatterToCache(IcuFormatterType::SIMPLE_DATE_FORMAT_DEFAULT,
645 thread->GetCurrentEcmaContext()->SetIcuFormatterToCache(IcuFormatterType::SIMPLE_DATE_FORMAT_DATE,
649 thread->GetCurrentEcmaContext()->SetIcuFormatterToCache(IcuFormatterType::SIMPLE_DATE_FORMAT_TIME,
656 SetIcuSimpleDateFormat(thread, dateTimeFormat, *simpleDateFormatIcu, JSDateTimeFormat::FreeSimpleDateFormat);
661 dateTimeFormat->SetIso8601(thread, JSTaggedValue(iso8601));
671 JSHandle<EcmaString> localeStr = intl::LocaleHelper::ToLanguageTag(thread, resolvedIcuLocaleCopy);
672 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDateTimeFormat, thread);
673 dateTimeFormat->SetLocale(thread, localeStr.GetTaggedValue());
676 dateTimeFormat->SetBoundFormat(thread, JSTaggedValue::Undefined());
682 icu::SimpleDateFormat *JSDateTimeFormat::GetCachedIcuSimpleDateFormat(JSThread *thread,
687 void *cachedSimpleDateFormat = thread->GetCurrentEcmaContext()->GetIcuFormatterFromCache(type, cacheEntry);
695 JSHandle<JSObject> JSDateTimeFormat::ToDateTimeOptions(JSThread *thread, const JSHandle<JSTaggedValue> &options,
698 EcmaVM *ecmaVm = thread->GetEcmaVM();
702 JSHandle<JSObject> optionsResult(thread, JSTaggedValue::Null());
704 optionsResult = JSTaggedValue::ToObject(thread, options);
705 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
709 optionsResult = JSObject::ObjectCreate(thread, optionsResult);
719 auto globalConst = thread->GlobalConstants();
722 array->Set(thread, 0, globalConst->GetHandledWeekdayString());
723 array->Set(thread, 1, globalConst->GetHandledYearString());
724 array->Set(thread, 2, globalConst->GetHandledMonthString()); // 2 means the third slot
725 array->Set(thread, 3, globalConst->GetHandledDayString()); // 3 means the fourth slot
726 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
729 key.Update(array->Get(thread, i));
730 OperationResult operationResult = JSObject::GetProperty(thread, optionsResult, key);
731 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
745 array->Set(thread, 0, globalConst->GetHandledDayPeriodString());
746 array->Set(thread, 1, globalConst->GetHandledHourString());
747 array->Set(thread, 2, globalConst->GetHandledMinuteString()); // 2 means the second slot
748 array->Set(thread, 3, globalConst->GetHandledSecondString()); // 3 means the third slot
749 array->Set(thread, 4, globalConst->GetHandledFractionalSecondDigitsString()); // 4 means the fourth slot
750 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
753 key.Update(array->Get(thread, i));
754 OperationResult operationResult = JSObject::GetProperty(thread, optionsResult, key);
755 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
764 JSObject::GetProperty(thread, optionsResult, globalConst->GetHandledDateStyleString());
765 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
768 JSObject::GetProperty(thread, optionsResult, globalConst->GetHandledTimeStyleString());
769 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
779 THROW_TYPE_ERROR_AND_RETURN(thread, "timeStyle is not undefined", optionsResult);
782 THROW_TYPE_ERROR_AND_RETURN(thread, "dateStyle is not undefined", optionsResult);
790 array->Set(thread, 0, globalConst->GetHandledYearString());
791 array->Set(thread, 1, globalConst->GetHandledMonthString());
792 array->Set(thread, 2, globalConst->GetHandledDayString()); // 2 means the third slot
793 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
796 key.Update(array->Get(thread, i));
797 JSObject::CreateDataPropertyOrThrow(thread, optionsResult, key, globalConst->GetHandledNumericString());
798 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
807 array->Set(thread, 0, globalConst->GetHandledHourString());
808 array->Set(thread, 1, globalConst->GetHandledMinuteString());
809 array->Set(thread, 2, globalConst->GetHandledSecondString()); // 2 means the third slot
810 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
813 key.Update(array->Get(thread, i));
814 JSObject::CreateDataPropertyOrThrow(thread, optionsResult, key, globalConst->GetHandledNumericString());
815 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread);
823 void JSDateTimeFormat::ToDateTimeSkeleton(JSThread *thread, const std::vector<std::string> &options,
827 EcmaVM *ecmaVm = thread->GetEcmaVM();
838 auto globalConst = thread->GlobalConstants();
841 array->Set(thread, 0, globalConst->GetHandledWeekdayString());
842 array->Set(thread, 1, globalConst->GetHandledYearString());
843 array->Set(thread, 2, globalConst->GetHandledMonthString()); // 2 means the third slot
844 array->Set(thread, 3, globalConst->GetHandledDayString()); // 3 means the fourth slot
845 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
848 key.Update(array->Get(thread, i));
865 array->Set(thread, 0, globalConst->GetHandledDayPeriodString());
866 array->Set(thread, 1, globalConst->GetHandledHourString());
867 array->Set(thread, 2, globalConst->GetHandledMinuteString()); // 2 means the second slot
868 array->Set(thread, 3, globalConst->GetHandledSecondString()); // 3 means the third slot
869 array->Set(thread, 4, globalConst->GetHandledFractionalSecondDigitsString()); // 4 means the fourth slot
870 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
873 key.Update(array->Get(thread, i));
913 JSHandle<EcmaString> JSDateTimeFormat::FormatDateTime(JSThread *thread,
917 JSHandle<EcmaString> res = FormatDateTime(thread, simpleDateFormat, x);
918 RETURN_HANDLE_IF_ABRUPT_COMPLETION(EcmaString, thread);
922 JSHandle<EcmaString> JSDateTimeFormat::FormatDateTime(JSThread *thread,
928 THROW_RANGE_ERROR_AND_RETURN(thread, "Invalid time value", thread->GetEcmaVM()->GetFactory()->GetEmptyString());
936 ThreadNativeScope nativeScope(thread);
941 return intl::LocaleHelper::UStringToString(thread, result);
945 JSHandle<JSArray> JSDateTimeFormat::FormatDateTimeToParts(JSThread *thread,
954 ThreadNativeScope nativeScope(thread);
958 THROW_TYPE_ERROR_AND_RETURN(thread, "format failed", thread->GetEcmaVM()->GetFactory()->NewJSArray());
962 JSHandle<JSArray> result(JSArray::ArrayCreate(thread, JSTaggedNumber(0)));
963 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSArray, thread);
989 JSMutableHandle<EcmaString> substring(thread, JSTaggedValue::Undefined());
993 substring.Update(intl::LocaleHelper::UStringToString(thread, formattedParts, part.fBeginIndex,
995 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSArray, thread);
1001 JSLocale::PutElement(thread, part.index, result, ConvertFieldIdToDateType(thread, -1),
1004 JSLocale::PutElement(thread, part.index, result, ConvertFieldIdToDateType(thread, part.fField),
1014 JSHandle<JSTaggedValue> JSDateTimeFormat::UnwrapDateTimeFormat(JSThread *thread,
1023 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1024 bool isInstanceOf = JSFunction::OrdinaryHasInstance(thread, env->GetDateTimeFormatFunction(), dateTimeFormat);
1025 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, dateTimeFormat);
1027 JSHandle<JSTaggedValue> key(thread, JSHandle<JSIntl>::Cast(env->GetIntlFunction())->GetFallbackSymbol());
1028 OperationResult operationResult = JSTaggedValue::GetProperty(thread, dateTimeFormat, key);
1029 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, dateTimeFormat);
1035 THROW_TYPE_ERROR_AND_RETURN(thread, "is not JSDateTimeFormat",
1036 JSHandle<JSTaggedValue>(thread, JSTaggedValue::Exception()));
1043 JSHandle<JSTaggedValue> ToHourCycleEcmaString(JSThread *thread, HourCycleOption hc)
1045 JSMutableHandle<JSTaggedValue> result(thread, JSTaggedValue::Undefined());
1046 auto globalConst = thread->GlobalConstants();
1067 JSHandle<JSTaggedValue> ToDateTimeStyleEcmaString(JSThread *thread, DateTimeStyleOption style)
1069 JSMutableHandle<JSTaggedValue> result(thread, JSTaggedValue::Undefined());
1070 auto globalConst = thread->GlobalConstants();
1092 void JSDateTimeFormat::ResolvedOptions(JSThread *thread, const JSHandle<JSDateTimeFormat> &dateTimeFormat,
1111 auto globalConst = thread->GlobalConstants();
1112 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1117 JSHandle<JSTaggedValue> locale(thread, dateTimeFormat->GetLocale());
1119 JSObject::CreateDataPropertyOrThrow(thread, options, property, locale);
1120 RETURN_IF_ABRUPT_COMPLETION(thread);
1122 JSMutableHandle<JSTaggedValue> calendarValue(thread, dateTimeFormat->GetCalendar());
1138 JSObject::CreateDataPropertyOrThrow(thread, options, property, calendarValue);
1139 RETURN_IF_ABRUPT_COMPLETION(thread);
1141 JSHandle<JSTaggedValue> numberingSystem(thread, dateTimeFormat->GetNumberingSystem());
1146 JSObject::CreateDataPropertyOrThrow(thread, options, property, numberingSystem);
1147 RETURN_IF_ABRUPT_COMPLETION(thread);
1149 JSMutableHandle<JSTaggedValue> timezoneValue(thread, dateTimeFormat->GetTimeZone());
1161 timezoneValue.Update(intl::LocaleHelper::UStringToString(thread, canonicalTimezone).GetTaggedValue());
1165 JSObject::CreateDataPropertyOrThrow(thread, options, property, timezoneValue);
1166 RETURN_IF_ABRUPT_COMPLETION(thread);
1175 hcValue = ToHourCycleEcmaString(thread, dateTimeFormat->GetHourCycle());
1176 JSObject::CreateDataPropertyOrThrow(thread, options, property, hcValue);
1177 RETURN_IF_ABRUPT_COMPLETION(thread);
1179 JSHandle<JSTaggedValue> trueValue(thread, JSTaggedValue::True());
1182 JSHandle<JSTaggedValue> falseValue(thread, JSTaggedValue::False());
1186 JSObject::CreateDataPropertyOrThrow(thread, options, property, hcValue);
1187 RETURN_IF_ABRUPT_COMPLETION(thread);
1202 JSHandle<JSTaggedValue> fsdValue(thread, JSTaggedValue(fsd));
1204 JSObject::CreateDataPropertyOrThrow(thread, options, property, fsdValue);
1205 RETURN_IF_ABRUPT_COMPLETION(thread);
1212 JSObject::CreateDataPropertyOrThrow(thread, options, property, hcValue);
1213 RETURN_IF_ABRUPT_COMPLETION(thread);
1221 hcValue = ToDateTimeStyleEcmaString(thread, dateTimeFormat->GetDateStyle());
1222 JSObject::CreateDataPropertyOrThrow(thread, options, property, hcValue);
1223 RETURN_IF_ABRUPT_COMPLETION(thread);
1227 hcValue = ToDateTimeStyleEcmaString(thread, dateTimeFormat->GetTimeStyle());
1228 JSObject::CreateDataPropertyOrThrow(thread, options, property, hcValue);
1229 RETURN_IF_ABRUPT_COMPLETION(thread);
1234 icu::FormattedDateInterval JSDateTimeFormat::ConstructDTFRange(JSThread *thread, const JSHandle<JSDateTimeFormat> &dtf,
1240 THROW_TYPE_ERROR_AND_RETURN(thread, "create dateIntervalFormat failed", emptyValue);
1248 JSHandle<EcmaString> JSDateTimeFormat::NormDateTimeRange(JSThread *thread, const JSHandle<JSDateTimeFormat> &dtf,
1251 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1257 THROW_RANGE_ERROR_AND_RETURN(thread, "x is NaN", result);
1263 THROW_RANGE_ERROR_AND_RETURN(thread, "y is NaN", result);
1266 icu::FormattedDateInterval formatted = ConstructDTFRange(thread, dtf, x, y);
1267 RETURN_HANDLE_IF_ABRUPT_COMPLETION(EcmaString, thread);
1274 THROW_TYPE_ERROR_AND_RETURN(thread, "format to string failed",
1275 thread->GetEcmaVM()->GetFactory()->GetEmptyString());
1284 result = intl::LocaleHelper::UStringToString(thread, formatResult);
1286 return FormatDateTime(thread, dtf, x);
1291 JSHandle<JSArray> JSDateTimeFormat::NormDateTimeRangeToParts(JSThread *thread, const JSHandle<JSDateTimeFormat> &dtf,
1294 JSHandle<JSArray> result(JSArray::ArrayCreate(thread, JSTaggedNumber(0)));
1295 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSArray, thread);
1300 THROW_RANGE_ERROR_AND_RETURN(thread, "x is invalid time value", result);
1306 THROW_RANGE_ERROR_AND_RETURN(thread, "y is invalid time value", result);
1309 icu::FormattedDateInterval formatted = ConstructDTFRange(thread, dtf, x, y);
1310 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSArray, thread);
1311 return ConstructFDateIntervalToJSArray(thread, formatted);
1314 JSHandle<TaggedArray> JSDateTimeFormat::GainAvailableLocales(JSThread *thread)
1316 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1321 std::vector<std::string> availableStringLocales = intl::LocaleHelper::GetAvailableLocales(thread, key, path);
1322 JSHandle<TaggedArray> availableLocales = JSLocale::ConstructLocaleList(thread, availableStringLocales);
1323 env->SetDateTimeFormatLocales(thread, availableLocales);
1329 JSHandle<JSArray> JSDateTimeFormat::ConstructFDateIntervalToJSArray(JSThread *thread,
1335 JSHandle<JSArray> array(JSArray::ArrayCreate(thread, JSTaggedNumber(0)));
1336 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSArray, thread);
1363 JSMutableHandle<EcmaString> substring(thread, JSTaggedValue::Undefined());
1387 THROW_TYPE_ERROR_AND_RETURN(thread, "format date interval error", array);
1394 substring.Update(intl::LocaleHelper::UStringToString(thread, formattedValue, part.fBeginIndex,
1396 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSArray, thread);
1399 element = JSLocale::PutElement(thread, part.index, array, ConvertFieldIdToDateType(thread, -1),
1402 element = JSLocale::PutElement(thread, part.index, array, ConvertFieldIdToDateType(thread, part.fField),
1405 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSArray, thread);
1407 ToValueString(thread, TrackValue(part.fBeginIndex, part.fEndIndex, begin, end)));
1408 JSObject::SetProperty(thread, element, thread->GlobalConstants()->GetHandledSourceString(), value, true);
1409 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSArray, thread);
1761 JSHandle<JSTaggedValue> JSDateTimeFormat::ConvertFieldIdToDateType(JSThread *thread, int32_t fieldId)
1763 JSMutableHandle<JSTaggedValue> result(thread, JSTaggedValue::Undefined());
1764 auto globalConst = thread->GlobalConstants();