5#ifndef V8_OBJECTS_OPTION_UTILS_H_
6#define V8_OBJECTS_OPTION_UTILS_H_
18 Isolate* isolate, DirectHandle<Object> options,
const char* method_name);
22 Isolate* isolate, DirectHandle<Object> options,
const char* method_name);
40 Isolate* isolate, DirectHandle<JSReceiver> options,
const char* property,
41 const std::vector<const char*>& values,
const char* method_name,
42 std::unique_ptr<
char[]>*
result);
51 const char* method_name,
const std::vector<const char*>& str_values,
52 const std::vector<T>& enum_values, T default_value) {
53 DCHECK_EQ(str_values.size(), enum_values.size());
54 std::unique_ptr<char[]> cstr;
56 GetStringOption(isolate, options, name, str_values, method_name, &cstr);
60 for (
size_t i = 0;
i < str_values.size();
i++) {
61 if (strcmp(cstr.get(), str_values[
i]) == 0) {
62 return Just(enum_values[
i]);
67 return Just(default_value);
77 const char*
method,
const std::vector<const char*>& str_values,
78 const std::vector<T>& enum_values, T true_value, T false_value,
80 DCHECK_EQ(str_values.size(), enum_values.size());
81 Factory* factory = isolate->factory();
92 if (IsUndefined(*value, isolate)) {
93 return Just(fallback_value);
96 if (IsTrue(*value, isolate)) {
97 return Just(true_value);
103 return Just(false_value);
113 return Just(fallback_value);
122 int32_t length = value_str->length();
123 for (
size_t i = 0;
i < str_values.size();
i++) {
124 if (
static_cast<int32_t
>(strlen(str_values.at(
i))) == length) {
128 return Just(enum_values[
i]);
133 return Just(enum_values[
i]);
141 NewRangeError(MessageTemplate::kValueOutOfRange, value,
159 Isolate* isolate, DirectHandle<JSReceiver> options,
const char* property,
160 const char* method_name,
bool*
result);
163 Isolate* isolate, DirectHandle<JSReceiver> options,
164 DirectHandle<String> property,
int min,
int max,
int fallback);
168 Isolate* isolate, DirectHandle<JSReceiver> options,
169 DirectHandle<String> property,
double default_value);
173 Isolate* isolate, DirectHandle<Object> value,
int min,
int max,
174 int fallback, DirectHandle<String> property);
V8_INLINE T FromJust() const &
constexpr T * begin() const
Handle< String > NewStringFromAsciiChecked(const char *str, AllocationType allocation=AllocationType::kYoung)
static V8_WARN_UNUSED_RESULT HandleType< String >::MaybeType ToString(Isolate *isolate, HandleType< T > input)
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > GetPropertyOrElement(Isolate *isolate, DirectHandle< JSAny > object, DirectHandle< Name > name)
static V8_EXPORT_PRIVATE bool BooleanValue(Tagged< Object > obj, IsolateT *isolate)
base::Vector< const uint8_t > ToOneByteVector() const
base::Vector< const base::uc16 > ToUC16Vector() const
static V8_INLINE HandleType< String > Flatten(Isolate *isolate, HandleType< T > string, AllocationType allocation=AllocationType::kYoung)
bool Equals(Tagged< String > other) const
#define THROW_NEW_ERROR_RETURN_VALUE(isolate, call, value)
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
#define MAYBE_RETURN(call, value)
ZoneVector< RpoNumber > & result
Maybe< double > GetNumberOptionAsDouble(Isolate *isolate, DirectHandle< JSReceiver > options, DirectHandle< String > property, double default_value)
Maybe< int > DefaultNumberOption(Isolate *isolate, DirectHandle< Object > value, int min, int max, int fallback, DirectHandle< String > property)
MaybeDirectHandle< JSReceiver > GetOptionsObject(Isolate *isolate, DirectHandle< Object > options, const char *method_name)
bool CompareCharsEqual(const lchar *lhs, const rchar *rhs, size_t chars)
V8_WARN_UNUSED_RESULT Maybe< bool > GetBoolOption(Isolate *isolate, DirectHandle< JSReceiver > options, const char *property, const char *method_name, bool *result)
Maybe< int > GetNumberOption(Isolate *isolate, DirectHandle< JSReceiver > options, DirectHandle< String > property, int min, int max, int fallback)
MaybeDirectHandle< JSReceiver > CoerceOptionsToObject(Isolate *isolate, DirectHandle< Object > options, const char *method_name)
static V8_WARN_UNUSED_RESULT Maybe< T > GetStringOrBooleanOption(Isolate *isolate, DirectHandle< JSReceiver > options, const char *property, const char *method, const std::vector< const char * > &str_values, const std::vector< T > &enum_values, T true_value, T false_value, T fallback_value)
Maybe< bool > GetStringOption(Isolate *isolate, DirectHandle< JSReceiver > options, const char *property, const std::vector< const char * > &values, const char *method_name, std::unique_ptr< char[]> *result)
Maybe< T > Just(const T &t)
#define DCHECK_NOT_NULL(val)
#define DCHECK_EQ(v1, v2)
#define V8_EXPORT_PRIVATE
#define V8_WARN_UNUSED_RESULT