blob: 7e0058f1717106dedd30b9756aad14597188cf61 [file] [log] [blame]
Andreas Huberc9410c72016-07-28 12:18:40 -07001#include "Method.h"
2
3#include "Formatter.h"
4#include "Type.h"
5
6namespace android {
7
Andreas Huberc9410c72016-07-28 12:18:40 -07008Method::Method(
9 const char *name,
Andreas Huber881227d2016-08-02 14:20:21 -070010 std::vector<TypedVar *> *args,
11 std::vector<TypedVar *> *results)
Andreas Huberc9410c72016-07-28 12:18:40 -070012 : mName(name),
13 mArgs(args),
14 mResults(results) {
15}
16
Andreas Huber881227d2016-08-02 14:20:21 -070017std::string Method::name() const {
18 return mName;
19}
20
21const std::vector<TypedVar *> &Method::args() const {
22 return *mArgs;
23}
24
25const std::vector<TypedVar *> &Method::results() const {
26 return *mResults;
27}
28
29// static
30std::string Method::GetSignature(const std::vector<TypedVar *> &args) {
31 bool first = true;
32 std::string out;
33 for (const auto &arg : args) {
34 if (!first) {
35 out += ", ";
36 }
37
38 std::string extra;
39 out += arg->type().getCppArgumentType(&extra);
40 out += " ";
41 out += arg->name();
42 out += extra;
43
44 first = false;
45 }
46
47 return out;
48}
49
Andreas Huber31629bc2016-08-03 09:06:40 -070050////////////////////////////////////////////////////////////////////////////////
51
52TypedVar::TypedVar(const char *name, Type *type)
53 : mName(name),
54 mType(type) {
55}
56
57std::string TypedVar::name() const {
58 return mName;
59}
60
61const Type &TypedVar::type() const {
62 return *mType;
63}
64
Andreas Huberc9410c72016-07-28 12:18:40 -070065} // namespace android
66