blob: c0bfc6cde7a520444e63e61ea9bd1c780b5bc871 [file] [log] [blame]
Andreas Huberc9410c72016-07-28 12:18:40 -07001#ifndef METHOD_H_
2
3#define METHOD_H_
4
5#include <android-base/macros.h>
6#include <string>
Andreas Huber3599d922016-08-09 10:42:57 -07007#include <utils/KeyedVector.h>
Andreas Huber881227d2016-08-02 14:20:21 -07008#include <vector>
Andreas Huberc9410c72016-07-28 12:18:40 -07009
10namespace android {
11
Andreas Huber3599d922016-08-09 10:42:57 -070012struct Annotation;
Andreas Huberc9410c72016-07-28 12:18:40 -070013struct Formatter;
14struct Type;
Andreas Huber31629bc2016-08-03 09:06:40 -070015struct TypedVar;
Andreas Huberc9410c72016-07-28 12:18:40 -070016
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070017using AnnotationVector =
18 DefaultKeyedVector<std::string, Annotation *>;
19
Andreas Huberc9410c72016-07-28 12:18:40 -070020struct Method {
21 Method(const char *name,
Andreas Huber881227d2016-08-02 14:20:21 -070022 std::vector<TypedVar *> *args,
Andreas Huber3599d922016-08-09 10:42:57 -070023 std::vector<TypedVar *> *results,
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070024 AnnotationVector *annotations);
Andreas Huberc9410c72016-07-28 12:18:40 -070025
Andreas Huber881227d2016-08-02 14:20:21 -070026 std::string name() const;
27 const std::vector<TypedVar *> &args() const;
28 const std::vector<TypedVar *> &results() const;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070029 const AnnotationVector &annotations() const;
Andreas Huber881227d2016-08-02 14:20:21 -070030
31 static std::string GetSignature(const std::vector<TypedVar *> &args);
Andreas Huber2831d512016-08-15 09:33:47 -070032 static std::string GetJavaSignature(const std::vector<TypedVar *> &args);
Andreas Huber881227d2016-08-02 14:20:21 -070033
Andreas Huber3599d922016-08-09 10:42:57 -070034 void dumpAnnotations(Formatter &out) const;
35
Andreas Huberc9410c72016-07-28 12:18:40 -070036private:
37 std::string mName;
Andreas Huber881227d2016-08-02 14:20:21 -070038 std::vector<TypedVar *> *mArgs;
39 std::vector<TypedVar *> *mResults;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070040 AnnotationVector *mAnnotationsByName;
Andreas Huberc9410c72016-07-28 12:18:40 -070041
42 DISALLOW_COPY_AND_ASSIGN(Method);
43};
44
Andreas Huber31629bc2016-08-03 09:06:40 -070045struct TypedVar {
46 TypedVar(const char *name, Type *type);
47
48 std::string name() const;
49 const Type &type() const;
50
51private:
52 std::string mName;
53 Type *mType;
54
55 DISALLOW_COPY_AND_ASSIGN(TypedVar);
56};
57
Andreas Huberc9410c72016-07-28 12:18:40 -070058} // namespace android
59
60#endif // METHOD_H_
61