diff options
| author | Devin Moore <devinmoore@google.com> | 2020-09-28 20:33:15 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-09-28 20:33:15 +0000 |
| commit | 37651d87ccc1d2162445e59978c64d03e3bc52fd (patch) | |
| tree | 3c074e98d8312e3bdd9bb11a794ee9b26d4bd35b /include | |
| parent | b00fb7d03ea5ad696bdbbc5420f5bca3822304cc (diff) | |
| parent | b9280aa8cc47bef592623239412db21faabcc951 (diff) | |
| download | platform_system_libfmq-37651d87ccc1d2162445e59978c64d03e3bc52fd.tar.gz platform_system_libfmq-37651d87ccc1d2162445e59978c64d03e3bc52fd.tar.bz2 platform_system_libfmq-37651d87ccc1d2162445e59978c64d03e3bc52fd.zip | |
Merge "Check payload type for @FixedSize or is_fundamental"
Diffstat (limited to 'include')
| -rw-r--r-- | include/fmq/AidlMessageQueue.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/fmq/AidlMessageQueue.h b/include/fmq/AidlMessageQueue.h index eaef087..9bc0792 100644 --- a/include/fmq/AidlMessageQueue.h +++ b/include/fmq/AidlMessageQueue.h @@ -48,9 +48,24 @@ struct FlavorTypeToValue<UnsynchronizedWrite> { typedef uint64_t RingBufferPosition; +/* + * AIDL parcelables will have the typedef fixed_size. It is std::true_type when the + * parcelable is annotated with @FixedSize, and std::false_type when not. Other types + * should not have the fixed_size typedef, so they will always resolve to std::false_type. + */ +template <typename T, typename = void> +struct has_typedef_fixed_size : std::false_type {}; + +template <typename T> +struct has_typedef_fixed_size<T, std::void_t<typename T::fixed_size>> : T::fixed_size {}; + template <typename T, typename U> struct AidlMessageQueue final : public MessageQueueBase<AidlMQDescriptorShim, T, FlavorTypeToValue<U>::value> { + static_assert(has_typedef_fixed_size<T>::value == true || std::is_fundamental<T>::value || + std::is_enum<T>::value, + "Only fundamental types, enums, and AIDL parcelables annotated with @FixedSize " + "are supported as payload types(T)."); typedef AidlMQDescriptorShim<T, FlavorTypeToValue<U>::value> Descriptor; /** * This constructor uses the external descriptor used with AIDL interfaces. |
