Commit 44bda444 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

gin: Remove ToV8Traits; templating TryConvertToV8 suffices.

Just a simplification.

Change-Id: I5aea1364540c0ab7b9266dca03884b079468e574
Reviewed-on: https://chromium-review.googlesource.com/964393
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543749}
parent 46feb737
...@@ -224,32 +224,17 @@ ConvertToV8(v8::Isolate* isolate, T input) { ...@@ -224,32 +224,17 @@ ConvertToV8(v8::Isolate* isolate, T input) {
return Converter<T>::ToV8(isolate, input); return Converter<T>::ToV8(isolate, input);
} }
template<typename T, bool = ToV8ReturnsMaybe<T>::value> struct ToV8Traits;
template <typename T> template <typename T>
struct ToV8Traits<T, true> { std::enable_if_t<ToV8ReturnsMaybe<T>::value, bool>
static bool TryConvertToV8(v8::Isolate* isolate, TryConvertToV8(v8::Isolate* isolate, T input, v8::Local<v8::Value>* output) {
T input,
v8::Local<v8::Value>* output) {
return ConvertToV8(isolate, input).ToLocal(output); return ConvertToV8(isolate, input).ToLocal(output);
} }
};
template <typename T> template <typename T>
struct ToV8Traits<T, false> { std::enable_if_t<!ToV8ReturnsMaybe<T>::value, bool>
static bool TryConvertToV8(v8::Isolate* isolate, TryConvertToV8(v8::Isolate* isolate, T input, v8::Local<v8::Value>* output) {
T input,
v8::Local<v8::Value>* output) {
*output = ConvertToV8(isolate, input); *output = ConvertToV8(isolate, input);
return true; return true;
}
};
template <typename T>
bool TryConvertToV8(v8::Isolate* isolate,
T input,
v8::Local<v8::Value>* output) {
return ToV8Traits<T>::TryConvertToV8(isolate, input, output);
} }
// This crashes when input.size() > v8::String::kMaxLength. // This crashes when input.size() > v8::String::kMaxLength.
......
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