• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef OHOS_HDI_ASTMETHOD_H
10 #define OHOS_HDI_ASTMETHOD_H
11 
12 #include <vector>
13 
14 #include "ast/ast_node.h"
15 #include "ast/ast_parameter.h"
16 #include "util/autoptr.h"
17 
18 namespace OHOS {
19 namespace HDI {
20 class ASTMethod : public ASTNode {
21 public:
SetName(const std::string & name)22     inline void SetName(const std::string &name)
23     {
24         name_ = name;
25     }
26 
GetName()27     inline std::string GetName()
28     {
29         return name_;
30     }
31 
SetAttribute(const AutoPtr<ASTAttr> & attr)32     inline void SetAttribute(const AutoPtr<ASTAttr> &attr)
33     {
34         if (attr != nullptr) {
35             attr_ = attr;
36         }
37     }
38 
GetAttribute()39     inline AutoPtr<ASTAttr> GetAttribute() const
40     {
41         return attr_;
42     }
43 
IsOneWay()44     inline bool IsOneWay() const
45     {
46         return attr_->HasValue(ASTAttr::ONEWAY);
47     }
48 
IsFull()49     inline bool IsFull() const
50     {
51         return attr_->HasValue(ASTAttr::FULL);
52     }
53 
IsLite()54     inline bool IsLite() const
55     {
56         return attr_->HasValue(ASTAttr::LITE);
57     }
58 
IsMini()59     inline bool IsMini() const
60     {
61         return attr_->HasValue(ASTAttr::MINI);
62     }
63 
64     void AddParameter(const AutoPtr<ASTParameter> &parameter);
65 
66     AutoPtr<ASTParameter> GetParameter(size_t index);
67 
GetParameterNumber()68     inline size_t GetParameterNumber()
69     {
70         return parameters_.size();
71     }
72 
73     std::string Dump(const std::string &prefix) override;
74 
75 private:
76     std::string name_;
77     AutoPtr<ASTAttr> attr_ = new ASTAttr();
78     std::vector<AutoPtr<ASTParameter>> parameters_;
79 };
80 } // namespace HDI
81 } // namespace OHOS
82 
83 #endif // OHOS_HDI_ASTMETHOD_H
84