Commit 1f09e468 authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ

[Temporal] Change Parser from Maybe to Optional

Bug: v8:11544
Change-Id: I16b1fb2cb4f6f4104b2f972a06b8fe0798ac6835
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3632675
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80435}
parent 1a5c64da
This diff is collapsed.
......@@ -5,6 +5,7 @@
#include "src/temporal/temporal-parser.h"
#include "src/base/bounds.h"
#include "src/base/optional.h"
#include "src/objects/string-inl.h"
#include "src/strings/char-predicates-inl.h"
......@@ -1186,23 +1187,23 @@ SATISIFY(TemporalDurationString, ParsedISO8601Duration)
} // namespace
#define IMPL_PARSE_METHOD(R, NAME) \
Maybe<R> TemporalParser::Parse##NAME(Isolate* isolate, \
Handle<String> iso_string) { \
bool valid; \
R parsed; \
iso_string = String::Flatten(isolate, iso_string); \
{ \
DisallowGarbageCollection no_gc; \
String::FlatContent str_content = iso_string->GetFlatContent(no_gc); \
if (str_content.IsOneByte()) { \
valid = Satisfy##NAME(str_content.ToOneByteVector(), &parsed); \
} else { \
valid = Satisfy##NAME(str_content.ToUC16Vector(), &parsed); \
} \
} \
if (valid) return Just(parsed); \
return Nothing<R>(); \
#define IMPL_PARSE_METHOD(R, NAME) \
base::Optional<R> TemporalParser::Parse##NAME(Isolate* isolate, \
Handle<String> iso_string) { \
bool valid; \
R parsed; \
iso_string = String::Flatten(isolate, iso_string); \
{ \
DisallowGarbageCollection no_gc; \
String::FlatContent str_content = iso_string->GetFlatContent(no_gc); \
if (str_content.IsOneByte()) { \
valid = Satisfy##NAME(str_content.ToOneByteVector(), &parsed); \
} else { \
valid = Satisfy##NAME(str_content.ToUC16Vector(), &parsed); \
} \
} \
if (valid) return parsed; \
return base::nullopt; \
}
IMPL_PARSE_METHOD(ParsedISO8601Result, TemporalDateTimeString)
......
......@@ -5,6 +5,7 @@
#ifndef V8_TEMPORAL_TEMPORAL_PARSER_H_
#define V8_TEMPORAL_TEMPORAL_PARSER_H_
#include "src/base/optional.h"
#include "src/execution/isolate.h"
namespace v8 {
......@@ -126,9 +127,9 @@ struct ParsedISO8601Duration {
*/
class V8_EXPORT_PRIVATE TemporalParser {
public:
#define DEFINE_PARSE_METHOD(R, NAME) \
V8_WARN_UNUSED_RESULT static Maybe<R> Parse##NAME(Isolate* isolate, \
Handle<String> iso_string)
#define DEFINE_PARSE_METHOD(R, NAME) \
V8_WARN_UNUSED_RESULT static base::Optional<R> Parse##NAME( \
Isolate* isolate, Handle<String> iso_string)
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalDateString);
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalDateTimeString);
DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalTimeString);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment