IHidlInterfaceBase for all autogenerated interfaces.
Add an interfaceChain() method to each interface
to facilitate casting between interfaces.
Add ::descriptor for each interface (so that
IFoo::descriptor won't fall back to
IHidlInterfaceBase::descriptor.
Test: hidl_test
Test: cd system/tools/hidl && mma
Test: cd hardware/interfaces/test && mma
Bug: 32337854
Change-Id: I317b7905750db0bfefc4c5fd608a07080923c719
diff --git a/Interface.h b/Interface.h
index 7f7edc7..ae7e032 100644
--- a/Interface.h
+++ b/Interface.h
@@ -19,10 +19,12 @@
#define INTERFACE_H_
#include "Scope.h"
+#include <vector>
namespace android {
struct Method;
+struct InterfaceAndMethod;
struct Interface : public Scope {
Interface(const char *localName, Interface *super);
@@ -34,8 +36,26 @@
const Interface *superType() const;
- const std::vector<Method *> &methods() const;
Method *lookupMethod(std::string name) const;
+ // Super type chain to root type, including myself.
+ // First element is this.
+ std::vector<const Interface *> typeChain() const;
+
+ // user defined methods (explicit definition in HAL files)
+ const std::vector<Method *> &userDefinedMethods() const;
+ // HIDL reserved methods (every interface has these implicitly defined)
+ const std::vector<Method *> &hidlReservedMethods() const;
+ // the sum of userDefinedMethods() and hidlReservedMethods().
+ std::vector<Method *> methods() const;
+
+ // userDefinedMethods() for all super type + methods()
+ // The order will be as follows (in the transaction code order):
+ // great-great-...-great-grand parent->userDefinedMethods()
+ // ...
+ // parent->userDefinedMethods()
+ // this->userDefinedMethods()
+ // this->hidlReservedMethods()
+ std::vector<InterfaceAndMethod> allMethodsFromRoot() const;
std::string getBaseName() const;
@@ -72,12 +92,27 @@
private:
Interface *mSuperType;
- std::vector<Method *> mMethods;
+ std::vector<Method *> mUserMethods;
+ std::vector<Method *> mReservedMethods;
mutable bool mIsJavaCompatibleInProgress;
+ Method *createDescriptorChainMethod() const;
DISALLOW_COPY_AND_ASSIGN(Interface);
};
+// An interface / method tuple.
+struct InterfaceAndMethod {
+ InterfaceAndMethod(const Interface *iface, Method *method)
+ : mInterface(iface),
+ mMethod(method) {}
+ Method *method() const { return mMethod; }
+ const Interface *interface() const { return mInterface; }
+private:
+ // do not own these objects.
+ const Interface *mInterface;
+ Method *mMethod;
+};
+
} // namespace android
#endif // INTERFACE_H_