Support IBinder array in the NDK/Rust backends.
IBinder[] in AIDL is mapped to
- vector<SpAIBinder> in NDK
- Vec<SpIBinder>, [&SpIBinder], Vec<Option<SpIBinder>> in Rust (according to the
position)
@nullable IBinder[] in AIDL is mapped to
- optional<vector<optional<SpAIBinder>>> in NDK
- Option<Vec<Option<SpIBinder>>>, Option<&[Option<SpIBinder>]> in Rust
Bug: 151817759
Test: aidl_integration_test, aidl_unittests, golden_test.sh check
Change-Id: I34d0afe9621a95ac9a06487915ee933cccb3d5ed
diff --git a/aidl_to_ndk.cpp b/aidl_to_ndk.cpp
index 49766e0..f4557d7 100644
--- a/aidl_to_ndk.cpp
+++ b/aidl_to_ndk.cpp
@@ -303,14 +303,24 @@
.read_func = StandardRead("::ndk::AParcel_readRequiredStrongBinder"),
.write_func = StandardRead("::ndk::AParcel_writeRequiredStrongBinder"),
},
- .array = nullptr,
+ .array = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
+ .cpp_name = "std::vector<::ndk::SpAIBinder>",
+ .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 = "::ndk::SpAIBinder",
.value_is_cheap = false,
.read_func = StandardRead("::ndk::AParcel_readNullableStrongBinder"),
.write_func = StandardRead("::ndk::AParcel_writeNullableStrongBinder"),
}),
- .nullable_array = nullptr,
+ .nullable_array = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
+ .cpp_name = "std::optional<std::vector<::ndk::SpAIBinder>>",
+ .value_is_cheap = false,
+ .read_func = StandardRead("::ndk::AParcel_readVector"),
+ .write_func = StandardWrite("::ndk::AParcel_writeVector"),
+ }),
}},
{"ParcelFileDescriptor",
TypeInfo{