libbinder_ndk: AParcel 'operator->' -> 'get'
Using 'operator->' directly is not very readable, and I'd rather not
have both. This is much cleaner.
Bug: 111445392
Test: ./ndk/runtests.sh
Change-Id: Ifcd828ee226225ddd298719e640f0d22bd9e5013
diff --git a/libs/binder/ndk/ibinder.cpp b/libs/binder/ndk/ibinder.cpp
index 23d84c2..b1b4194 100644
--- a/libs/binder/ndk/ibinder.cpp
+++ b/libs/binder/ndk/ibinder.cpp
@@ -426,7 +426,7 @@
}
*in = new AParcel(binder);
- status_t status = (**in)->writeInterfaceToken(clazz->getInterfaceDescriptor());
+ status_t status = (*in)->get()->writeInterfaceToken(clazz->getInterfaceDescriptor());
binder_status_t ret = PruneStatusT(status);
if (ret != STATUS_OK) {
@@ -472,8 +472,7 @@
*out = new AParcel(binder);
- status_t status =
- binder->getBinder()->transact(code, *(*in)->operator->(), (*out)->operator->(), flags);
+ status_t status = binder->getBinder()->transact(code, *(*in)->get(), (*out)->get(), flags);
binder_status_t ret = PruneStatusT(status);
if (ret != STATUS_OK) {
diff --git a/libs/binder/ndk/parcel.cpp b/libs/binder/ndk/parcel.cpp
index a896d10..e506847 100644
--- a/libs/binder/ndk/parcel.cpp
+++ b/libs/binder/ndk/parcel.cpp
@@ -38,11 +38,11 @@
binder_status_t AParcel_writeStrongBinder(AParcel* parcel, AIBinder* binder) {
sp<IBinder> writeBinder = binder != nullptr ? binder->getBinder() : nullptr;
- return (*parcel)->writeStrongBinder(writeBinder);
+ return parcel->get()->writeStrongBinder(writeBinder);
}
binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder) {
sp<IBinder> readBinder = nullptr;
- status_t status = (*parcel)->readStrongBinder(&readBinder);
+ status_t status = parcel->get()->readStrongBinder(&readBinder);
if (status != STATUS_OK) {
return PruneStatusT(status);
}
@@ -53,7 +53,7 @@
}
binder_status_t AParcel_readNullableStrongBinder(const AParcel* parcel, AIBinder** binder) {
sp<IBinder> readBinder = nullptr;
- status_t status = (*parcel)->readNullableStrongBinder(&readBinder);
+ status_t status = parcel->get()->readNullableStrongBinder(&readBinder);
if (status != STATUS_OK) {
return PruneStatusT(status);
}
@@ -67,92 +67,92 @@
// libbinder and this library.
// @START
binder_status_t AParcel_writeInt32(AParcel* parcel, int32_t value) {
- status_t status = (*parcel)->writeInt32(value);
+ status_t status = parcel->get()->writeInt32(value);
return PruneStatusT(status);
}
binder_status_t AParcel_writeUint32(AParcel* parcel, uint32_t value) {
- status_t status = (*parcel)->writeUint32(value);
+ status_t status = parcel->get()->writeUint32(value);
return PruneStatusT(status);
}
binder_status_t AParcel_writeInt64(AParcel* parcel, int64_t value) {
- status_t status = (*parcel)->writeInt64(value);
+ status_t status = parcel->get()->writeInt64(value);
return PruneStatusT(status);
}
binder_status_t AParcel_writeUint64(AParcel* parcel, uint64_t value) {
- status_t status = (*parcel)->writeUint64(value);
+ status_t status = parcel->get()->writeUint64(value);
return PruneStatusT(status);
}
binder_status_t AParcel_writeFloat(AParcel* parcel, float value) {
- status_t status = (*parcel)->writeFloat(value);
+ status_t status = parcel->get()->writeFloat(value);
return PruneStatusT(status);
}
binder_status_t AParcel_writeDouble(AParcel* parcel, double value) {
- status_t status = (*parcel)->writeDouble(value);
+ status_t status = parcel->get()->writeDouble(value);
return PruneStatusT(status);
}
binder_status_t AParcel_writeBool(AParcel* parcel, bool value) {
- status_t status = (*parcel)->writeBool(value);
+ status_t status = parcel->get()->writeBool(value);
return PruneStatusT(status);
}
binder_status_t AParcel_writeChar(AParcel* parcel, char16_t value) {
- status_t status = (*parcel)->writeChar(value);
+ status_t status = parcel->get()->writeChar(value);
return PruneStatusT(status);
}
binder_status_t AParcel_writeByte(AParcel* parcel, int8_t value) {
- status_t status = (*parcel)->writeByte(value);
+ status_t status = parcel->get()->writeByte(value);
return PruneStatusT(status);
}
binder_status_t AParcel_readInt32(const AParcel* parcel, int32_t* value) {
- status_t status = (*parcel)->readInt32(value);
+ status_t status = parcel->get()->readInt32(value);
return PruneStatusT(status);
}
binder_status_t AParcel_readUint32(const AParcel* parcel, uint32_t* value) {
- status_t status = (*parcel)->readUint32(value);
+ status_t status = parcel->get()->readUint32(value);
return PruneStatusT(status);
}
binder_status_t AParcel_readInt64(const AParcel* parcel, int64_t* value) {
- status_t status = (*parcel)->readInt64(value);
+ status_t status = parcel->get()->readInt64(value);
return PruneStatusT(status);
}
binder_status_t AParcel_readUint64(const AParcel* parcel, uint64_t* value) {
- status_t status = (*parcel)->readUint64(value);
+ status_t status = parcel->get()->readUint64(value);
return PruneStatusT(status);
}
binder_status_t AParcel_readFloat(const AParcel* parcel, float* value) {
- status_t status = (*parcel)->readFloat(value);
+ status_t status = parcel->get()->readFloat(value);
return PruneStatusT(status);
}
binder_status_t AParcel_readDouble(const AParcel* parcel, double* value) {
- status_t status = (*parcel)->readDouble(value);
+ status_t status = parcel->get()->readDouble(value);
return PruneStatusT(status);
}
binder_status_t AParcel_readBool(const AParcel* parcel, bool* value) {
- status_t status = (*parcel)->readBool(value);
+ status_t status = parcel->get()->readBool(value);
return PruneStatusT(status);
}
binder_status_t AParcel_readChar(const AParcel* parcel, char16_t* value) {
- status_t status = (*parcel)->readChar(value);
+ status_t status = parcel->get()->readChar(value);
return PruneStatusT(status);
}
binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) {
- status_t status = (*parcel)->readByte(value);
+ status_t status = parcel->get()->readByte(value);
return PruneStatusT(status);
}
diff --git a/libs/binder/ndk/parcel_internal.h b/libs/binder/ndk/parcel_internal.h
index b6a9110..d69971f 100644
--- a/libs/binder/ndk/parcel_internal.h
+++ b/libs/binder/ndk/parcel_internal.h
@@ -24,8 +24,8 @@
#include "ibinder_internal.h"
struct AParcel {
- const ::android::Parcel* operator->() const { return mParcel; }
- ::android::Parcel* operator->() { return mParcel; }
+ const ::android::Parcel* get() const { return mParcel; }
+ ::android::Parcel* get() { return mParcel; }
AParcel(const AIBinder* binder) : AParcel(binder, new ::android::Parcel, true /*owns*/) {}
AParcel(const AIBinder* binder, ::android::Parcel* parcel, bool owns)
diff --git a/libs/binder/ndk/scripts/gen_parcel_helper.py b/libs/binder/ndk/scripts/gen_parcel_helper.py
index c4c9ad4..85ee755 100755
--- a/libs/binder/ndk/scripts/gen_parcel_helper.py
+++ b/libs/binder/ndk/scripts/gen_parcel_helper.py
@@ -68,7 +68,7 @@
header += " */\n"
header += "binder_status_t AParcel_write" + pretty + "(AParcel* parcel, " + cpp + " value);\n\n"
source += "binder_status_t AParcel_write" + pretty + "(AParcel* parcel, " + cpp + " value) {\n"
- source += " status_t status = (*parcel)->write" + pretty + "(value);\n"
+ source += " status_t status = parcel->get()->write" + pretty + "(value);\n"
source += " return PruneStatusT(status);\n"
source += "}\n\n"
@@ -78,7 +78,7 @@
header += " */\n"
header += "binder_status_t AParcel_read" + pretty + "(const AParcel* parcel, " + cpp + "* value);\n\n"
source += "binder_status_t AParcel_read" + pretty + "(const AParcel* parcel, " + cpp + "* value) {\n"
- source += " status_t status = (*parcel)->read" + pretty + "(value);\n"
+ source += " status_t status = parcel->get()->read" + pretty + "(value);\n"
source += " return PruneStatusT(status);\n"
source += "}\n\n"