Commit fd2df718 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

bindings: Define IDLAny and support it in NativeValueTraits

Bug: 839389
Change-Id: I6f4a03b1162f7d465c0f572d032d5fa878df3402
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040497Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738855}
parent 1e592fb9
......@@ -26,7 +26,10 @@ class ScriptValue;
// The type names below are named as "IDL" prefix + Web IDL type name.
// https://heycam.github.io/webidl/#dfn-type-name
// Boolean
// any
struct IDLAny final : public IDLBaseHelper<ScriptValue> {};
// boolean
struct IDLBoolean final : public IDLBaseHelper<bool> {};
// Integer types
......@@ -92,11 +95,11 @@ using IDLLongLongEnforceRange =
using IDLUnsignedLongLongEnforceRange =
IDLIntegerTypeBase<uint64_t, bindings::IDLIntegerConvMode::kEnforceRange>;
// Float
// float
struct IDLFloat final : public IDLBaseHelper<float> {};
struct IDLUnrestrictedFloat final : public IDLBaseHelper<float> {};
// Double
// double
struct IDLDouble final : public IDLBaseHelper<double> {};
struct IDLUnrestrictedDouble final : public IDLBaseHelper<double> {};
......@@ -161,10 +164,10 @@ using IDLUSVStringV2 =
// object
struct IDLObject final : public IDLBaseHelper<ScriptValue> {};
// Promise
// Promise types
struct IDLPromise final : public IDLBaseHelper<ScriptPromise> {};
// Sequence
// Sequence types
template <typename T>
struct IDLSequence final : public IDLBase {
using ImplType =
......@@ -175,7 +178,7 @@ struct IDLSequence final : public IDLBase {
template <typename T>
using IDLArray = IDLSequence<T>;
// Record
// Record types
template <typename Key, typename Value>
struct IDLRecord final : public IDLBase {
static_assert(std::is_same<typename Key::ImplType, String>::value,
......@@ -189,7 +192,7 @@ struct IDLRecord final : public IDLBase {
std::remove_pointer_t<typename NativeValueTraits<Value>::ImplType>>;
};
// Nullable
// Nullable types
template <typename InnerType>
struct IDLNullable final : public IDLBase {
using ImplType = std::conditional_t<
......
......@@ -58,7 +58,21 @@ CORE_EXPORT ScriptWrappable* NativeValueTraitsInterfaceOrNullArgumentValue(
} // namespace bindings
// Boolean
// any
template <>
struct CORE_EXPORT NativeValueTraits<IDLAny>
: public NativeValueTraitsBase<IDLAny> {
static ScriptValue NativeValue(v8::Isolate* isolate,
v8::Local<v8::Value> value,
ExceptionState& exception_state) {
return ScriptValue(isolate, value);
}
};
// IDLNullable<IDLAny> must not be used.
template <>
struct NativeValueTraits<IDLNullable<IDLAny>>;
// boolean
template <>
struct CORE_EXPORT NativeValueTraits<IDLBoolean>
: public NativeValueTraitsBase<IDLBoolean> {
......@@ -441,7 +455,7 @@ struct CORE_EXPORT NativeValueTraits<IDLNullable<IDLObject>>
}
};
// Promises
// Promise types
template <>
struct CORE_EXPORT NativeValueTraits<IDLPromise>
: public NativeValueTraitsBase<IDLPromise> {
......@@ -456,7 +470,7 @@ struct CORE_EXPORT NativeValueTraits<IDLPromise>
template <>
struct NativeValueTraits<IDLNullable<IDLPromise>>;
// Sequences
// Sequence types
template <typename T>
struct NativeValueTraits<IDLSequence<T>>
: public NativeValueTraitsBase<IDLSequence<T>> {
......@@ -584,7 +598,7 @@ struct NativeValueTraits<IDLSequence<T>>
}
};
// Records
// Record types
template <typename K, typename V>
struct NativeValueTraits<IDLRecord<K, V>>
: public NativeValueTraitsBase<IDLRecord<K, V>> {
......@@ -708,7 +722,7 @@ struct NativeValueTraits<IDLRecord<K, V>>
}
};
// Callback functions
// Callback function types
template <typename T>
struct NativeValueTraits<
T,
......@@ -728,7 +742,7 @@ struct NativeValueTraits<
}
};
// Dictionary
// Dictionary types
template <typename T>
struct NativeValueTraits<
T,
......@@ -742,7 +756,7 @@ struct NativeValueTraits<
}
};
// Enumeration
// Enumeration types
template <typename T>
struct NativeValueTraits<
T,
......@@ -756,7 +770,7 @@ struct NativeValueTraits<
}
};
// Interface
// Interface types
template <typename T>
struct NativeValueTraits<
T,
......@@ -805,7 +819,7 @@ struct NativeValueTraits<
}
};
// Union type
// Union types
template <typename T>
struct NativeValueTraits<
T,
......@@ -818,7 +832,7 @@ struct NativeValueTraits<
}
};
// Nullable
// Nullable types
template <typename InnerType>
struct NativeValueTraits<
IDLNullable<InnerType>,
......
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