Support array of interface
Interfaces can be an array.
interface IFoo {}
IFoo[] getFooArray();
aidl_integration_test will be updated in a follow-up change.
Bug: 151817759
Test: gold_test.sh update
Test: aidl_integration_test / aidl_unittests
(this ensures the compiler generates compilable code & no regression)
Change-Id: Ice770f2b4e7feab2b8a900cb5fb4ad64cfa91231
diff --git a/aidl_to_ndk.cpp b/aidl_to_ndk.cpp
index b8e8d12..1fc4718 100644
--- a/aidl_to_ndk.cpp
+++ b/aidl_to_ndk.cpp
@@ -138,14 +138,24 @@
.read_func = StandardRead(clazz + "::readFromParcel"),
.write_func = StandardWrite(clazz + "::writeToParcel"),
},
- .array = nullptr,
+ .array = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
+ .cpp_name = "std::vector<std::shared_ptr<" + clazz + ">>",
+ .value_is_cheap = false,
+ .read_func = StandardRead("::ndk::AParcel_readVector"),
+ .write_func = StandardWrite("::ndk::AParcel_writeVector"),
+ }),
.nullable = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
.cpp_name = "std::shared_ptr<" + clazz + ">",
.value_is_cheap = false,
.read_func = StandardRead(clazz + "::readFromParcel"),
.write_func = StandardWrite(clazz + "::writeToParcel"),
}),
- .nullable_array = nullptr,
+ .nullable_array = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
+ .cpp_name = "std::optional<std::vector<std::shared_ptr<" + clazz + ">>>",
+ .value_is_cheap = false,
+ .read_func = StandardRead("::ndk::AParcel_readVector"),
+ .write_func = StandardWrite("::ndk::AParcel_writeVector"),
+ }),
};
}