Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 1 | #ifndef METHOD_H_ |
| 2 | |
| 3 | #define METHOD_H_ |
| 4 | |
| 5 | #include <android-base/macros.h> |
| 6 | #include <string> |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 7 | #include <utils/KeyedVector.h> |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 8 | #include <vector> |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 9 | |
| 10 | namespace android { |
| 11 | |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 12 | struct Annotation; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 13 | struct Formatter; |
| 14 | struct Type; |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 15 | struct TypedVar; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 16 | |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame^] | 17 | using AnnotationVector = |
| 18 | DefaultKeyedVector<std::string, Annotation *>; |
| 19 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 20 | struct Method { |
| 21 | Method(const char *name, |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 22 | std::vector<TypedVar *> *args, |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 23 | std::vector<TypedVar *> *results, |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame^] | 24 | AnnotationVector *annotations); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 25 | |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 26 | std::string name() const; |
| 27 | const std::vector<TypedVar *> &args() const; |
| 28 | const std::vector<TypedVar *> &results() const; |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame^] | 29 | const AnnotationVector &annotations() const; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 30 | |
| 31 | static std::string GetSignature(const std::vector<TypedVar *> &args); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 32 | static std::string GetJavaSignature(const std::vector<TypedVar *> &args); |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 33 | |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 34 | void dumpAnnotations(Formatter &out) const; |
| 35 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 36 | private: |
| 37 | std::string mName; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 38 | std::vector<TypedVar *> *mArgs; |
| 39 | std::vector<TypedVar *> *mResults; |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame^] | 40 | AnnotationVector *mAnnotationsByName; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 41 | |
| 42 | DISALLOW_COPY_AND_ASSIGN(Method); |
| 43 | }; |
| 44 | |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 45 | struct TypedVar { |
| 46 | TypedVar(const char *name, Type *type); |
| 47 | |
| 48 | std::string name() const; |
| 49 | const Type &type() const; |
| 50 | |
| 51 | private: |
| 52 | std::string mName; |
| 53 | Type *mType; |
| 54 | |
| 55 | DISALLOW_COPY_AND_ASSIGN(TypedVar); |
| 56 | }; |
| 57 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 58 | } // namespace android |
| 59 | |
| 60 | #endif // METHOD_H_ |
| 61 | |