diff options
Diffstat (limited to 'tests/golden_output/aidl-test-interface-cpp-source/gen/include/android')
10 files changed, 353 insertions, 39 deletions
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h index 0265063d..b5c0a6ce 100644 --- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h +++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h @@ -2,12 +2,16 @@ #include <android/aidl/tests/ArrayOfInterfaces.h> #include <android/binder_to_string.h> +#include <array> +#include <binder/Enums.h> #include <binder/IBinder.h> #include <binder/IInterface.h> #include <binder/Parcel.h> #include <binder/Status.h> #include <cassert> +#include <cstdint> #include <optional> +#include <string> #include <tuple> #include <type_traits> #include <utility> @@ -136,12 +140,17 @@ public: }; // class MyParcelable class MyUnion : public ::android::Parcelable { public: - enum Tag : int32_t { - iface = 0, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface iface; - nullable_iface, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface nullable_iface; - iface_array, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface[] iface_array; - nullable_iface_array, // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface[] nullable_iface_array; + enum class Tag : int32_t { + iface = 0, + nullable_iface = 1, + iface_array = 2, + nullable_iface_array = 3, }; + // Expose tag symbols for legacy code + static const inline Tag iface = Tag::iface; + static const inline Tag nullable_iface = Tag::nullable_iface; + static const inline Tag iface_array = Tag::iface_array; + static const inline Tag nullable_iface_array = Tag::nullable_iface_array; template<typename _Tp> static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, MyUnion>; @@ -263,3 +272,37 @@ public: } // namespace tests } // namespace aidl } // namespace android +namespace android { +namespace aidl { +namespace tests { +[[nodiscard]] static inline std::string toString(ArrayOfInterfaces::MyUnion::Tag val) { + switch(val) { + case ArrayOfInterfaces::MyUnion::Tag::iface: + return "iface"; + case ArrayOfInterfaces::MyUnion::Tag::nullable_iface: + return "nullable_iface"; + case ArrayOfInterfaces::MyUnion::Tag::iface_array: + return "iface_array"; + case ArrayOfInterfaces::MyUnion::Tag::nullable_iface_array: + return "nullable_iface_array"; + default: + return std::to_string(static_cast<int32_t>(val)); + } +} +} // namespace tests +} // namespace aidl +} // namespace android +namespace android { +namespace internal { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++17-extensions" +template <> +constexpr inline std::array<::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag, 4> enum_values<::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag> = { + ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::iface, + ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::nullable_iface, + ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::iface_array, + ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::nullable_iface_array, +}; +#pragma clang diagnostic pop +} // namespace internal +} // namespace android diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h index 2d2a8648..3cb8ad0d 100644 --- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h +++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h @@ -71,8 +71,9 @@ public: static constexpr uint32_t TRANSACTION_ReverseNullableIBinderArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 60; static constexpr uint32_t TRANSACTION_GetOldNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 61; static constexpr uint32_t TRANSACTION_GetNewNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 62; - static constexpr uint32_t TRANSACTION_GetCppJavaTests = ::android::IBinder::FIRST_CALL_TRANSACTION + 63; - static constexpr uint32_t TRANSACTION_getBackendType = ::android::IBinder::FIRST_CALL_TRANSACTION + 64; + static constexpr uint32_t TRANSACTION_GetUnionTags = ::android::IBinder::FIRST_CALL_TRANSACTION + 63; + static constexpr uint32_t TRANSACTION_GetCppJavaTests = ::android::IBinder::FIRST_CALL_TRANSACTION + 64; + static constexpr uint32_t TRANSACTION_getBackendType = ::android::IBinder::FIRST_CALL_TRANSACTION + 65; explicit BnTestService(); ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override; }; // class BnTestService @@ -270,6 +271,9 @@ public: ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) override { return _aidl_delegate->GetNewNameInterface(_aidl_return); } + ::android::binder::Status GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _aidl_return) override { + return _aidl_delegate->GetUnionTags(input, _aidl_return); + } ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) override { return _aidl_delegate->GetCppJavaTests(_aidl_return); } diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h index c1cbaa8d..3829d9b9 100644 --- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h +++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h @@ -75,6 +75,7 @@ public: ::android::binder::Status ReverseNullableIBinderArray(const ::std::optional<::std::vector<::android::sp<::android::IBinder>>>& input, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* repeated, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* _aidl_return) override; ::android::binder::Status GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>* _aidl_return) override; ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) override; + ::android::binder::Status GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _aidl_return) override; ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) override; ::android::binder::Status getBackendType(::android::aidl::tests::BackendType* _aidl_return) override; }; // class BpTestService diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h index f94a3b88..65f67117 100644 --- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h +++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h @@ -3,10 +3,13 @@ #include <android/aidl/tests/FixedSize.h> #include <android/aidl/tests/LongEnum.h> #include <android/binder_to_string.h> +#include <array> +#include <binder/Enums.h> #include <binder/Parcel.h> #include <binder/Status.h> #include <cassert> #include <cstdint> +#include <string> #include <tuple> #include <type_traits> #include <utility> @@ -24,16 +27,25 @@ class FixedSize : public ::android::Parcelable { public: class FixedUnion : public ::android::Parcelable { public: - enum Tag : uint8_t { - booleanValue = 0, // boolean booleanValue; - byteValue, // byte byteValue; - charValue, // char charValue; - intValue, // int intValue; - longValue, // long longValue; - floatValue, // float floatValue; - doubleValue, // double doubleValue; - enumValue, // android.aidl.tests.LongEnum enumValue; + enum class Tag : int8_t { + booleanValue = 0, + byteValue = 1, + charValue = 2, + intValue = 3, + longValue = 4, + floatValue = 5, + doubleValue = 6, + enumValue = 7, }; + // Expose tag symbols for legacy code + static const inline Tag booleanValue = Tag::booleanValue; + static const inline Tag byteValue = Tag::byteValue; + static const inline Tag charValue = Tag::charValue; + static const inline Tag intValue = Tag::intValue; + static const inline Tag longValue = Tag::longValue; + static const inline Tag floatValue = Tag::floatValue; + static const inline Tag doubleValue = Tag::doubleValue; + static const inline Tag enumValue = Tag::enumValue; template <Tag _Tag> using _at = typename std::tuple_element<static_cast<size_t>(_Tag), std::tuple<bool, int8_t, char16_t, int32_t, int64_t, float, double, ::android::aidl::tests::LongEnum>>::type; @@ -119,7 +131,7 @@ public: return os.str(); } private: - Tag _tag __attribute__((aligned (1))) = booleanValue; + Tag _tag = booleanValue; union _value_t { _value_t() {} ~_value_t() {} @@ -220,3 +232,49 @@ public: } // namespace tests } // namespace aidl } // namespace android +namespace android { +namespace aidl { +namespace tests { +[[nodiscard]] static inline std::string toString(FixedSize::FixedUnion::Tag val) { + switch(val) { + case FixedSize::FixedUnion::Tag::booleanValue: + return "booleanValue"; + case FixedSize::FixedUnion::Tag::byteValue: + return "byteValue"; + case FixedSize::FixedUnion::Tag::charValue: + return "charValue"; + case FixedSize::FixedUnion::Tag::intValue: + return "intValue"; + case FixedSize::FixedUnion::Tag::longValue: + return "longValue"; + case FixedSize::FixedUnion::Tag::floatValue: + return "floatValue"; + case FixedSize::FixedUnion::Tag::doubleValue: + return "doubleValue"; + case FixedSize::FixedUnion::Tag::enumValue: + return "enumValue"; + default: + return std::to_string(static_cast<int8_t>(val)); + } +} +} // namespace tests +} // namespace aidl +} // namespace android +namespace android { +namespace internal { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++17-extensions" +template <> +constexpr inline std::array<::android::aidl::tests::FixedSize::FixedUnion::Tag, 8> enum_values<::android::aidl::tests::FixedSize::FixedUnion::Tag> = { + ::android::aidl::tests::FixedSize::FixedUnion::Tag::booleanValue, + ::android::aidl::tests::FixedSize::FixedUnion::Tag::byteValue, + ::android::aidl::tests::FixedSize::FixedUnion::Tag::charValue, + ::android::aidl::tests::FixedSize::FixedUnion::Tag::intValue, + ::android::aidl::tests::FixedSize::FixedUnion::Tag::longValue, + ::android::aidl::tests::FixedSize::FixedUnion::Tag::floatValue, + ::android::aidl::tests::FixedSize::FixedUnion::Tag::doubleValue, + ::android::aidl::tests::FixedSize::FixedUnion::Tag::enumValue, +}; +#pragma clang diagnostic pop +} // namespace internal +} // namespace android diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h index dd0e7f1c..9246a87e 100644 --- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h +++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h @@ -10,6 +10,7 @@ #include <android/aidl/tests/LongEnum.h> #include <android/aidl/tests/RecursiveList.h> #include <android/aidl/tests/StructuredParcelable.h> +#include <android/aidl/tests/Union.h> #include <android/aidl/tests/extension/ExtendableParcelable.h> #include <android/binder_to_string.h> #include <binder/IBinder.h> @@ -272,6 +273,7 @@ public: virtual ::android::binder::Status ReverseNullableIBinderArray(const ::std::optional<::std::vector<::android::sp<::android::IBinder>>>& input, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* repeated, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* _aidl_return) = 0; virtual ::android::binder::Status GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>* _aidl_return) = 0; virtual ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) = 0; + virtual ::android::binder::Status GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _aidl_return) = 0; virtual ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) = 0; virtual ::android::binder::Status getBackendType(::android::aidl::tests::BackendType* _aidl_return) = 0; }; // class ITestService @@ -470,6 +472,9 @@ public: ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* /*_aidl_return*/) override { return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); } + ::android::binder::Status GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& /*input*/, ::std::vector<::android::aidl::tests::Union::Tag>* /*_aidl_return*/) override { + return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); + } ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* /*_aidl_return*/) override { return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); } diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h index e9dcb2b0..455bf4b6 100644 --- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h +++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h @@ -2,12 +2,16 @@ #include <android/aidl/tests/ListOfInterfaces.h> #include <android/binder_to_string.h> +#include <array> +#include <binder/Enums.h> #include <binder/IBinder.h> #include <binder/IInterface.h> #include <binder/Parcel.h> #include <binder/Status.h> #include <cassert> +#include <cstdint> #include <optional> +#include <string> #include <tuple> #include <type_traits> #include <utility> @@ -136,12 +140,17 @@ public: }; // class MyParcelable class MyUnion : public ::android::Parcelable { public: - enum Tag : int32_t { - iface = 0, // android.aidl.tests.ListOfInterfaces.IEmptyInterface iface; - nullable_iface, // android.aidl.tests.ListOfInterfaces.IEmptyInterface nullable_iface; - iface_list, // List<android.aidl.tests.ListOfInterfaces.IEmptyInterface> iface_list; - nullable_iface_list, // List<android.aidl.tests.ListOfInterfaces.IEmptyInterface> nullable_iface_list; + enum class Tag : int32_t { + iface = 0, + nullable_iface = 1, + iface_list = 2, + nullable_iface_list = 3, }; + // Expose tag symbols for legacy code + static const inline Tag iface = Tag::iface; + static const inline Tag nullable_iface = Tag::nullable_iface; + static const inline Tag iface_list = Tag::iface_list; + static const inline Tag nullable_iface_list = Tag::nullable_iface_list; template<typename _Tp> static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, MyUnion>; @@ -263,3 +272,37 @@ public: } // namespace tests } // namespace aidl } // namespace android +namespace android { +namespace aidl { +namespace tests { +[[nodiscard]] static inline std::string toString(ListOfInterfaces::MyUnion::Tag val) { + switch(val) { + case ListOfInterfaces::MyUnion::Tag::iface: + return "iface"; + case ListOfInterfaces::MyUnion::Tag::nullable_iface: + return "nullable_iface"; + case ListOfInterfaces::MyUnion::Tag::iface_list: + return "iface_list"; + case ListOfInterfaces::MyUnion::Tag::nullable_iface_list: + return "nullable_iface_list"; + default: + return std::to_string(static_cast<int32_t>(val)); + } +} +} // namespace tests +} // namespace aidl +} // namespace android +namespace android { +namespace internal { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++17-extensions" +template <> +constexpr inline std::array<::android::aidl::tests::ListOfInterfaces::MyUnion::Tag, 4> enum_values<::android::aidl::tests::ListOfInterfaces::MyUnion::Tag> = { + ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::iface, + ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::nullable_iface, + ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::iface_list, + ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::nullable_iface_list, +}; +#pragma clang diagnostic pop +} // namespace internal +} // namespace android diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h index 44284019..a82300f7 100644 --- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h +++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h @@ -2,6 +2,8 @@ #include <android/aidl/tests/ByteEnum.h> #include <android/binder_to_string.h> +#include <array> +#include <binder/Enums.h> #include <binder/IBinder.h> #include <binder/Parcel.h> #include <binder/Status.h> @@ -23,15 +25,23 @@ namespace aidl { namespace tests { class Union : public ::android::Parcelable { public: - enum Tag : int32_t { - ns = 0, // int[] ns; - n, // int n; - m, // int m; - s, // String s; - ibinder, // IBinder ibinder; - ss, // List<String> ss; - be, // android.aidl.tests.ByteEnum be; + enum class Tag : int32_t { + ns = 0, + n = 1, + m = 2, + s = 3, + ibinder = 4, + ss = 5, + be = 6, }; + // Expose tag symbols for legacy code + static const inline Tag ns = Tag::ns; + static const inline Tag n = Tag::n; + static const inline Tag m = Tag::m; + static const inline Tag s = Tag::s; + static const inline Tag ibinder = Tag::ibinder; + static const inline Tag ss = Tag::ss; + static const inline Tag be = Tag::be; template<typename _Tp> static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>; @@ -125,3 +135,46 @@ private: } // namespace tests } // namespace aidl } // namespace android +namespace android { +namespace aidl { +namespace tests { +[[nodiscard]] static inline std::string toString(Union::Tag val) { + switch(val) { + case Union::Tag::ns: + return "ns"; + case Union::Tag::n: + return "n"; + case Union::Tag::m: + return "m"; + case Union::Tag::s: + return "s"; + case Union::Tag::ibinder: + return "ibinder"; + case Union::Tag::ss: + return "ss"; + case Union::Tag::be: + return "be"; + default: + return std::to_string(static_cast<int32_t>(val)); + } +} +} // namespace tests +} // namespace aidl +} // namespace android +namespace android { +namespace internal { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++17-extensions" +template <> +constexpr inline std::array<::android::aidl::tests::Union::Tag, 7> enum_values<::android::aidl::tests::Union::Tag> = { + ::android::aidl::tests::Union::Tag::ns, + ::android::aidl::tests::Union::Tag::n, + ::android::aidl::tests::Union::Tag::m, + ::android::aidl::tests::Union::Tag::s, + ::android::aidl::tests::Union::Tag::ibinder, + ::android::aidl::tests::Union::Tag::ss, + ::android::aidl::tests::Union::Tag::be, +}; +#pragma clang diagnostic pop +} // namespace internal +} // namespace android diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h index 06ae2a60..c97edf1f 100644 --- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h +++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h @@ -1,11 +1,14 @@ #pragma once #include <android/binder_to_string.h> +#include <array> +#include <binder/Enums.h> #include <binder/Parcel.h> #include <binder/ParcelFileDescriptor.h> #include <binder/Status.h> #include <cassert> #include <cstdint> +#include <string> #include <type_traits> #include <utility> #include <utils/String16.h> @@ -20,10 +23,13 @@ namespace aidl { namespace tests { class UnionWithFd : public ::android::Parcelable { public: - enum Tag : int32_t { - num = 0, // int num; - pfd, // ParcelFileDescriptor pfd; + enum class Tag : int32_t { + num = 0, + pfd = 1, }; + // Expose tag symbols for legacy code + static const inline Tag num = Tag::num; + static const inline Tag pfd = Tag::pfd; template<typename _Tp> static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionWithFd>; @@ -111,3 +117,31 @@ private: } // namespace tests } // namespace aidl } // namespace android +namespace android { +namespace aidl { +namespace tests { +[[nodiscard]] static inline std::string toString(UnionWithFd::Tag val) { + switch(val) { + case UnionWithFd::Tag::num: + return "num"; + case UnionWithFd::Tag::pfd: + return "pfd"; + default: + return std::to_string(static_cast<int32_t>(val)); + } +} +} // namespace tests +} // namespace aidl +} // namespace android +namespace android { +namespace internal { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++17-extensions" +template <> +constexpr inline std::array<::android::aidl::tests::UnionWithFd::Tag, 2> enum_values<::android::aidl::tests::UnionWithFd::Tag> = { + ::android::aidl::tests::UnionWithFd::Tag::num, + ::android::aidl::tests::UnionWithFd::Tag::pfd, +}; +#pragma clang diagnostic pop +} // namespace internal +} // namespace android diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h index 3898fbcf..a65f9f0b 100644 --- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h +++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h @@ -3,9 +3,13 @@ #include <android/aidl/tests/IntEnum.h> #include <android/aidl/tests/LongEnum.h> #include <android/binder_to_string.h> +#include <array> +#include <binder/Enums.h> #include <binder/Parcel.h> #include <binder/Status.h> #include <cassert> +#include <cstdint> +#include <string> #include <type_traits> #include <utility> #include <utils/String16.h> @@ -21,10 +25,13 @@ namespace tests { namespace unions { class EnumUnion : public ::android::Parcelable { public: - enum Tag : int32_t { - intEnum = 0, // android.aidl.tests.IntEnum intEnum; - longEnum, // android.aidl.tests.LongEnum longEnum; + enum class Tag : int32_t { + intEnum = 0, + longEnum = 1, }; + // Expose tag symbols for legacy code + static const inline Tag intEnum = Tag::intEnum; + static const inline Tag longEnum = Tag::longEnum; template<typename _Tp> static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, EnumUnion>; @@ -113,3 +120,33 @@ private: } // namespace tests } // namespace aidl } // namespace android +namespace android { +namespace aidl { +namespace tests { +namespace unions { +[[nodiscard]] static inline std::string toString(EnumUnion::Tag val) { + switch(val) { + case EnumUnion::Tag::intEnum: + return "intEnum"; + case EnumUnion::Tag::longEnum: + return "longEnum"; + default: + return std::to_string(static_cast<int32_t>(val)); + } +} +} // namespace unions +} // namespace tests +} // namespace aidl +} // namespace android +namespace android { +namespace internal { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++17-extensions" +template <> +constexpr inline std::array<::android::aidl::tests::unions::EnumUnion::Tag, 2> enum_values<::android::aidl::tests::unions::EnumUnion::Tag> = { + ::android::aidl::tests::unions::EnumUnion::Tag::intEnum, + ::android::aidl::tests::unions::EnumUnion::Tag::longEnum, +}; +#pragma clang diagnostic pop +} // namespace internal +} // namespace android diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/UnionInUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/UnionInUnion.h index 9adbbe96..9badc3af 100644 --- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/UnionInUnion.h +++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/UnionInUnion.h @@ -2,10 +2,13 @@ #include <android/aidl/tests/unions/EnumUnion.h> #include <android/binder_to_string.h> +#include <array> +#include <binder/Enums.h> #include <binder/Parcel.h> #include <binder/Status.h> #include <cassert> #include <cstdint> +#include <string> #include <type_traits> #include <utility> #include <utils/String16.h> @@ -21,10 +24,13 @@ namespace tests { namespace unions { class UnionInUnion : public ::android::Parcelable { public: - enum Tag : int32_t { - first = 0, // android.aidl.tests.unions.EnumUnion first; - second, // int second; + enum class Tag : int32_t { + first = 0, + second = 1, }; + // Expose tag symbols for legacy code + static const inline Tag first = Tag::first; + static const inline Tag second = Tag::second; template<typename _Tp> static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionInUnion>; @@ -113,3 +119,33 @@ private: } // namespace tests } // namespace aidl } // namespace android +namespace android { +namespace aidl { +namespace tests { +namespace unions { +[[nodiscard]] static inline std::string toString(UnionInUnion::Tag val) { + switch(val) { + case UnionInUnion::Tag::first: + return "first"; + case UnionInUnion::Tag::second: + return "second"; + default: + return std::to_string(static_cast<int32_t>(val)); + } +} +} // namespace unions +} // namespace tests +} // namespace aidl +} // namespace android +namespace android { +namespace internal { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++17-extensions" +template <> +constexpr inline std::array<::android::aidl::tests::unions::UnionInUnion::Tag, 2> enum_values<::android::aidl::tests::unions::UnionInUnion::Tag> = { + ::android::aidl::tests::unions::UnionInUnion::Tag::first, + ::android::aidl::tests::unions::UnionInUnion::Tag::second, +}; +#pragma clang diagnostic pop +} // namespace internal +} // namespace android |