hidl-gen: enumerate interface methods in Bn classes

Bn${interface} classes inherit from I${interface} as as from IBinder
(via BBinder).  Make this explicit in auto-generated code by enumerating
the methods from I${interface} as pure virtual ones.  This is a no-op
change--it's just for clarity.

Change-Id: Idc01757c92613a9b0461bb57ed269348fab4a40a
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/generateCpp.cpp b/generateCpp.cpp
index f61659a..b034c87 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -288,6 +288,58 @@
     return mRootScope->emitTypeDeclarations(out);
 }
 
+status_t AST::generateHeaderMethodSignatures(
+        Formatter &out, bool abstract) const {
+    const Interface *iface = mRootScope->getInterface();
+
+    std::vector<const Interface *> chain;
+    while (iface != NULL) {
+        chain.push_back(iface);
+        iface = iface->superType();
+    }
+
+    for (auto it = chain.rbegin(); it != chain.rend(); ++it) {
+        const Interface *superInterface = *it;
+
+        out << "// Methods from "
+            << superInterface->fullName()
+            << " follow.\n";
+
+        for (const auto &method : superInterface->methods()) {
+            const bool returnsValue = !method->results().empty();
+
+            const TypedVar *elidedReturn = method->canElideCallback();
+
+            if (elidedReturn == nullptr) {
+                out << "::android::hardware::Status ";
+            } else {
+                std::string extra;
+                out << "::android::hardware::SimpleReturn<";
+                out << elidedReturn->type().getCppResultType(&extra) << "> ";
+            }
+            out << method->name()
+                << "("
+                << Method::GetSignature(method->args());
+
+            if (returnsValue && elidedReturn == nullptr) {
+                if (!method->args().empty()) {
+                    out << ", ";
+                }
+
+                out << method->name() << "_cb _hidl_cb";
+            }
+
+            out << ") ";
+            out << (abstract ? "= 0" : "override");
+            out << ";\n";
+        }
+
+        out << "\n";
+    }
+
+    return OK;
+}
+
 status_t AST::generateStubHeader(const std::string &outputPath) const {
     std::string ifaceName;
     if (!AST::isInterface(&ifaceName)) {
@@ -348,10 +400,12 @@
     out << "const ::android::hardware::Parcel &_hidl_data,\n";
     out << "::android::hardware::Parcel *_hidl_reply,\n";
     out << "uint32_t _hidl_flags = 0,\n";
-    out << "TransactCallback _hidl_cb = nullptr) override;\n";
+    out << "TransactCallback _hidl_cb = nullptr) override;\n\n";
     out.unindent();
     out.unindent();
 
+    generateHeaderMethodSignatures(out, true); // = 0
+
     out.unindent();
 
     out << "};\n\n";
@@ -421,50 +475,7 @@
         << "(const ::android::sp<::android::hardware::IBinder> &_hidl_impl);"
         << "\n\n";
 
-    const Interface *iface = mRootScope->getInterface();
-
-    std::vector<const Interface *> chain;
-    while (iface != NULL) {
-        chain.push_back(iface);
-        iface = iface->superType();
-    }
-
-    for (auto it = chain.rbegin(); it != chain.rend(); ++it) {
-        const Interface *superInterface = *it;
-
-        out << "// Methods from "
-            << superInterface->fullName()
-            << " follow.\n";
-
-        for (const auto &method : superInterface->methods()) {
-            const bool returnsValue = !method->results().empty();
-
-            const TypedVar *elidedReturn = method->canElideCallback();
-
-            if (elidedReturn == nullptr) {
-                out << "::android::hardware::Status ";
-            } else {
-                std::string extra;
-                out << "::android::hardware::SimpleReturn<";
-                out << elidedReturn->type().getCppResultType(&extra) << "> ";
-            }
-            out << method->name()
-                << "("
-                << Method::GetSignature(method->args());
-
-            if (returnsValue && elidedReturn == nullptr) {
-                if (!method->args().empty()) {
-                    out << ", ";
-                }
-
-                out << method->name() << "_cb _hidl_cb";
-            }
-
-            out << ") override;\n";
-        }
-
-        out << "\n";
-    }
+    generateHeaderMethodSignatures(out, false); // override
 
     out.unindent();