c++-impl: gen server stub boilerplate
-Lc++-impl now generates a default implementation for all
the interfaces in the specified package. The method
implementations are all left empty.
The default implementation also contains a special function,
HIDL_FETCH_IFOO(), which is used to retrieve an instance of
a particular interface in pass-through mode. For that to work,
the default implementation must live in a shared-library with
a well-known name, eg android.hardware.tests.foo@1.0.impl.so.
Sample invocation:
hidl-gen -o tmp/impl/ -Lc++-impl -randroid.hardware:hardware/interfaces
android.hardware.tests.foo@1.0
Bug: 31228745
Change-Id: I747aa47cb76931eed85179b8131d2efd3f887471
diff --git a/FQName.cpp b/FQName.cpp
index fcdaf20..bc47c46 100644
--- a/FQName.cpp
+++ b/FQName.cpp
@@ -193,6 +193,28 @@
return out;
}
+const FQName FQName::getTopLevelType() const {
+ auto idx = mName.find('.');
+
+ if (idx == std::string::npos) {
+ return *this;
+ }
+
+ return FQName(mPackage, mVersion, mName.substr(0, idx));
+}
+
+std::string FQName::tokenName() const {
+ std::vector<std::string> components;
+ getPackageAndVersionComponents(&components, true /* cpp_compatible */);
+
+ std::vector<std::string> nameComponents;
+ SplitString(mName, '.', &nameComponents);
+
+ components.insert(components.end(), nameComponents.begin(), nameComponents.end());
+
+ return JoinStrings(components, "_");
+}
+
std::string FQName::cppNamespace() const {
std::vector<std::string> components;
getPackageAndVersionComponents(&components, true /* cpp_compatible */);