Loading libs/binder/include/binder/IInterface.h +44 −42 Original line number Diff line number Diff line Loading @@ -129,48 +129,50 @@ public: \ #endif #define DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(INTERFACE, NAME)\ const ::android::StaticString16 \ I##INTERFACE##_descriptor_static_str16(__IINTF_CONCAT(u, NAME));\ const ::android::String16 I##INTERFACE::descriptor( \ I##INTERFACE##_descriptor_static_str16); \ const ::android::String16& \ I##INTERFACE::getInterfaceDescriptor() const { \ return I##INTERFACE::descriptor; \ } \ ::android::sp<I##INTERFACE> I##INTERFACE::asInterface( \ const ::android::sp<::android::IBinder>& obj) \ { \ ::android::sp<I##INTERFACE> intr; \ // Macro to be used by both IMPLEMENT_META_INTERFACE and IMPLEMENT_META_NESTED_INTERFACE #define DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE0(ITYPE, INAME, BPTYPE) \ const ::android::String16& ITYPE::getInterfaceDescriptor() const { return ITYPE::descriptor; } \ ::android::sp<ITYPE> ITYPE::asInterface(const ::android::sp<::android::IBinder>& obj) { \ ::android::sp<ITYPE> intr; \ if (obj != nullptr) { \ intr = ::android::sp<I##INTERFACE>::cast( \ obj->queryLocalInterface(I##INTERFACE::descriptor)); \ intr = ::android::sp<ITYPE>::cast(obj->queryLocalInterface(ITYPE::descriptor)); \ if (intr == nullptr) { \ intr = ::android::sp<Bp##INTERFACE>::make(obj); \ intr = ::android::sp<BPTYPE>::make(obj); \ } \ } \ return intr; \ } \ std::unique_ptr<I##INTERFACE> I##INTERFACE::default_impl; \ bool I##INTERFACE::setDefaultImpl(std::unique_ptr<I##INTERFACE> impl)\ { \ std::unique_ptr<ITYPE> ITYPE::default_impl; \ bool ITYPE::setDefaultImpl(std::unique_ptr<ITYPE> impl) { \ /* Only one user of this interface can use this function */ \ /* at a time. This is a heuristic to detect if two different */ \ /* users in the same process use this function. */ \ assert(!I##INTERFACE::default_impl); \ assert(!ITYPE::default_impl); \ if (impl) { \ I##INTERFACE::default_impl = std::move(impl); \ ITYPE::default_impl = std::move(impl); \ return true; \ } \ return false; \ } \ const std::unique_ptr<I##INTERFACE>& I##INTERFACE::getDefaultImpl() \ { \ return I##INTERFACE::default_impl; \ } \ I##INTERFACE::I##INTERFACE() { } \ I##INTERFACE::~I##INTERFACE() { } \ const std::unique_ptr<ITYPE>& ITYPE::getDefaultImpl() { return ITYPE::default_impl; } \ ITYPE::INAME() {} \ ITYPE::~INAME() {} // Macro for an interface type. #define DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \ const ::android::StaticString16 I##INTERFACE##_descriptor_static_str16( \ __IINTF_CONCAT(u, NAME)); \ const ::android::String16 I##INTERFACE::descriptor(I##INTERFACE##_descriptor_static_str16); \ DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE0(I##INTERFACE, I##INTERFACE, Bp##INTERFACE) // Macro for "nested" interface type. // For example, // class Parent .. { class INested .. { }; }; // DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_NESTED_INTERFACE(Parent, Nested, "Parent.INested") #define DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_NESTED_INTERFACE(PARENT, INTERFACE, NAME) \ const ::android::String16 PARENT::I##INTERFACE::descriptor(NAME); \ DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE0(PARENT::I##INTERFACE, I##INTERFACE, \ PARENT::Bp##INTERFACE) #define CHECK_INTERFACE(interface, data, reply) \ do { \ Loading Loading
libs/binder/include/binder/IInterface.h +44 −42 Original line number Diff line number Diff line Loading @@ -129,48 +129,50 @@ public: \ #endif #define DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(INTERFACE, NAME)\ const ::android::StaticString16 \ I##INTERFACE##_descriptor_static_str16(__IINTF_CONCAT(u, NAME));\ const ::android::String16 I##INTERFACE::descriptor( \ I##INTERFACE##_descriptor_static_str16); \ const ::android::String16& \ I##INTERFACE::getInterfaceDescriptor() const { \ return I##INTERFACE::descriptor; \ } \ ::android::sp<I##INTERFACE> I##INTERFACE::asInterface( \ const ::android::sp<::android::IBinder>& obj) \ { \ ::android::sp<I##INTERFACE> intr; \ // Macro to be used by both IMPLEMENT_META_INTERFACE and IMPLEMENT_META_NESTED_INTERFACE #define DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE0(ITYPE, INAME, BPTYPE) \ const ::android::String16& ITYPE::getInterfaceDescriptor() const { return ITYPE::descriptor; } \ ::android::sp<ITYPE> ITYPE::asInterface(const ::android::sp<::android::IBinder>& obj) { \ ::android::sp<ITYPE> intr; \ if (obj != nullptr) { \ intr = ::android::sp<I##INTERFACE>::cast( \ obj->queryLocalInterface(I##INTERFACE::descriptor)); \ intr = ::android::sp<ITYPE>::cast(obj->queryLocalInterface(ITYPE::descriptor)); \ if (intr == nullptr) { \ intr = ::android::sp<Bp##INTERFACE>::make(obj); \ intr = ::android::sp<BPTYPE>::make(obj); \ } \ } \ return intr; \ } \ std::unique_ptr<I##INTERFACE> I##INTERFACE::default_impl; \ bool I##INTERFACE::setDefaultImpl(std::unique_ptr<I##INTERFACE> impl)\ { \ std::unique_ptr<ITYPE> ITYPE::default_impl; \ bool ITYPE::setDefaultImpl(std::unique_ptr<ITYPE> impl) { \ /* Only one user of this interface can use this function */ \ /* at a time. This is a heuristic to detect if two different */ \ /* users in the same process use this function. */ \ assert(!I##INTERFACE::default_impl); \ assert(!ITYPE::default_impl); \ if (impl) { \ I##INTERFACE::default_impl = std::move(impl); \ ITYPE::default_impl = std::move(impl); \ return true; \ } \ return false; \ } \ const std::unique_ptr<I##INTERFACE>& I##INTERFACE::getDefaultImpl() \ { \ return I##INTERFACE::default_impl; \ } \ I##INTERFACE::I##INTERFACE() { } \ I##INTERFACE::~I##INTERFACE() { } \ const std::unique_ptr<ITYPE>& ITYPE::getDefaultImpl() { return ITYPE::default_impl; } \ ITYPE::INAME() {} \ ITYPE::~INAME() {} // Macro for an interface type. #define DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \ const ::android::StaticString16 I##INTERFACE##_descriptor_static_str16( \ __IINTF_CONCAT(u, NAME)); \ const ::android::String16 I##INTERFACE::descriptor(I##INTERFACE##_descriptor_static_str16); \ DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE0(I##INTERFACE, I##INTERFACE, Bp##INTERFACE) // Macro for "nested" interface type. // For example, // class Parent .. { class INested .. { }; }; // DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_NESTED_INTERFACE(Parent, Nested, "Parent.INested") #define DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_NESTED_INTERFACE(PARENT, INTERFACE, NAME) \ const ::android::String16 PARENT::I##INTERFACE::descriptor(NAME); \ DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE0(PARENT::I##INTERFACE, I##INTERFACE, \ PARENT::Bp##INTERFACE) #define CHECK_INTERFACE(interface, data, reply) \ do { \ Loading