Generate java method signatures in common code
generateJavaImpl and generateJava both need to generate method
signatures. This makes it so that they can call a method on "Method"
instead of having to add all the logic themselves.
Fixes: 132654975
Test: ./test/run_all_host_tests.sh && ./test/run_all_device_tests.sh
Change-Id: I60ef33da5658139a5f40d71d5e6f6c6a2bbdbee0
diff --git a/generateJava.cpp b/generateJava.cpp
index 1fe0634..577caf9 100644
--- a/generateJava.cpp
+++ b/generateJava.cpp
@@ -238,7 +238,6 @@
iface->emitJavaTypeDeclarations(out, false /* atTopLevel */);
for (const auto &method : iface->methods()) {
- const bool returnsValue = !method->results().empty();
const bool needsCallback = method->results().size() > 1;
if (needsCallback) {
@@ -257,27 +256,9 @@
method->emitDocComment(out);
- if (returnsValue && !needsCallback) {
- out << method->results()[0]->type().getJavaType();
- } else {
- out << "void";
- }
+ method->emitJavaSignature(out);
- out << " "
- << method->name()
- << "(";
- method->emitJavaArgSignature(out);
-
- if (needsCallback) {
- if (!method->args().empty()) {
- out << ", ";
- }
-
- out << method->name()
- << "Callback _hidl_cb";
- }
-
- out << ")\n";
+ out << "\n";
out.indent();
out << "throws android.os.RemoteException;\n";
out.unindent();
@@ -341,27 +322,9 @@
const bool needsCallback = method->results().size() > 1;
out << "@Override\npublic ";
- if (returnsValue && !needsCallback) {
- out << method->results()[0]->type().getJavaType();
- } else {
- out << "void";
- }
+ method->emitJavaSignature(out);
- out << " "
- << method->name()
- << "(";
- method->emitJavaArgSignature(out);
-
- if (needsCallback) {
- if (!method->args().empty()) {
- out << ", ";
- }
-
- out << method->name()
- << "Callback _hidl_cb";
- }
-
- out << ")\n";
+ out << "\n";
out.indent();
out.indent();
out << "throws android.os.RemoteException {\n";