Support nullable types in Rust/NDK
In NDK/Rust, a few variants of nullable types were not supported.
- nullable parcelable/ParcelFileDescriptor
- nullable list or nullable array of parcelables/ParcelFileDescriptors
Bug: 175744740
Test: aidl_integration_test
Change-Id: I68c6551520fee5525d38688f52386c8092533d29
diff --git a/aidl_to_ndk.cpp b/aidl_to_ndk.cpp
index 4bf1c1f..b8e8d12 100644
--- a/aidl_to_ndk.cpp
+++ b/aidl_to_ndk.cpp
@@ -181,7 +181,12 @@
.read_func = StandardRead("::ndk::AParcel_readNullableParcelable"),
.write_func = StandardWrite("::ndk::AParcel_writeNullableParcelable"),
}),
- .nullable_array = nullptr,
+ .nullable_array = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
+ .cpp_name = "std::optional<std::vector<std::optional<" + clazz + ">>>",
+ .value_is_cheap = false,
+ .read_func = StandardRead("::ndk::AParcel_readVector"),
+ .write_func = StandardWrite("::ndk::AParcel_writeVector"),
+ }),
};
}
@@ -343,7 +348,12 @@
.read_func = StandardRead("::ndk::AParcel_readNullableParcelFileDescriptor"),
.write_func = StandardRead("::ndk::AParcel_writeNullableParcelFileDescriptor"),
}),
- .nullable_array = nullptr,
+ .nullable_array = std::shared_ptr<TypeInfo::Aspect>(new TypeInfo::Aspect{
+ .cpp_name = "std::optional<std::vector<::ndk::ScopedFileDescriptor>>",
+ .value_is_cheap = false,
+ .read_func = StandardRead("::ndk::AParcel_readVector"),
+ .write_func = StandardWrite("::ndk::AParcel_writeVector"),
+ }),
}},
{"ParcelableHolder",
TypeInfo{