Remove static gAllReservedMethods from Interface.cpp
This was a global static that was used to determine all the methods in
IBase so that they could be added to all inheriting children. This
removes that global static and adds it as a member in AST.
Bison now calls into AST to add a method to an interface, which the AST
uses to store the reserved methods (similar to how gAllReservedMethods
did). The call to addAllReservedMethods also goes through AST which
finds all the reserved methods by checking all its importedAST (one of
which is guaranteed to have the methods).
Bug: N/A
Test: ./test/run_all_host_tests.sh && ./test/run_all_device_tests.sh
Change-Id: I47c592d724047c8e78e7b978b46837b39ffe4221
diff --git a/Interface.cpp b/Interface.cpp
index 55df082..b6d2f38 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -441,23 +441,9 @@
return true;
}
-static std::map<std::string, Method *> gAllReservedMethods;
-
-bool Interface::addMethod(Method *method) {
- if (isIBase()) {
- if (!gAllReservedMethods.emplace(method->name(), method).second) {
- std::cerr << "ERROR: hidl-gen encountered duplicated reserved method " << method->name()
- << std::endl;
- return false;
- }
- // will add it in addAllReservedMethods
- return true;
- }
-
+void Interface::addUserDefinedMethod(Method* method) {
CHECK(!method->isHidlReserved());
mUserMethods.push_back(method);
-
- return true;
}
std::vector<const Reference<Type>*> Interface::getReferences() const {
@@ -600,10 +586,10 @@
return OK;
}
-bool Interface::addAllReservedMethods() {
+bool Interface::addAllReservedMethods(const std::map<std::string, Method*>& allReservedMethods) {
// use a sorted map to insert them in serial ID order.
std::map<int32_t, Method *> reservedMethodsById;
- for (const auto &pair : gAllReservedMethods) {
+ for (const auto& pair : allReservedMethods) {
Method *method = pair.second->copySignature();
bool fillSuccess = fillPingMethod(method)
|| fillDescriptorChainMethod(method)