summaryrefslogtreecommitdiff
path: root/libs/binder/Parcel.cpp
diff options
context:
space:
mode:
author Casey Dahlin <sadmac@google.com> 2015-10-15 15:44:59 -0700
committer Casey Dahlin <sadmac@google.com> 2015-10-15 17:55:17 -0700
commitd6848f52e60be17b7f0992be7827dcae4ea2efb1 (patch)
treec4495d00efb81a7ea99861e036f0eb24b6400ffb /libs/binder/Parcel.cpp
parent8e0c88ea489a7b395a3d349f81000fb2639bf448 (diff)
Add methods to Parcel for bool and char and byte
We lift these to int, but handling the details of that here will be better than having AIDL generate casting code all the time. Test: unit tests pass Bug: 24981507 Change-Id: If6aa33ab5fe365dd237136a95c5d9a702af41d15 Signed-off-by: Casey Dahlin <sadmac@google.com>
Diffstat (limited to 'libs/binder/Parcel.cpp')
-rw-r--r--libs/binder/Parcel.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 45191f5bd9..95385db9d9 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -760,6 +760,21 @@ status_t Parcel::writeByteArray(size_t len, const uint8_t *val) {
return ret;
}
+status_t Parcel::writeBool(bool val)
+{
+ return writeInt32(int32_t(val));
+}
+
+status_t Parcel::writeChar(char16_t val)
+{
+ return writeInt32(int32_t(val));
+}
+
+status_t Parcel::writeByte(int8_t val)
+{
+ return writeInt32(int32_t(val));
+}
+
status_t Parcel::writeInt64(int64_t val)
{
return writeAligned(val);
@@ -1252,6 +1267,44 @@ intptr_t Parcel::readIntPtr() const
return readAligned<intptr_t>();
}
+status_t Parcel::readBool(bool *pArg) const
+{
+ int32_t tmp;
+ status_t ret = readInt32(&tmp);
+ *pArg = (tmp != 0);
+ return ret;
+}
+
+bool Parcel::readBool() const
+{
+ return readInt32() != 0;
+}
+
+status_t Parcel::readChar(char16_t *pArg) const
+{
+ int32_t tmp;
+ status_t ret = readInt32(&tmp);
+ *pArg = char16_t(tmp);
+ return ret;
+}
+
+char16_t Parcel::readChar() const
+{
+ return char16_t(readInt32());
+}
+
+status_t Parcel::readByte(int8_t *pArg) const
+{
+ int32_t tmp;
+ status_t ret = readInt32(&tmp);
+ *pArg = int8_t(tmp);
+ return ret;
+}
+
+int8_t Parcel::readByte() const
+{
+ return int8_t(readInt32());
+}
const char* Parcel::readCString() const
{