Method.h revision 40d474a15ea87fb80b7344fba7602fbb2da2a449
1#ifndef METHOD_H_ 2 3#define METHOD_H_ 4 5#include <android-base/macros.h> 6#include <string> 7#include <utils/KeyedVector.h> 8#include <vector> 9 10namespace android { 11 12struct Annotation; 13struct Formatter; 14struct ScalarType; 15struct Type; 16struct TypedVar; 17 18using AnnotationVector = 19 DefaultKeyedVector<std::string, Annotation *>; 20 21struct Method { 22 Method(const char *name, 23 std::vector<TypedVar *> *args, 24 std::vector<TypedVar *> *results, 25 bool oneway, 26 AnnotationVector *annotations); 27 28 std::string name() const; 29 const std::vector<TypedVar *> &args() const; 30 const std::vector<TypedVar *> &results() const; 31 bool isOneway() const { return mOneway; } 32 const AnnotationVector &annotations() const; 33 34 static std::string GetSignature(const std::vector<TypedVar *> &args); 35 static std::string GetJavaSignature(const std::vector<TypedVar *> &args); 36 37 const TypedVar* canElideCallback() const; 38 39 void dumpAnnotations(Formatter &out) const; 40 41 bool isJavaCompatible() const; 42 43private: 44 std::string mName; 45 std::vector<TypedVar *> *mArgs; 46 std::vector<TypedVar *> *mResults; 47 bool mOneway; 48 AnnotationVector *mAnnotationsByName; 49 50 DISALLOW_COPY_AND_ASSIGN(Method); 51}; 52 53struct TypedVar { 54 TypedVar(const char *name, Type *type); 55 56 std::string name() const; 57 const Type &type() const; 58 59 bool isJavaCompatible() const; 60 61private: 62 std::string mName; 63 Type *mType; 64 65 DISALLOW_COPY_AND_ASSIGN(TypedVar); 66}; 67 68} // namespace android 69 70#endif // METHOD_H_ 71 72