Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/IDLTypes.h |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/IDLTypes.h b/third_party/WebKit/Source/bindings/core/v8/IDLTypes.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..69a8c853949fd60ba13d48fbf998da0b84f3324d |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/bindings/core/v8/IDLTypes.h |
| @@ -0,0 +1,92 @@ |
| +// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef IDLTypes_h |
| +#define IDLTypes_h |
| + |
| +#include <type_traits> |
| +#include "bindings/core/v8/IDLTypesBase.h" |
| +#include "bindings/core/v8/NativeValueTraits.h" |
| +#include "bindings/core/v8/V8Binding.h" |
| +#include "core/CoreExport.h" |
| +#include "platform/heap/Handle.h" |
| +#include "wtf/TypeTraits.h" |
| +#include "wtf/text/WTFString.h" |
| + |
| +namespace blink { |
| + |
| +class ScriptPromise; |
| + |
| +// Boolean |
| +struct CORE_EXPORT IDLBoolean final : public IDLBaseHelper<bool> {}; |
| + |
| +// Integers |
| +struct CORE_EXPORT IDLByte final : public IDLBaseHelper<int8_t> {}; |
| +struct CORE_EXPORT IDLOctet final : public IDLBaseHelper<uint8_t> {}; |
| +struct CORE_EXPORT IDLShort final : public IDLBaseHelper<int16_t> {}; |
| +struct CORE_EXPORT IDLUnsignedShort final : public IDLBaseHelper<uint16_t> {}; |
| +struct CORE_EXPORT IDLLong final : public IDLBaseHelper<int32_t> {}; |
| +struct CORE_EXPORT IDLUnsignedLong final : public IDLBaseHelper<uint32_t> {}; |
| +struct CORE_EXPORT IDLLongLong final : public IDLBaseHelper<int64_t> {}; |
| +struct CORE_EXPORT IDLUnsignedLongLong final : public IDLBaseHelper<uint64_t> { |
| +}; |
| + |
| +// Strings |
| +struct CORE_EXPORT IDLByteString final : public IDLBaseHelper<String> {}; |
| +struct CORE_EXPORT IDLString final : public IDLBaseHelper<String> {}; |
| +struct CORE_EXPORT IDLUSVString final : public IDLBaseHelper<String> {}; |
| + |
| +// Double |
| +struct CORE_EXPORT IDLDouble final : public IDLBaseHelper<double> {}; |
| +struct CORE_EXPORT IDLUnrestrictedDouble final : public IDLBaseHelper<double> { |
| +}; |
| + |
| +// Float |
| +struct CORE_EXPORT IDLFloat final : public IDLBaseHelper<float> {}; |
| +struct CORE_EXPORT IDLUnrestrictedFloat final : public IDLBaseHelper<float> {}; |
| + |
| +struct CORE_EXPORT IDLDate final : public IDLBaseHelper<double> {}; |
| + |
| +// Promise |
| +struct CORE_EXPORT IDLPromise final : public IDLBaseHelper<ScriptPromise> {}; |
| + |
| +// Template helpers for type introspection |
| +struct IDLTypesHelper { |
|
haraken
2017/03/06 12:56:32
I'd prefer not introducing IDLTypesHelper though.
|
| + STATIC_ONLY(IDLTypesHelper); |
| + |
| + // Whether a type needs to be wrapped in Member<> (i.e. Oilpan-based types). |
| + template <typename T> |
| + struct MaybeWrapped { |
|
haraken
2017/03/06 12:56:32
MaybeWrapped => NeedsMember ?
Yuki
2017/03/08 10:14:22
rakuco, you seems overlooking this comment.
This
|
| + using ImplType = typename std:: |
| + conditional<WTF::IsGarbageCollectedType<T>::value, Member<T>, T>::type; |
| + }; |
| + |
| + // Whether a type should be wrapped in Vector<> or HeapVector<>. HeapVector<> |
| + // is used for Oilpan-based types as well as IDL unions and dictionaries |
| + // (which have V8TypeOf). |
| + template <typename T> |
| + struct NeedsHeapVector { |
| + static const bool value = WTF::IsGarbageCollectedType<T>::value || |
| + std::is_class<typename V8TypeOf<T>::Type>::value; |
|
haraken
2017/03/06 12:56:32
What is std::is_class<typename V8TypeOf<T>::Type>:
|
| + }; |
| +}; |
| + |
| +// Sequence |
| +template <typename T> |
| +struct CORE_EXPORT IDLSequence final : public IDLBase { |
| + private: |
| + using CppType = typename NativeValueTraits<T>::ImplType; |
| + using MaybeWrappedCppType = |
| + typename IDLTypesHelper::MaybeWrapped<CppType>::ImplType; |
| + |
| + public: |
| + using ImplType = |
| + typename std::conditional<IDLTypesHelper::NeedsHeapVector<CppType>::value, |
| + HeapVector<MaybeWrappedCppType>, |
| + Vector<MaybeWrappedCppType>>::type; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // IDLTypes_h |