Emit "deprecated"
We've supported /** @deprecated note */ but it's passed to only the Java
backend as it is (as comments).
Now the deprecation is emitted properly according to the backend types.
- Java: @Deprecated + /** @deprecated note */
- C++/NDK: __attribute__((deprecated(note))
- Rust: #[deprecated = note]
For now, "note" is only available for the Java backend. Supporting
deprecation notes will be followed.
Bug: 174514415
Test: aidl_unittests / aidl_integration_test
Change-Id: Iefb216585d884b3195719c82748e573bb08922ab
Merged-In: Iefb216585d884b3195719c82748e573bb08922ab
Ignore-AOSP-First: topic with internal-only project
(packages/services/Car)
(cherry picked from commit ea571f8f53f30c08bc1b9a4ea02cb473522cbc9b)
diff --git a/aidl_to_cpp_common.cpp b/aidl_to_cpp_common.cpp
index 31b44ba..aa4bb1e 100644
--- a/aidl_to_cpp_common.cpp
+++ b/aidl_to_cpp_common.cpp
@@ -306,8 +306,9 @@
code << "#pragma clang diagnostic push\n";
code << "#pragma clang diagnostic ignored \"-Wc++17-extensions\"\n";
code << "template <>\n";
- code << "constexpr inline std::array<" << fq_name << ", " << size << "> enum_values<" << fq_name
- << "> = {\n";
+ code << "constexpr inline std::array<" << fq_name << ", " << size << ">";
+ GenerateDeprecated(code, enum_decl);
+ code << " enum_values<" << fq_name << "> = {\n";
for (const auto& enumerator : enum_decl.GetEnumerators()) {
code << " " << fq_name << "::" << enumerator->GetName() << ",\n";
}
@@ -444,7 +445,10 @@
out << "enum Tag : " << name_of(tag_type, typenames) << " {\n";
bool is_first = true;
for (const auto& f : decl.GetFields()) {
- out << " " << f->GetName() << (is_first ? " = 0" : "") << ", // " << f->Signature() << ";\n";
+ out << " " << f->GetName();
+ GenerateDeprecated(out, *f);
+ if (is_first) out << " = 0";
+ out << ", // " << f->Signature() << ";\n";
is_first = false;
}
out << "};\n";