Use std::function

Repalce old C style function pointer declaration

Bug: v8:12083
Change-Id: I0e7b0c808a7c195989cc75da5d6617d7295918f9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3088357
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76285}
This commit is contained in:
Frank Tang 2021-08-12 10:14:23 -07:00 committed by V8 LUCI CQ
parent 4d0730084d
commit c4e4868e03
3 changed files with 7 additions and 6 deletions

View File

@ -2209,8 +2209,8 @@ template <typename T>
MaybeHandle<T> FormatRangeCommon(
Isolate* isolate, Handle<JSDateTimeFormat> date_time_format, double x,
double y,
MaybeHandle<T> (*formatToResult)(Isolate*, const icu::FormattedValue&,
bool*),
const std::function<MaybeHandle<T>(Isolate*, const icu::FormattedValue&,
bool*)>& formatToResult,
bool* outputRange) {
// Track newer feature formateRange and formatRangeToParts
isolate->CountUsage(v8::Isolate::UseCounterFeature::kDateTimeFormatRange);

View File

@ -220,7 +220,8 @@ Maybe<std::vector<icu::UnicodeString>> ToUnicodeStringArray(
template <typename T>
MaybeHandle<T> FormatListCommon(
Isolate* isolate, Handle<JSListFormat> format, Handle<JSArray> list,
MaybeHandle<T> (*formatToResult)(Isolate*, const icu::FormattedValue&)) {
const std::function<MaybeHandle<T>(Isolate*, const icu::FormattedValue&)>&
formatToResult) {
DCHECK(!list->IsUndefined());
Maybe<std::vector<icu::UnicodeString>> maybe_array =
ToUnicodeStringArray(isolate, list);

View File

@ -342,9 +342,9 @@ template <typename T>
MaybeHandle<T> FormatCommon(
Isolate* isolate, Handle<JSRelativeTimeFormat> format,
Handle<Object> value_obj, Handle<Object> unit_obj, const char* func_name,
MaybeHandle<T> (*formatToResult)(Isolate*,
const icu::FormattedRelativeDateTime&,
Handle<Object>, Handle<String>)) {
const std::function<
MaybeHandle<T>(Isolate*, const icu::FormattedRelativeDateTime&,
Handle<Object>, Handle<String>)>& formatToResult) {
// 3. Let value be ? ToNumber(value).
Handle<Object> value;
ASSIGN_RETURN_ON_EXCEPTION(isolate, value,