Add getReferenceInfo to IBase.
Also added a IMPL_STUB_IMPL for HIDL reserved methods that:
* add a method with the same name and signature
to BnHwFoo
* BnHwFoo::onTransact will call BnHwFoo::method instead of
_hidl_mImpl->method
* Content of IMPL_STUB_IMPL will go to BnHwFoo::method.
Test: make and tested NFC / light / audio
Test: hidl_test
Change-Id: I85f6314450178c02c7bcba91c8a9fffbce822c76
diff --git a/generateCpp.cpp b/generateCpp.cpp
index f40d9d4..9a51ff9 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -813,6 +813,31 @@
out.unindent();
out << "private:\n";
out.indent();
+
+ status_t err = generateMethods(out, [&](const Method *method, const Interface *iface) {
+ if (!method->isHidlReserved() || !method->overridesCppImpl(IMPL_STUB_IMPL)) {
+ return OK;
+ }
+ const bool returnsValue = !method->results().empty();
+ const TypedVar *elidedReturn = method->canElideCallback();
+
+ if (elidedReturn == nullptr && returnsValue) {
+ out << "using " << method->name() << "_cb = "
+ << iface->fqName().cppName()
+ << "::" << method->name() << "_cb;\n";
+ }
+ method->generateCppSignature(out);
+ out << " ";
+ out.block([&] {
+ method->cppImpl(IMPL_STUB_IMPL, out);
+ out << "\n";
+ }).endl();
+ return OK;
+ });
+ if (err != OK) {
+ return err;
+ }
+
out << "::android::sp<" << ifaceName << "> _hidl_mImpl;\n";
out.unindent();
out << "};\n\n";
@@ -1536,13 +1561,16 @@
const bool returnsValue = !method->results().empty();
const TypedVar *elidedReturn = method->canElideCallback();
+ const std::string callee =
+ (method->isHidlReserved() && method->overridesCppImpl(IMPL_STUB_IMPL))
+ ? "this" : "_hidl_mImpl";
if (elidedReturn != nullptr) {
out << elidedReturn->type().getCppResultType()
<< " _hidl_out_"
<< elidedReturn->name()
<< " = "
- << "_hidl_mImpl->" << method->name()
+ << callee << "->" << method->name()
<< "(";
bool first = true;
@@ -1595,7 +1623,7 @@
out << "bool _hidl_callbackCalled = false;\n\n";
}
- out << "_hidl_mImpl->" << method->name() << "(";
+ out << callee << "->" << method->name() << "(";
bool first = true;
for (const auto &arg : method->args()) {