slang_rs_export_func.h revision 6315f76e3cc6ff2d012d1183a0b030d4ff0dc808
1#ifndef _SLANG_COMPILER_RS_EXPORT_FUNC_H
2#define _SLANG_COMPILER_RS_EXPORT_FUNC_H
3
4#include <list>
5#include <string>
6
7#include "llvm/ADT/StringRef.h"
8
9namespace clang {
10  class FunctionDecl;
11}   // namespace clang
12
13namespace slang {
14
15  class RSContext;
16  class RSExportType;
17  class RSExportRecordType;
18
19class RSExportFunc {
20  friend class RSContext;
21 public:
22  class Parameter {
23   private:
24    RSExportType *mType;
25    std::string mName;
26
27   public:
28    Parameter(RSExportType *T, const llvm::StringRef &Name)
29        : mType(T),
30          mName(Name.data(), Name.size()) {
31      return;
32    }
33
34    inline const RSExportType *getType() const { return mType; }
35    inline const std::string &getName() const { return mName; }
36  };
37
38 private:
39  RSContext *mContext;
40  std::string mName;
41  std::list<const Parameter*> mParams;
42  mutable RSExportRecordType *mParamPacketType;
43
44  RSExportFunc(RSContext *Context, const llvm::StringRef &Name)
45      : mContext(Context),
46        mName(Name.data(), Name.size()),
47        mParamPacketType(NULL) {
48    return;
49  }
50
51 public:
52  static RSExportFunc *Create(RSContext *Context,
53                              const clang::FunctionDecl *FD);
54
55  typedef std::list<const Parameter*>::const_iterator const_param_iterator;
56
57  inline const_param_iterator params_begin() const {
58    return this->mParams.begin();
59  }
60  inline const_param_iterator params_end() const {
61    return this->mParams.end();
62  }
63
64  inline const std::string &getName() const {
65    return mName;
66  }
67  inline RSContext *getRSContext() const {
68    return mContext;
69  }
70
71  inline bool hasParam() const {
72    return !mParams.empty();
73  }
74  inline int getNumParameters() const {
75    return mParams.size();
76  }
77
78  const RSExportRecordType *getParamPacketType() const;
79
80  ~RSExportFunc();
81};  // RSExportFunc
82
83}   // namespace slang
84
85#endif  // _SLANG_COMPILER_RS_EXPORT_FUNC_H
86