• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_IDL_ASTMETHOD_H
17 #define OHOS_IDL_ASTMETHOD_H
18 
19 #include <cstddef>
20 #include <vector>
21 
22 #include "ast/ast_node.h"
23 #include "ast/ast_parameter.h"
24 #include "ast/ast_type.h"
25 #include "util/autoptr.h"
26 #include "util/string.h"
27 
28 namespace OHOS {
29 namespace Idl {
30 class ASTMethod : public ASTNode {
31 public:
SetName(const String & name)32     void SetName(const String& name)
33     {
34         name_ = name;
35     }
36 
GetName()37     String GetName()
38     {
39         return name_;
40     }
41 
42     String GetSignature();
43 
SetOneway(bool oneway)44     void SetOneway(bool oneway)
45     {
46         oneway_ = oneway;
47     }
48 
IsOneway()49     bool IsOneway()
50     {
51         return oneway_;
52     }
53 
SetReturnType(ASTType * type)54     void SetReturnType(ASTType* type)
55     {
56         returnType_ = type;
57     }
58 
GetReturnType()59     AutoPtr<ASTType> GetReturnType()
60     {
61         return returnType_;
62     }
63 
64     void AddParameter(ASTParameter* parameter);
65 
66     AutoPtr<ASTParameter> GetParameter(size_t index);
67 
GetParameterNumber()68     size_t GetParameterNumber()
69     {
70         return parameters_.size();
71     }
72 
73     String Dump(const String& prefix) override;
74 
75 private:
76     void BuildSignature();
77 
78     String name_;
79     String signature_;
80     bool oneway_ = false;
81     AutoPtr<ASTType> returnType_;
82     std::vector<AutoPtr<ASTParameter>> parameters_;
83 };
84 } // namespace Idl
85 } // namespace OHOS
86 #endif // OHOS_IDL_ASTMETHOD_H
87