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; ...@@ -26,7 +26,10 @@ class ScriptValue;
// The type names below are named as "IDL" prefix + Web IDL type name. // The type names below are named as "IDL" prefix + Web IDL type name.
// https://heycam.github.io/webidl/#dfn-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> {}; struct IDLBoolean final : public IDLBaseHelper<bool> {};
// Integer types // Integer types
...@@ -92,11 +95,11 @@ using IDLLongLongEnforceRange = ...@@ -92,11 +95,11 @@ using IDLLongLongEnforceRange =
using IDLUnsignedLongLongEnforceRange = using IDLUnsignedLongLongEnforceRange =
IDLIntegerTypeBase<uint64_t, bindings::IDLIntegerConvMode::kEnforceRange>; IDLIntegerTypeBase<uint64_t, bindings::IDLIntegerConvMode::kEnforceRange>;
// Float // float
struct IDLFloat final : public IDLBaseHelper<float> {}; struct IDLFloat final : public IDLBaseHelper<float> {};
struct IDLUnrestrictedFloat final : public IDLBaseHelper<float> {}; struct IDLUnrestrictedFloat final : public IDLBaseHelper<float> {};
// Double // double
struct IDLDouble final : public IDLBaseHelper<double> {}; struct IDLDouble final : public IDLBaseHelper<double> {};
struct IDLUnrestrictedDouble final : public IDLBaseHelper<double> {}; struct IDLUnrestrictedDouble final : public IDLBaseHelper<double> {};
...@@ -161,10 +164,10 @@ using IDLUSVStringV2 = ...@@ -161,10 +164,10 @@ using IDLUSVStringV2 =
// object // object
struct IDLObject final : public IDLBaseHelper<ScriptValue> {}; struct IDLObject final : public IDLBaseHelper<ScriptValue> {};
// Promise // Promise types
struct IDLPromise final : public IDLBaseHelper<ScriptPromise> {}; struct IDLPromise final : public IDLBaseHelper<ScriptPromise> {};
// Sequence // Sequence types
template <typename T> template <typename T>
struct IDLSequence final : public IDLBase { struct IDLSequence final : public IDLBase {
using ImplType = using ImplType =
...@@ -175,7 +178,7 @@ struct IDLSequence final : public IDLBase { ...@@ -175,7 +178,7 @@ struct IDLSequence final : public IDLBase {
template <typename T> template <typename T>
using IDLArray = IDLSequence<T>; using IDLArray = IDLSequence<T>;
// Record // Record types
template <typename Key, typename Value> template <typename Key, typename Value>
struct IDLRecord final : public IDLBase { struct IDLRecord final : public IDLBase {
static_assert(std::is_same<typename Key::ImplType, String>::value, static_assert(std::is_same<typename Key::ImplType, String>::value,
...@@ -189,7 +192,7 @@ struct IDLRecord final : public IDLBase { ...@@ -189,7 +192,7 @@ struct IDLRecord final : public IDLBase {
std::remove_pointer_t<typename NativeValueTraits<Value>::ImplType>>; std::remove_pointer_t<typename NativeValueTraits<Value>::ImplType>>;
}; };
// Nullable // Nullable types
template <typename InnerType> template <typename InnerType>
struct IDLNullable final : public IDLBase { struct IDLNullable final : public IDLBase {
using ImplType = std::conditional_t< using ImplType = std::conditional_t<
......
...@@ -58,7 +58,21 @@ CORE_EXPORT ScriptWrappable* NativeValueTraitsInterfaceOrNullArgumentValue( ...@@ -58,7 +58,21 @@ CORE_EXPORT ScriptWrappable* NativeValueTraitsInterfaceOrNullArgumentValue(
} // namespace bindings } // 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 <> template <>
struct CORE_EXPORT NativeValueTraits<IDLBoolean> struct CORE_EXPORT NativeValueTraits<IDLBoolean>
: public NativeValueTraitsBase<IDLBoolean> { : public NativeValueTraitsBase<IDLBoolean> {
...@@ -441,7 +455,7 @@ struct CORE_EXPORT NativeValueTraits<IDLNullable<IDLObject>> ...@@ -441,7 +455,7 @@ struct CORE_EXPORT NativeValueTraits<IDLNullable<IDLObject>>
} }
}; };
// Promises // Promise types
template <> template <>
struct CORE_EXPORT NativeValueTraits<IDLPromise> struct CORE_EXPORT NativeValueTraits<IDLPromise>
: public NativeValueTraitsBase<IDLPromise> { : public NativeValueTraitsBase<IDLPromise> {
...@@ -456,7 +470,7 @@ struct CORE_EXPORT NativeValueTraits<IDLPromise> ...@@ -456,7 +470,7 @@ struct CORE_EXPORT NativeValueTraits<IDLPromise>
template <> template <>
struct NativeValueTraits<IDLNullable<IDLPromise>>; struct NativeValueTraits<IDLNullable<IDLPromise>>;
// Sequences // Sequence types
template <typename T> template <typename T>
struct NativeValueTraits<IDLSequence<T>> struct NativeValueTraits<IDLSequence<T>>
: public NativeValueTraitsBase<IDLSequence<T>> { : public NativeValueTraitsBase<IDLSequence<T>> {
...@@ -584,7 +598,7 @@ struct NativeValueTraits<IDLSequence<T>> ...@@ -584,7 +598,7 @@ struct NativeValueTraits<IDLSequence<T>>
} }
}; };
// Records // Record types
template <typename K, typename V> template <typename K, typename V>
struct NativeValueTraits<IDLRecord<K, V>> struct NativeValueTraits<IDLRecord<K, V>>
: public NativeValueTraitsBase<IDLRecord<K, V>> { : public NativeValueTraitsBase<IDLRecord<K, V>> {
...@@ -708,7 +722,7 @@ struct NativeValueTraits<IDLRecord<K, V>> ...@@ -708,7 +722,7 @@ struct NativeValueTraits<IDLRecord<K, V>>
} }
}; };
// Callback functions // Callback function types
template <typename T> template <typename T>
struct NativeValueTraits< struct NativeValueTraits<
T, T,
...@@ -728,7 +742,7 @@ struct NativeValueTraits< ...@@ -728,7 +742,7 @@ struct NativeValueTraits<
} }
}; };
// Dictionary // Dictionary types
template <typename T> template <typename T>
struct NativeValueTraits< struct NativeValueTraits<
T, T,
...@@ -742,7 +756,7 @@ struct NativeValueTraits< ...@@ -742,7 +756,7 @@ struct NativeValueTraits<
} }
}; };
// Enumeration // Enumeration types
template <typename T> template <typename T>
struct NativeValueTraits< struct NativeValueTraits<
T, T,
...@@ -756,7 +770,7 @@ struct NativeValueTraits< ...@@ -756,7 +770,7 @@ struct NativeValueTraits<
} }
}; };
// Interface // Interface types
template <typename T> template <typename T>
struct NativeValueTraits< struct NativeValueTraits<
T, T,
...@@ -805,7 +819,7 @@ struct NativeValueTraits< ...@@ -805,7 +819,7 @@ struct NativeValueTraits<
} }
}; };
// Union type // Union types
template <typename T> template <typename T>
struct NativeValueTraits< struct NativeValueTraits<
T, T,
...@@ -818,7 +832,7 @@ struct NativeValueTraits< ...@@ -818,7 +832,7 @@ struct NativeValueTraits<
} }
}; };
// Nullable // Nullable types
template <typename InnerType> template <typename InnerType>
struct NativeValueTraits< struct NativeValueTraits<
IDLNullable<InnerType>, 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