blob: e449542f3a65363e0833404134bd9150b7afb4f4 [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
17struct Method {
18 Method(const char *name,
Andreas Huber881227d2016-08-02 14:20:21 -070019 std::vector<TypedVar *> *args,
Andreas Huber3599d922016-08-09 10:42:57 -070020 std::vector<TypedVar *> *results,
21 KeyedVector<std::string, Annotation *> *annotations);
Andreas Huberc9410c72016-07-28 12:18:40 -070022
Andreas Huber881227d2016-08-02 14:20:21 -070023 std::string name() const;
24 const std::vector<TypedVar *> &args() const;
25 const std::vector<TypedVar *> &results() const;
Andreas Huber3599d922016-08-09 10:42:57 -070026 const KeyedVector<std::string, Annotation *> &annotations() const;
Andreas Huber881227d2016-08-02 14:20:21 -070027
28 static std::string GetSignature(const std::vector<TypedVar *> &args);
Andreas Huber2831d512016-08-15 09:33:47 -070029 static std::string GetJavaSignature(const std::vector<TypedVar *> &args);
Andreas Huber881227d2016-08-02 14:20:21 -070030
Andreas Huber3599d922016-08-09 10:42:57 -070031 void dumpAnnotations(Formatter &out) const;
32
Andreas Huberc9410c72016-07-28 12:18:40 -070033private:
34 std::string mName;
Andreas Huber881227d2016-08-02 14:20:21 -070035 std::vector<TypedVar *> *mArgs;
36 std::vector<TypedVar *> *mResults;
Andreas Huber3599d922016-08-09 10:42:57 -070037 KeyedVector<std::string, Annotation *> *mAnnotationsByName;
Andreas Huberc9410c72016-07-28 12:18:40 -070038
39 DISALLOW_COPY_AND_ASSIGN(Method);
40};
41
Andreas Huber31629bc2016-08-03 09:06:40 -070042struct TypedVar {
43 TypedVar(const char *name, Type *type);
44
45 std::string name() const;
46 const Type &type() const;
47
48private:
49 std::string mName;
50 Type *mType;
51
52 DISALLOW_COPY_AND_ASSIGN(TypedVar);
53};
54
Andreas Huberc9410c72016-07-28 12:18:40 -070055} // namespace android
56
57#endif // METHOD_H_
58