From 01f93a9ef103e446dd7c90229cfc0c7af54cb855 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Thu, 29 Dec 2022 01:57:03 +0000 Subject: libbinder*: toString - support unique_ptr Exists for @nullable(heap=true) Bug: 259162245 Test: make AIDL RecursiveList when toString functions are a compilation requirement Change-Id: I5d589d7501423b850758126e541074047cb99b4c --- libs/binder/ndk/include_cpp/android/binder_to_string.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/binder/ndk/include_cpp/android/binder_to_string.h b/libs/binder/ndk/include_cpp/android/binder_to_string.h index 8d3231d985..27fdcdbc56 100644 --- a/libs/binder/ndk/include_cpp/android/binder_to_string.h +++ b/libs/binder/ndk/include_cpp/android/binder_to_string.h @@ -111,10 +111,12 @@ class IsPointerLike { IsInstantiationOf<_U, sp>::value || // for IBinder and interface types in the C++ // backend #endif - IsInstantiationOf<_U, std::optional>::value || // for @nullable types in the - // C++/NDK backends - IsInstantiationOf<_U, std::shared_ptr>::value, // for interface types in the - // NDK backends + IsInstantiationOf<_U, std::optional>::value || // for @nullable types in the + // C++/NDK backends + IsInstantiationOf<_U, std::unique_ptr>::value || // for @nullable(heap=true) + // in C++/NDK backends + IsInstantiationOf<_U, std::shared_ptr>::value, // for interface types in the + // NDK backends std::true_type> _test(int); -- cgit v1.2.3-59-g8ed1b From 8cf3e9ffbd3a5e51f86d68754cc020d5e6d9f676 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Sat, 5 Nov 2022 01:02:27 +0000 Subject: cpp binder: error if no toString implemented Now that they are all implemented. Bug: 259162245 Test: N/A Change-Id: Ibe63610f480a867641716e91ac85268a069361e5 --- libs/binder/ndk/include_cpp/android/binder_to_string.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/binder/ndk/include_cpp/android/binder_to_string.h b/libs/binder/ndk/include_cpp/android/binder_to_string.h index 27fdcdbc56..e3ead11475 100644 --- a/libs/binder/ndk/include_cpp/android/binder_to_string.h +++ b/libs/binder/ndk/include_cpp/android/binder_to_string.h @@ -166,6 +166,11 @@ class ToEmptyString { enum { value = decltype(_test<_T>(0))::value }; }; +template +struct TypeDependentFalse { + enum { value = false }; +}; + } // namespace details template @@ -225,7 +230,7 @@ std::string ToString(const _T& t) { out << "]"; return out.str(); } else { - return "{no toString() implemented}"; + static_assert(details::TypeDependentFalse<_T>::value, "no toString implemented, huh?"); } } -- cgit v1.2.3-59-g8ed1b